/**
  * Finds an object from the repository by searching for its identity properties.
  *
  * @param array $identityProperties Property names and values to search for
  * @param string $type The object type to look for
  * @return mixed Either the object matching the identity or FALSE if no object was found
  * @throws \RuntimeException if more than one object was found
  * @author Robert Lemke <*****@*****.**>
  * @author Karsten Dambekalns <*****@*****.**>
  */
 protected function findObjectByIdentityProperties(array $identityProperties, $type)
 {
     $query = $this->queryFactory->create($type);
     $classSchema = $this->reflectionService->getClassSchema($type);
     $equals = array();
     foreach ($classSchema->getIdentityProperties() as $propertyName => $propertyType) {
         if (isset($identityProperties[$propertyName])) {
             if ($propertyType === 'string') {
                 $equals[] = $query->equals($propertyName, $identityProperties[$propertyName], FALSE);
             } else {
                 $equals[] = $query->equals($propertyName, $identityProperties[$propertyName]);
             }
         }
     }
     if (count($equals) === 1) {
         $constraint = current($equals);
     } else {
         $constraint = $query->logicalAnd(current($equals), next($equals));
         while (($equal = next($equals)) !== FALSE) {
             $constraint = $query->logicalAnd($constraint, $equal);
         }
     }
     $objects = $query->matching($constraint)->execute();
     if (count($objects) === 1) {
         return current($objects);
     } elseif (count($objects) === 0) {
         return FALSE;
     } else {
         throw new \RuntimeException('More than one object was returned for the given identity, this is a constraint violation.', 1259612399);
     }
 }
 /**
  * Register an object's clean state, e.g. after it has been reconstituted
  * from the FLOW3 persistence layer
  *
  * The method takes an optional argument $propertyName to mark only the
  * specified property as clean. This was used in conjunction with lazy
  * loading...
  *
  * @param \F3\FLOW3\AOP\JoinPointInterface $joinPoint
  * @return void
  * @before F3\FLOW3\Persistence\Aspect\DirtyMonitoringAspect->needsDirtyCheckingAspect && method(.*->FLOW3_Persistence_memorizeCleanState())
  * @author Karsten Dambekalns <*****@*****.**>
  */
 public function memorizeCleanState(\F3\FLOW3\AOP\JoinPointInterface $joinPoint)
 {
     $proxy = $joinPoint->getProxy();
     if ($joinPoint->getMethodArgument('propertyName') !== NULL) {
         $propertyNames = array($joinPoint->getMethodArgument('propertyName'));
     } else {
         $propertyNames = array_keys($this->reflectionService->getClassSchema($joinPoint->getClassName())->getProperties());
     }
     foreach ($propertyNames as $propertyName) {
         if (is_object($proxy->FLOW3_AOP_Proxy_getProperty($propertyName))) {
             $proxy->FLOW3_Persistence_cleanProperties[$propertyName] = clone $proxy->FLOW3_AOP_Proxy_getProperty($propertyName);
         } else {
             $proxy->FLOW3_Persistence_cleanProperties[$propertyName] = $proxy->FLOW3_AOP_Proxy_getProperty($propertyName);
         }
     }
 }
 /**
  * Maps a single record into the object it represents and registers it as
  * reconstituted with the session.
  *
  * @param array $objectData
  * @return object
  * @author Karsten Dambekalns <*****@*****.**>
  */
 public function mapToObject(array $objectData)
 {
     if ($this->persistenceSession->hasIdentifier($objectData['identifier'])) {
         return $this->persistenceSession->getObjectByIdentifier($objectData['identifier']);
     } else {
         $className = $objectData['classname'];
         $classSchema = $this->reflectionService->getClassSchema($className);
         $objectConfiguration = $this->objectManager->getObjectConfiguration($className);
         $object = $this->objectBuilder->createEmptyObject($className, $objectConfiguration);
         $this->persistenceSession->registerObject($object, $objectData['identifier']);
         $this->objectBuilder->reinjectDependencies($object, $objectConfiguration);
         $this->thawProperties($object, $objectData['identifier'], $objectData, $classSchema);
         $object->FLOW3_Persistence_memorizeCleanState();
         $this->persistenceSession->registerReconstitutedObject($object);
         return $object;
     }
 }
 /**
  * Initializes this object
  *
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 public function initializeObject()
 {
     $this->dataTypeClassSchema = $this->reflectionService->getClassSchema($this->dataType);
 }