/**
  * In this method, actually create the user / account.
  *
  * NOTE: After this method is called, the $registrationFlow is DESTROYED, so you need to store all attributes
  * in your object as you need them.
  *
  * @param RegistrationFlow $registrationFlow
  * @return void
  */
 public function createUserAndAccount(RegistrationFlow $registrationFlow)
 {
     // Create the account
     $account = new Account();
     $account->setAccountIdentifier($registrationFlow->getEmail());
     $account->setCredentialsSource($registrationFlow->getEncryptedPassword());
     $account->setAuthenticationProviderName('Sandstorm.UserManagement:Login');
     // Assign pre-configured roles
     foreach ($this->rolesForNewUsers as $roleString) {
         $account->addRole(new Role($roleString));
     }
     // Create the user
     $user = new User();
     $user->setAccount($account);
     $user->setEmail($registrationFlow->getEmail());
     if (array_key_exists('salutation', $registrationFlow->getAttributes())) {
         $user->setGender($registrationFlow->getAttributes()['salutation']);
     }
     if (array_key_exists('firstName', $registrationFlow->getAttributes())) {
         $user->setFirstName($registrationFlow->getAttributes()['firstName']);
     }
     if (array_key_exists('lastName', $registrationFlow->getAttributes())) {
         $user->setLastName($registrationFlow->getAttributes()['lastName']);
     }
     // Persist user
     $this->userRepository->add($user);
     $this->persistenceManager->whitelistObject($user);
     $this->persistenceManager->whitelistObject($account);
 }
 /**
  * @param mixed $source
  * @param \Flowpack\ElasticSearch\Annotations\Transform $annotation
  * @return string
  */
 public function transformByAnnotation($source, \Flowpack\ElasticSearch\Annotations\Transform $annotation)
 {
     if ($source != null) {
         return $this->persistenceManager->getIdentifierByObject($source);
     }
     return '';
 }
 /**
  * @param \DLigo\Animaltool\Domain\Model\Animal $animal
  */
 public function findByAnimal($animal)
 {
     $id = $this->persistenceManager->getIdentifierByObject($animal);
     $query = $this->createQuery();
     $query->matching($query->equals('animalId', $id))->setOrderings(array('time' => \TYPO3\Flow\Persistence\QueryInterface::ORDER_DESCENDING));
     return $query->execute();
 }
 /**
  * Executes this finisher
  * @see AbstractFinisher::execute()
  *
  * @return void
  * @throws \TYPO3\Flow\Mvc\Exception\StopActionException();
  */
 protected function executeInternal()
 {
     /** @var \TYPO3\Form\Core\Runtime\FormRuntime $formRuntime */
     $formRuntime = $this->finisherContext->getFormRuntime();
     $formValueArray = $formRuntime->getFormState()->getFormValues();
     /** @var \GIB\GradingTool\Domain\Model\Project $project */
     $project = $this->projectRepository->findByIdentifier($formRuntime->getRequest()->getParentRequest()->getArgument('project'));
     // store changes to project
     $project->setProjectData($formValueArray);
     $this->projectRepository->update($project);
     // add a flash message
     $message = new \TYPO3\Flow\Error\Message('The project data for "%s" was successfully edited.', \TYPO3\Flow\Error\Message::SEVERITY_OK, array($project->getProjectTitle()));
     $this->flashMessageContainer->addMessage($message);
     $this->persistenceManager->persistAll();
     // redirect to dashboard
     $formRuntime = $this->finisherContext->getFormRuntime();
     $request = $formRuntime->getRequest()->getMainRequest();
     $uriBuilder = new \TYPO3\Flow\Mvc\Routing\UriBuilder();
     $uriBuilder->setRequest($request);
     $uriBuilder->reset();
     $uri = $uriBuilder->uriFor('index', NULL, 'Admin');
     $response = $formRuntime->getResponse();
     $mainResponse = $response;
     while ($response = $response->getParentResponse()) {
         $mainResponse = $response;
     }
     $mainResponse->setStatus(303);
     $mainResponse->setHeader('Location', (string) $uri);
     throw new \TYPO3\Flow\Mvc\Exception\StopActionException();
 }
 /**
  * Change the property on the given node.
  *
  * @param NodeData $node
  * @return void
  */
 public function execute(NodeData $node)
 {
     foreach ($node->getNodeType()->getProperties() as $propertyName => $propertyConfiguration) {
         if (isset($propertyConfiguration['type']) && in_array(trim($propertyConfiguration['type']), $this->getHandledObjectTypes())) {
             if (!isset($nodeProperties)) {
                 $nodeRecordQuery = $this->entityManager->getConnection()->prepare('SELECT properties FROM typo3_typo3cr_domain_model_nodedata WHERE persistence_object_identifier=?');
                 $nodeRecordQuery->execute([$this->persistenceManager->getIdentifierByObject($node)]);
                 $nodeRecord = $nodeRecordQuery->fetch(\PDO::FETCH_ASSOC);
                 $nodeProperties = unserialize($nodeRecord['properties']);
             }
             if (!isset($nodeProperties[$propertyName]) || !is_object($nodeProperties[$propertyName])) {
                 continue;
             }
             /** @var Asset $assetObject */
             $assetObject = $nodeProperties[$propertyName];
             $nodeProperties[$propertyName] = null;
             $stream = $assetObject->getResource()->getStream();
             if ($stream === false) {
                 continue;
             }
             fclose($stream);
             $objectType = TypeHandling::getTypeForValue($assetObject);
             $objectIdentifier = ObjectAccess::getProperty($assetObject, 'Persistence_Object_Identifier', true);
             $nodeProperties[$propertyName] = array('__flow_object_type' => $objectType, '__identifier' => $objectIdentifier);
         }
     }
     if (isset($nodeProperties)) {
         $nodeUpdateQuery = $this->entityManager->getConnection()->prepare('UPDATE typo3_typo3cr_domain_model_nodedata SET properties=? WHERE persistence_object_identifier=?');
         $nodeUpdateQuery->execute([serialize($nodeProperties), $this->persistenceManager->getIdentifierByObject($node)]);
     }
 }
 /**
  * @test
  */
 public function renderWithoutValueInvokesRenderChildren()
 {
     $object = new \stdClass();
     $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue($object));
     $this->mockPersistenceManager->expects($this->once())->method('getIdentifierByObject')->with($object)->will($this->returnValue('b59292c5-1a28-4b36-8615-10d3c5b3a4d8'));
     $this->assertEquals('b59292c5-1a28-4b36-8615-10d3c5b3a4d8', $this->viewHelper->render());
 }
 /**
  * @param BadgeAssertion $badgeAssertion
  * @return array
  */
 public function badgeAssertionToArray(BadgeAssertion $badgeAssertion)
 {
     $badgeClassUri = $this->controllerContext->getUriBuilder()->reset()->setCreateAbsoluteUri(TRUE)->setFormat('json')->uriFor('show', array('badgeClass' => $badgeAssertion->getBadgeClass()), 'BadgeClass');
     $badgeAssertionUri = $this->controllerContext->getUriBuilder()->reset()->setCreateAbsoluteUri(TRUE)->setFormat('json')->uriFor('show', array('badgeAssertion' => $badgeAssertion), 'BadgeAssertion');
     $badgeAssertionIdentifier = $this->persistenceManager->getIdentifierByObject($badgeAssertion);
     return array('uid' => $badgeAssertionIdentifier, 'recipient' => $badgeAssertion->getIdentityObject(), 'badge' => $badgeClassUri, 'verify' => array('type' => 'hosted', 'url' => $badgeAssertionUri), 'issuedOn' => $badgeAssertion->getIssuedOn()->format('c'));
 }
 /**
  * After returning advice, making sure we have an UUID for each and every entity.
  *
  * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point
  * @return void
  * @Flow\Before("TYPO3\Flow\Persistence\Aspect\PersistenceMagicAspect->isEntity && method(.*->(__construct|__clone)()) && filter(TYPO3\Flow\Persistence\Doctrine\Mapping\Driver\FlowAnnotationDriver)")
  */
 public function generateUuid(JoinPointInterface $joinPoint)
 {
     /** @var $proxy \TYPO3\Flow\Persistence\Aspect\PersistenceMagicInterface */
     $proxy = $joinPoint->getProxy();
     ObjectAccess::setProperty($proxy, 'Persistence_Object_Identifier', Algorithms::generateUUID(), TRUE);
     $this->persistenceManager->registerNewObject($proxy);
 }
