Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function persist($entity)
 {
     if (!is_object($entity)) {
         throw ORMInvalidArgumentException::invalidObject('EntityManager#persist()', $entity);
     }
     $this->getUnitOfWork()->persist($entity);
 }
Esempio n. 2
0
 /**
  * Merges the state of a detached entity into the persistence context
  * of this EntityManager and returns the managed copy of the entity.
  * The entity passed to merge will not become associated/managed with this EntityManager.
  *
  * @param object $entity The detached entity to merge into the persistence context.
  *
  * @return object The managed copy of the entity.
  *
  * @throws ORMInvalidArgumentException
  */
 public function merge($entity)
 {
     if (!is_object($entity)) {
         throw ORMInvalidArgumentException::invalidObject('EntityManager#merge()', $entity);
     }
     $this->errorIfClosed();
     return $this->unitOfWork->merge($entity);
 }
Esempio n. 3
0
 /**
  * Is this entity read only?
  *
  * @param object $object
  *
  * @return bool
  *
  * @throws ORMInvalidArgumentException
  */
 public function isReadOnly($object)
 {
     if (!is_object($object)) {
         throw ORMInvalidArgumentException::readOnlyRequiresManagedEntity($object);
     }
     return isset($this->readOnlyObjects[spl_object_hash($object)]);
 }
Esempio n. 4
0
 /**
  * Processes an individual parameter value.
  *
  * @param mixed $value
  *
  * @return array
  *
  * @throws ORMInvalidArgumentException
  */
 public function processParameterValue($value)
 {
     if (is_array($value)) {
         foreach ($value as $key => $paramValue) {
             $paramValue = $this->processParameterValue($paramValue);
             $value[$key] = is_array($paramValue) ? reset($paramValue) : $paramValue;
         }
         return $value;
     }
     if (is_object($value) && $this->_em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($value))) {
         $value = $this->_em->getUnitOfWork()->getSingleIdentifierValue($value);
         if ($value === null) {
             throw ORMInvalidArgumentException::invalidIdentifierBindingEntity();
         }
     }
     return $value;
 }
Esempio n. 5
0
 /**
  * @param \Doctrine\ORM\Mapping\ClassMetadata $metadata   The entity metadata.
  * @param mixed                               $identifier The entity identifier.
  *
  * @return array
  */
 private function toIdentifierArray(ClassMetadata $metadata, $identifier)
 {
     if (is_object($identifier) && $this->em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($identifier))) {
         $identifier = $this->uow->getSingleIdentifierValue($identifier);
         if ($identifier === null) {
             throw ORMInvalidArgumentException::invalidIdentifierBindingEntity();
         }
     }
     return array($metadata->identifier[0] => $identifier);
 }
 /**
  * @param ORMInvalidArgumentException $exception
  * @throws ReportException
  */
 protected function inverseSideAdderThrowAdderOrmInvalidArgumentException(ORMInvalidArgumentException $exception)
 {
     $message = 'ORMInvalidArgumentException occured after calling ';
     $message .= $this->getInverseSideClassName() . '::' . $this->getInverseSideAdder() . '(), ';
     $message .= 'then ' . get_class($this->getManager()) . '::flush().';
     $errorReport = new ErrorReport($message);
     $errorReport->addError($exception->getMessage());
     $this->inverseSideAdderAddInverseSideEntityPersistError($errorReport);
     throw new ReportException($this->getReport(), $errorReport);
 }