2017 © Pedro Peláez
 

interface identifier-interface

Write down your routing mapping at one place

image

happyr/identifier-interface

Write down your routing mapping at one place

  • Wednesday, January 1, 2014
  • by Nyholm
  • Repository
  • 2 Watchers
  • 0 Stars
  • 361 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

HappyR Identifier Interface

This "library" is not much. It is just one interface. The interface makes sure you have a public function called getId()., (*1)

Say that you are writing AcmeMessageBundle with a Message entity. Each Message should have a relation to a User. You could write something like this:, (*2)


class Message { private $user; /* ... */ public function setUser(IdentifierInterface $user) { $this->user = $user; } /* ... */ } class MessageSenderService { /* ... */ public function send(Message $message, IdentifierInterface $recipient) { if ($message->getUser()->getId() == $recipient->getId()) { throw new \Exception("You can not send a message to yourself."); } /* ... */ } }

You could of course ship your own IdentifierInterface with your AcmeMessageBundle but after a while you will notice that your User entity implements too many interfaces..., (*3)

class User implements SymfonyUserInterface, AcmeMessageBundleIdInterface, OtherBundleInterface, AcmeDemoBundleUserInterface, CompanyBundleIdentifierInterface, MyIndentifierInterface
{
  /* ... */
}

When we create Symfony2 bundles we will always use the HappyR Identifier Interface for both public and interal work., (*4)

The Versions

01/01 2014

dev-master

9999999-dev http://developer.happyr.se/

Write down your routing mapping at one place

  Sources   Download

MIT

The Requires

  • php >=5

 

identifier interface id

01/01 2014

1.0.0

1.0.0.0 http://developer.happyr.se/

Write down your routing mapping at one place

  Sources   Download

MIT

The Requires

  • php >=5

 

identifier interface id