Example #9
0
 /**
  */
 public function getOptions()
 {
     $classSchema = $this->reflectionService->getClassSchema($this->getRelationClass());
     if ($classSchema->getRepositoryClassName() !== NULL) {
         $repository = $this->objectManager->get($classSchema->getRepositoryClassName());
         $query = call_user_func(array($repository, $this->settings['QueryMethod']));
     } else {
         $query = $this->persistenceManager->createQueryForType($this->getRelationClass());
     }
     $options = $query->execute()->toArray();
     if ($this->settings['LabelPath'] !== NULL) {
         $options = array();
         foreach ($query->execute() as $option) {
             $identifier = $this->persistenceManager->getIdentifierByObject($option);
             $label = ObjectAccess::getPropertyPath($option, $this->settings['LabelPath']);
             $options[$identifier] = $label;
         }
     }
     if ($this->settings['EmptyOption'] !== NULL) {
         $newOptions = array('' => $this->settings['EmptyOption']);
         foreach ($options as $key => $value) {
             $newOptions[$key] = $value;
         }
         $options = $newOptions;
     }
     return $options;
 }
Example #10
0
 /**
  * Gets the Party having an Account assigned
  *
  * @param Account $account
  * @return AbstractParty
  */
 public function getAssignedPartyOfAccount(Account $account)
 {
     $accountIdentifier = $this->persistenceManager->getIdentifierByObject($account);
     if (isset($this->accountsInPartyRuntimeCache[$accountIdentifier])) {
         return $this->accountsInPartyRuntimeCache[$accountIdentifier];
     }
     return $this->partyRepository->findOneHavingAccount($account);
 }
 /**
  * Returns cache cache tag parts for the given object if known, otherwise NULL.
  *
  * @param $object
  * @return mixed
  */
 public function identifyCacheTagForObject($object)
 {
     $className = get_class($object);
     if (property_exists($object, 'Persistence_Object_Identifier') || $this->reflectionService->isClassAnnotatedWith($className, Flow\Entity::class) || $this->reflectionService->isClassAnnotatedWith($className, Flow\ValueObject::class) || $this->reflectionService->isClassAnnotatedWith($className, Doctrine\Entity::class)) {
         $identifier = $this->persistenceManager->getIdentifierByObject($object);
         return $className . '_' . $identifier;
     }
 }
