コード例 #1
0
 /**
  * Checks if provided person is the same person who is logged in.
  * Contains somehow tricky logic, for identity, stored in a session
  * is not an instance of Person.
  * See documentation for \Application\Entity\Account class for details.
  * @param Person $person person to check if logged in
  * @return boolean true then and only then $person has the same ID as logged in person
  */
 protected function isMyself(Person $person)
 {
     if ($this->identity() == null) {
         return false;
     }
     if ($myself = $this->identity()->getPerson()) {
         if ($myself == null) {
             return false;
         }
         return $person->getId() == $myself->getId();
     }
     return false;
 }
コード例 #2
0
ファイル: ContactService.php プロジェクト: Wbondar/Buddies
 public function destroy(Person $source, $idOfContact)
 {
     $contact = $this->retrieve($idOfContact);
     if ($source->getContacts()->contains($contact)) {
         $this->objectManager->remove($contact);
         /*
          * Note: Reflected contact might not be needed for other types of contacts.
          * TODO Implement DQL query for handling deletion of bidirectional contacts.
          */
         foreach ($contact->getTarget()->getContacts() as $reflectedContact) {
             if ($reflectedContact->getTarget()->getId() == $source->getId()) {
                 $this->objectManager->remove($reflectedContact);
             }
         }
         $this->objectManager->flush();
     }
 }
コード例 #3
0
 /**
  * {@inheritDoc}
  */
 public function getId()
 {
     if ($this->__isInitialized__ === false) {
         return (int) parent::getId();
     }
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array());
     return parent::getId();
 }