本文整理汇总了PHP中TYPO3\Flow\Persistence\PersistenceManagerInterface类的典型用法代码示例。如果您正苦于以下问题:PHP PersistenceManagerInterface类的具体用法?PHP PersistenceManagerInterface怎么用?PHP PersistenceManagerInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PersistenceManagerInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* 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);
}
示例2: createUserAndAccount
/**
* 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);
}
示例3: transformByAnnotation
/**
* @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 '';
}
示例4: findByAnimal
/**
* @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();
}
示例5: executeInternal
/**
* 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();
}
示例6: execute
/**
* 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)]);
}
}
示例7: renderWithoutValueInvokesRenderChildren
/**
* @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());
}
示例8: badgeAssertionToArray
/**
* @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'));
}
示例9: generateUuid
/**
* 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);
}
示例10: getOptions
/**
*/
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;
}
示例11: getAssignedPartyOfAccount
/**
* 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);
}
示例12: identifyCacheTagForObject
/**
* 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;
}
}
示例13: getData
/**
* @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;
}
示例14: getData
/**
* 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;
}
示例15: getNodePropertyWithBadgeClass
/**
* @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;
}
}
开发者ID:christophlehmann,项目名称:Networkteam.OpenBadges,代码行数:13,代码来源:BadgeClassContentElementWrappingAspect.php