Example #12
0
 /**
  * @param NodeInterface $node The node that is currently edited (optional)
  * @param array $arguments Additional arguments (key / value)
  * @return array
  */
 public function getData(NodeInterface $node, array $arguments)
 {
     $options = [];
     foreach ($this->userService->getUsers() as $user) {
         $options[$this->persistenceManager->getIdentifierByObject($user)] = ['label' => $user->getLabel()];
     }
     return $options;
 }
 /**
  * Get data
  *
  * @param NodeInterface $node unused
  * @param array $arguments unused
  * @return array title of all asset collections
  */
 public function getData(NodeInterface $node = NULL, array $arguments)
 {
     $assetCollections = [];
     /** @var AssetCollection $assetCollection */
     foreach ($this->assetCollectionRepository->findAll() as $assetCollection) {
         $assetCollections[] = ['value' => $this->persistenceManager->getIdentifierByObject($assetCollection), 'label' => $assetCollection->getTitle()];
     }
     return $assetCollections;
 }
 /**
  * @Flow\Around("method(TYPO3\Neos\Service\ContentElementWrappingService->getNodeProperty())")
  * @param JoinPointInterface $joinPoint
  */
 public function getNodePropertyWithBadgeClass(JoinPointInterface $joinPoint)
 {
     $result = $joinPoint->getAdviceChain()->proceed($joinPoint);
     if ($result instanceof BadgeClass) {
         return json_encode($this->persistenceManager->getIdentifierByObject($result));
     } else {
         return $result;
     }
 }
 public function setAnimal($id)
 {
     $animal = $this->animalRepository->findByIdentifier($id);
     foreach ($animal->getTreatments() as $tr) {
         foreach ($tr->getTherapies() as $th) {
             $this->therapies[$this->persistenceManager->getIdentifierByObject($th)] = true;
         }
     }
 }
