Example #1
0
 /**
  * Returns the values of the identifier fields of an entity
  *
  * Doctrine must know about this entity, that is, the entity must already
  * be persisted or added to the identity map before. Otherwise an
  * exception is thrown.
  *
  * @param  object $entity  The entity for which to get the identifier
  * @throws FormException   If the entity does not exist in Doctrine's
  *                         identity map
  */
 public function getIdentifierValues($entity)
 {
     if (!$this->unitOfWork->isInIdentityMap($entity)) {
         throw new FormException('Entities passed to the choice field must be managed');
     }
     return $this->unitOfWork->getEntityIdentifier($entity);
 }
Example #2
0
 /**
  * Checks if the instance is managed by the EntityManager.
  * 
  * @param object $entity
  * @return boolean TRUE if this EntityManager currently manages the given entity
  *                 (and has it in the identity map), FALSE otherwise.
  */
 public function contains($entity)
 {
     return $this->_unitOfWork->isInIdentityMap($entity) && !$this->_unitOfWork->isRegisteredRemoved($entity);
 }
Example #3
0
 /**
  * Determines whether an entity instance is managed in this EntityManager.
  *
  * @param object $entity
  * @return boolean TRUE if this EntityManager currently manages the given entity, FALSE otherwise.
  */
 public function contains($entity)
 {
     return $this->_unitOfWork->isScheduledForInsert($entity) || $this->_unitOfWork->isInIdentityMap($entity) && !$this->_unitOfWork->isScheduledForDelete($entity);
 }