Example #16
0
 /**
  * @param NodeInterface|null $node
  * @param array $arguments
  * @return \TYPO3\Flow\Persistence\QueryResultInterface
  */
 public function getData(NodeInterface $node = null, array $arguments)
 {
     $tagCollection = $this->tagRepository->findAll();
     $tags = [];
     foreach ($tagCollection as $tag) {
         /** @var \TYPO3\Media\Domain\Model\Tag $tag */
         $tags[$this->persistenceManager->getIdentifierByObject($tag)] = $tag;
     }
     return $tags;
 }
 /**
  * @test
  * @return void
  */
 public function generateUuidGeneratesUuidAndRegistersProxyAsNewObject()
 {
     $className = 'Class' . md5(uniqid(mt_rand(), TRUE));
     eval('class ' . $className . ' implements \\TYPO3\\Flow\\Persistence\\Aspect\\PersistenceMagicInterface { public $Persistence_Object_Identifier = NULL; }');
     $object = new $className();
     $this->mockJoinPoint->expects($this->atLeastOnce())->method('getProxy')->will($this->returnValue($object));
     $this->mockPersistenceManager->expects($this->atLeastOnce())->method('registerNewObject')->with($object);
     $this->persistenceMagicAspect->generateUuid($this->mockJoinPoint);
     $this->assertEquals(36, strlen($object->Persistence_Object_Identifier));
 }
 /**
  * Get data
  *
  * @param NodeInterface $node The node that is currently edited (optional)
  * @param array $arguments Additional arguments (key / value)
  * @return mixed JSON serializable data
  * @api
  */
 public function getData(NodeInterface $node = NULL, array $arguments)
 {
     $result = array();
     $result[''] = array('label' => 'Please select a receiver group');
     foreach ($this->receiverGroupRepository->findAll() as $receiverGroup) {
         /* @var $receiverGroup \Sandstorm\Newsletter\Domain\Model\ReceiverGroup */
         $result[$this->persistenceManager->getIdentifierByObject($receiverGroup)] = array('label' => $receiverGroup->getFullLabel());
     }
     return $result;
 }
Example #19
0
 /**
  * @test
  */
 public function getAssignedPartyOfAccountCachesParty()
 {
     $this->mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValue('723e3913-f803-42c8-a44c-fd7115f555c3'));
     $this->mockPartyRepository->expects($this->once())->method('findOneHavingAccount')->with($this->account)->will($this->returnValue($this->party));
     $this->party->addAccount($this->account);
     $assignedParty = $this->partyService->getAssignedPartyOfAccount($this->account);
     $this->assertSame($this->party, $assignedParty);
     $assignedParty = $this->partyService->getAssignedPartyOfAccount($this->account);
     $this->assertSame($this->party, $assignedParty);
 }
 /**
  * Sets up this test case
  *
  */
 public function setUp()
 {
     $this->mockObjectManager = $this->getMock(\TYPO3\Flow\Object\ObjectManagerInterface::class);
     $this->route = $this->getAccessibleMock(\TYPO3\Flow\Mvc\Routing\Route::class, array('dummy'));
     $this->route->_set('objectManager', $this->mockObjectManager);
     $this->mockPersistenceManager = $this->getMock(\TYPO3\Flow\Persistence\PersistenceManagerInterface::class);
     $this->mockPersistenceManager->expects($this->any())->method('convertObjectsToIdentityArrays')->will($this->returnCallback(function ($array) {
         return $array;
     }));
     $this->inject($this->route, 'persistenceManager', $this->mockPersistenceManager);
 }
 /**
  * Get data
  *
  * @param NodeInterface $node The node that is currently edited (optional)
  * @param array $arguments Additional arguments (key / value)
  * @return array JSON serializable data
  */
 public function getData(NodeInterface $node = NULL, array $arguments)
 {
     $collections = $this->instagramCollectionRepository->findAll();
     /* @var \Weissheiten\Neos\InstagramMedia\Domain\Model\InstagramCollection $col */
     foreach ($collections as $col) {
         /*$rv[] = array('value' => json_encode(array('__identity' => $this->persistenceManager->getIdentifierByObject($col),
           '__type' => '\Weissheiten\Neos\InstagramMedia\Domain\Model\InstagramCollection')),*/
         $rv[] = array('value' => $this->persistenceManager->getIdentifierByObject($col), 'label' => $col->getTitle());
     }
     return $rv;
 }
 /**
  * Loads the objects this LazySplObjectStorage is supposed to hold.
  *
  * @return void
  */
 protected function initialize()
 {
     if (is_array($this->objectIdentifiers)) {
         foreach ($this->objectIdentifiers as $identifier) {
             try {
                 parent::attach($this->persistenceManager->getObjectByIdentifier($identifier));
             } catch (\TYPO3\Flow\Persistence\Generic\Exception\InvalidObjectDataException $exception) {
                 // when security query rewriting holds back an object here, we skip it...
             }
         }
         $this->objectIdentifiers = null;
     }
 }
 /**
  * Outputs the identifier of the specified object
  *
  * @param object $value the object to render the identifier for, or NULL if VH children should be used
  * @return mixed the identifier of $value, usually the UUID
  * @throws ViewHelper\Exception if the given value is no object
  * @api
  */
 public function render($value = NULL)
 {
     if ($value === NULL) {
         $value = $this->renderChildren();
     }
     if ($value === NULL) {
         return NULL;
     }
     if (!is_object($value)) {
         throw new ViewHelper\Exception('f:format.identifier expects an object, ' . gettype($value) . ' given.', 1337700024);
     }
     return $this->persistenceManager->getIdentifierByObject($value);
 }
 /**
  * Renders a hidden form field containing the technical identity of the given object.
  *
  * @param object $object Object to create the identity field for
  * @param string $name Name
  * @return string A hidden field containing the Identity (UUID in Flow) of the given object or NULL if the object is unknown to the persistence framework
  * @see \TYPO3\Flow\Mvc\Controller\Argument::setValue()
  */
 protected function renderHiddenIdentityField($object, $name)
 {
     if (!is_object($object) || $this->persistenceManager->isNewObject($object)) {
         return '';
     }
     $identifier = $this->persistenceManager->getIdentifierByObject($object);
     if ($identifier === null) {
         return chr(10) . '<!-- Object of type ' . get_class($object) . ' is without identity -->' . chr(10);
     }
     $name = $this->prefixFieldName($name) . '[__identity]';
     $this->registerFieldNameForFormTokenGeneration($name);
     return chr(10) . '<input type="hidden" name="' . $name . '" value="' . $identifier . '" />' . chr(10);
 }
 /**
  * @param \Lightwerk\SurfCaptain\Domain\Model\Deployment $surfCaptainDeployment
  * @param \TYPO3\Flow\Log\LoggerInterface $logger
  * @return Deployment
  * @throws Exception
  */
 public function getDeploymentByDeploymentRecord(\Lightwerk\SurfCaptain\Domain\Model\Deployment $surfCaptainDeployment, LoggerInterface $logger)
 {
     $deployment = new Deployment($this->persistenceManager->getIdentifierByObject($surfCaptainDeployment));
     $deployment->setLogger($logger);
     $configuration = $surfCaptainDeployment->getConfiguration();
     if (empty($configuration['applications']) || !is_array($configuration['applications'])) {
         throw new Exception('No applications are given in deployment configuration', 1408397565);
     }
     $applications = $this->applicationFactory->getApplicationsByConfiguration($configuration['applications']);
     foreach ($applications as $application) {
         $deployment->addApplication($application);
     }
     return $deployment;
 }
Example #26
0
 /**
  * Appends the given message along with the additional information into the log.
  *
  * @param string $message The message to log
  * @param integer $severity One of the LOG_* constants
  * @param mixed $additionalData A variable containing more information about the event to be logged
  * @param string $packageKey Key of the package triggering the log (determined automatically if not specified)
  * @param string $className Name of the class triggering the log (determined automatically if not specified)
  * @param string $methodName Name of the method triggering the log (determined automatically if not specified)
  * @return void
  * @api
  */
 public function append($message, $severity = LOG_INFO, $additionalData = NULL, $packageKey = NULL, $className = NULL, $methodName = NULL)
 {
     if ($this->number < self::MAX_LOGS) {
         $log = new Log();
         $log->setDeployment($this->deployment)->setDate(new \DateTime())->setNumber(++$this->number)->setMessage($message)->setSeverity($severity);
         $this->logRepository->add($log);
         $this->persistenceManager->persistAll();
     } elseif ($this->number === self::MAX_LOGS) {
         $log = new Log();
         $log->setDeployment($this->deployment)->setDate(new \DateTime())->setNumber(++$this->number)->setMessage('logging killed with #logs > ' . self::MAX_LOGS)->setSeverity(LOG_EMERG);
         $this->logRepository->add($log);
         $this->persistenceManager->persistAll();
     }
 }
Example #27
0
 /**
  * Sets up this test case
  *
  */
 public function setUp()
 {
     $this->mockObjectManager = $this->getMock('TYPO3\\Flow\\Object\\ObjectManagerInterface');
     $this->mockObjectManager->expects($this->any())->method('create')->will($this->returnCallback(array($this, 'objectManagerCallBack')));
     $this->route = $this->getAccessibleMock('TYPO3\\Flow\\Mvc\\Routing\\Route', array('dummy'));
     $this->route->_set('objectManager', $this->mockObjectManager);
     $this->mockRouter = $this->getMock('TYPO3\\Flow\\Mvc\\Routing\\RouterInterface');
     $this->mockRouter->expects($this->any())->method('getControllerObjectName')->will($this->returnValue('SomeControllerObjectName'));
     $this->inject($this->route, 'router', $this->mockRouter);
     $this->mockPersistenceManager = $this->getMock('TYPO3\\Flow\\Persistence\\PersistenceManagerInterface');
     $this->mockPersistenceManager->expects($this->any())->method('convertObjectsToIdentityArrays')->will($this->returnCallback(function ($array) {
         return $array;
     }));
     $this->inject($this->route, 'persistenceManager', $this->mockPersistenceManager);
 }
 /**
  * Sends the given HTTP request
  *
  * @param Http\Request $httpRequest
  * @return Http\Response
  * @throws Http\Exception
  * @api
  */
 public function sendRequest(Http\Request $httpRequest)
 {
     $requestHandler = $this->bootstrap->getActiveRequestHandler();
     if (!$requestHandler instanceof FunctionalTestRequestHandler) {
         throw new Http\Exception('The browser\'s internal request engine has only been designed for use within functional tests.', 1335523749);
     }
     $this->securityContext->clearContext();
     $this->validatorResolver->reset();
     $response = new Http\Response();
     $requestHandler->setHttpRequest($httpRequest);
     $requestHandler->setHttpResponse($response);
     $objectManager = $this->bootstrap->getObjectManager();
     $baseComponentChain = $objectManager->get(\TYPO3\Flow\Http\Component\ComponentChain::class);
     $componentContext = new ComponentContext($httpRequest, $response);
     if (version_compare(PHP_VERSION, '6.0.0') >= 0) {
         try {
             $baseComponentChain->handle($componentContext);
         } catch (\Throwable $throwable) {
             $this->prepareErrorResponse($throwable, $response);
         }
     } else {
         try {
             $baseComponentChain->handle($componentContext);
         } catch (\Exception $exception) {
             $this->prepareErrorResponse($exception, $response);
         }
     }
     $session = $this->bootstrap->getObjectManager()->get(\TYPO3\Flow\Session\SessionInterface::class);
     if ($session->isStarted()) {
         $session->close();
     }
     $this->persistenceManager->clearState();
     return $response;
 }
 /**
  * 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 object Either the object matching the identity or NULL if no object was found
  * @throws DuplicateObjectException if more than one object was found
  */
 protected function findObjectByIdentityProperties(array $identityProperties, $type)
 {
     $query = $this->persistenceManager->createQueryForType($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();
     $numberOfResults = $objects->count();
     if ($numberOfResults === 1) {
         return $objects->getFirst();
     } elseif ($numberOfResults === 0) {
         return NULL;
     } else {
         throw new DuplicateObjectException('More than one object was returned for the given identity, this is a constraint violation.', 1259612399);
     }
 }
 /**
  * After returning advice, generates the value hash for the object
  *
  * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point
  * @return void
  * @Flow\After("classAnnotatedWith(TYPO3\Flow\Annotations\ValueObject) && method(.*->__construct()) && filter(TYPO3\Flow\Persistence\Doctrine\Mapping\Driver\FlowAnnotationDriver)")
  */
 public function generateValueHash(JoinPointInterface $joinPoint)
 {
     $proxy = $joinPoint->getProxy();
     $proxyClassName = get_class($proxy);
     $hashSourceParts = array();
     $classSchema = $this->reflectionService->getClassSchema($proxyClassName);
     foreach ($classSchema->getProperties() as $property => $propertySchema) {
         // Currently, private properties are transient. Should this behaviour change, they need to be included
         // in the value hash generation
         if ($classSchema->isPropertyTransient($property) || $this->reflectionService->isPropertyPrivate($proxyClassName, $property)) {
             continue;
         }
         $propertyValue = ObjectAccess::getProperty($proxy, $property, true);
         if (is_object($propertyValue) === true) {
             // The persistence manager will return NULL if the given object is unknown to persistence
             $propertyValue = $this->persistenceManager->getIdentifierByObject($propertyValue) ?: $propertyValue;
         }
         $hashSourceParts[$property] = $propertyValue;
     }
     ksort($hashSourceParts);
     $hashSourceParts['__class_name__'] = $proxyClassName;
     $serializedSource = $this->useIgBinary === true ? igbinary_serialize($hashSourceParts) : serialize($hashSourceParts);
     $proxy = $joinPoint->getProxy();
     ObjectAccess::setProperty($proxy, 'Persistence_Object_Identifier', sha1($serializedSource), true);
 }