/**
  * @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 '';
 }
 /**
  * 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)]);
     }
 }
 /**
  * @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'));
 }
示例#4
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;
 }
示例#5
0
 /**
  * @return string
  * @throws \TYPO3\Flow\Security\Exception\InvalidArgumentForHashGenerationException
  */
 public function getJWTToken()
 {
     /** @var \TYPO3\Flow\Security\Account $account */
     $account = $this->securityContext->getAccount();
     $this->apiToken = $this->securityContext->getAuthenticationTokensOfType('RFY\\JWT\\Security\\Authentication\\Token\\JwtToken')[0];
     if ($account->getAuthenticationProviderName() !== $this->apiToken->getAuthenticationProviderName()) {
         // TODO: Currently you can get only 1 tokenAccount because of the duplication restraint based on accountIdentifier & AuthenticationProviderName
         $account = $this->accountRepository->findActiveByAccountIdentifierAndAuthenticationProviderName($account->getAccountIdentifier(), $this->apiToken->getAuthenticationProviderName());
         if ($account === NULL) {
             $account = $this->generateTokenAccount();
         }
     }
     $payload = array();
     $payload['identifier'] = $account->getAccountIdentifier();
     $payload['partyIdentifier'] = $this->persistenceManager->getIdentifierByObject($account->getParty());
     $payload['user_agent'] = $this->request->getHeader('User-Agent');
     $payload['ip_address'] = $this->request->getClientIpAddress();
     if ($account->getCreationDate() instanceof \DateTime) {
         $payload['creationDate'] = $account->getCreationDate()->getTimestamp();
     }
     if ($account->getExpirationDate() instanceof \DateTime) {
         $payload['expirationDate'] = $account->getExpirationDate()->getTimestamp();
     }
     // Add hmac
     $hmac = $this->hashService->generateHmac($this->signature);
     return JWT::encode($payload, $hmac);
 }
 /**
  * @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();
 }
示例#7
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;
     }
 }
示例#9
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;
 }
 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;
         }
     }
 }
 /**
  * @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;
     }
 }
 /**
  * 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;
 }
示例#14
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;
 }
 /**
  * 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;
 }
 /**
  * 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);
 }
 /**
  * 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);
 }
示例#18
0
 /**
  * @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;
 }
 /**
  * Fetches the identifier from the set content object. If that
  * is not using automatically introduced UUIDs by Flow it tries
  * to call persistAll() and fetch the identifier again. If it still
  * fails, an exception is thrown.
  *
  * @return void
  * @throws \TYPO3\Flow\Persistence\Exception\IllegalObjectTypeException
  */
 protected function initializeObject()
 {
     if ($this->contentObject !== null) {
         $this->targetType = get_class($this->contentObject);
         $this->targetId = $this->persistenceManager->getIdentifierByObject($this->contentObject);
         if ($this->targetId === null) {
             $this->persistenceManager->persistAll();
             $this->targetId = $this->persistenceManager->getIdentifierByObject($this->contentObject);
             if ($this->targetId === null) {
                 throw new \TYPO3\Flow\Persistence\Exception\IllegalObjectTypeException('You cannot add an object without an identifier to a ContentObjectProxy. Probably you didn\'t add a valid entity?', 1303859434);
             }
         }
     }
 }
 /**
  * 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);
 }
 /**
  * Traverses the given object structure in order to transform it into an
  * array structure.
  *
  * @param object $object Object to traverse
  * @param array $configuration Configuration for transforming the given object
  * @param boolean $onlyIdentifier
  * @param boolean $enableSideLoading
  * @return array Object structure as an array
  * @todo implement sideloading
  */
 protected function transformObject($object, array $configuration, $onlyIdentifier = TRUE, $enableSideLoading = TRUE)
 {
     if ($object instanceof \DateTime) {
         return $object->format('Y-m-d\\TH:i:s');
     } elseif ($onlyIdentifier === TRUE) {
         return $this->persistenceManager->getIdentifierByObject($object);
     } else {
         $transformedObject = array('id' => $this->persistenceManager->getIdentifierByObject($object));
         $objectName = $this->objectManager->getObjectNameByClassName($this->reflectionService->getClassNameByObject($object));
         foreach (ObjectAccess::getGettablePropertyNames($object) as $propertyName) {
             if ($this->isPropertyIgnored($objectName, $propertyName)) {
                 continue;
             }
             $propertyValue = ObjectAccess::getProperty($object, $propertyName);
             if (is_array($propertyValue) || $propertyValue instanceof \ArrayAccess) {
                 $propertyValue = $this->transformValue($propertyValue, array(), TRUE, $enableSideLoading);
                 if ($this->isRelation($objectName, $propertyName)) {
                     $this->addLink($transformedObject, $propertyName, $propertyValue);
                     if ($enableSideLoading === TRUE && !$this->reflectionService->isPropertyAnnotatedWith($objectName, $propertyName, 'TYPO3\\Flow\\Annotations\\Lazy')) {
                         $propertyTags = $this->reflectionService->getPropertyTagValues($objectName, $propertyName, 'var');
                         $propertyObjectType = TypeHandling::parseType($propertyTags[0]);
                         $this->sideLoad($propertyObjectType['elementType'], $propertyValue);
                     }
                     $propertyValue = NULL;
                 } elseif (empty($propertyValue)) {
                     $propertyValue = NULL;
                 }
             } elseif ($this->isSimpleValue($propertyValue)) {
                 if (is_object($propertyValue)) {
                     $propertyValue = $this->transformObject($propertyValue, $configuration, FALSE, $enableSideLoading);
                 }
             } elseif (is_object($propertyValue)) {
                 $propertyObjectName = $this->objectManager->getObjectNameByClassName($this->reflectionService->getClassNameByObject($propertyValue));
                 if (!$this->isObjectIgnored($propertyObjectName)) {
                     $propertyValue = $this->transformObject($propertyValue, $configuration, TRUE, $enableSideLoading);
                     if ($this->isRelation($objectName, $propertyName)) {
                         $this->addLink($transformedObject, $propertyName, $propertyValue);
                         if ($enableSideLoading === TRUE && !$this->reflectionService->isPropertyAnnotatedWith($objectName, $propertyName, 'TYPO3\\Flow\\Annotations\\Lazy')) {
                             $this->sideLoad($propertyObjectName, $propertyValue);
                         }
                         $propertyValue = NULL;
                     } elseif (empty($propertyValue)) {
                         $propertyValue = NULL;
                     }
                 }
             }
             if ($propertyValue !== NULL) {
                 if (is_object($propertyValue)) {
                     $propertyObjectName = $this->objectManager->getObjectNameByClassName($this->reflectionService->getClassNameByObject($propertyValue));
                     if (!$this->isObjectIgnored($propertyObjectName)) {
                         $transformedObject[$propertyName] = $propertyValue;
                     }
                 } else {
                     $transformedObject[$propertyName] = $propertyValue;
                 }
             }
         }
         return $transformedObject;
     }
 }
 /**
  * @param mixed $value
  * @return mixed object
  */
 protected function getQueryMatchValue($value)
 {
     if (is_object($value) && $this->reflectionService->isClassAnnotatedWith(get_class($value), 'TYPO3\\Flow\\Annotations\\Entity')) {
         return $this->persistenceManager->getIdentifierByObject($value);
     }
     return $value;
 }
示例#23
0
 /**
  * @return string
  */
 public function getLocationId()
 {
     if ($this->location == null) {
         return null;
     }
     return $this->persistenceManager->getIdentifierByObject($this->location);
 }
 /**
  * Serialize an array
  *
  * @param array $array
  * @param int $depth
  *
  * @return FALSE|string if error appends
  */
 protected function serializeArray(array &$array, $depth = 0)
 {
     if ($depth < 50) {
         foreach ($array as &$val) {
             if (is_scalar($val)) {
                 continue;
             } elseif (is_array($val)) {
                 $serialized = $this->serializeArray($val, $depth + 1);
                 if ($serialized === false) {
                     return false;
                 } else {
                     $val = 'ARR->|' . $serialized;
                 }
             } elseif (is_object($val)) {
                 if ($val instanceof \DateTime) {
                     $val = 'DAT->|' . serialize($val);
                 } else {
                     $className = get_class($val);
                     if ($val instanceof TranslatableInterface) {
                         $ref = $this->persistenceManager->getIdentifierByObject($val);
                         if ($ref !== null && strlen($ref) > 0) {
                             $val = 'OBJ->|' . $className . '|' . $ref;
                         } else {
                             return false;
                         }
                     }
                 }
             } else {
                 return false;
             }
         }
         return serialize($array);
     }
     return false;
 }
 /**
  * Check if $value is valid. If it is not valid, needs to add an errorw
  * to Result.
  *
  * @param AssetInterface $value
  * @return void
  */
 protected function isValid($value)
 {
     $fileName = $value->getTitle() ?: $value->getResource()->getFilename();
     /** @var Query $query */
     $query = $this->entityManager->createQuery('SELECT a FROM TYPO3\\Media\\Domain\\Model\\Asset a JOIN a.resource r WHERE (a.title = :fileName OR r.filename = :fileName) AND a.Persistence_Object_Identifier != :assetIdentifier');
     $query->setParameter('fileName', $fileName);
     $query->setParameter('assetIdentifier', $this->persistenceManager->getIdentifierByObject($value));
     $result = $query->getArrayResult();
     // We need to exclude ImageVariant objects, but can not do that in the DQL query
     $result = array_filter($result, function ($value) {
         return $value['dtype'] !== 'typo3_media_imagevariant';
     });
     if (count($result) > 0) {
         $this->addError($this->translator->translateById('assetWithTitleAlreadyExists', [$fileName], null, $this->_localizationService->getConfiguration()->getCurrentLocale(), 'Main', 'Flownative.Neos.UniqueFilenames'), 1462705529);
     }
 }
 /**
  * Removes unused ImageVariants after a Node property changes to a different ImageVariant.
  * This is triggered via the nodePropertyChanged event.
  *
  * Note: This method it triggered by the "nodePropertyChanged" signal, @see \TYPO3\TYPO3CR\Domain\Model\Node::emitNodePropertyChanged()
  *
  * @param NodeInterface $node the affected node
  * @param string $propertyName name of the property that has been changed/added
  * @param mixed $oldValue the property value before it was changed or NULL if the property is new
  * @param mixed $value the new property value
  * @return void
  */
 public function removeUnusedImageVariant(NodeInterface $node, $propertyName, $oldValue, $value)
 {
     if ($oldValue === $value || !$oldValue instanceof ImageVariant) {
         return;
     }
     $identifier = $this->persistenceManager->getIdentifierByObject($oldValue);
     $results = $this->nodeDataRepository->findNodesByRelatedEntities(array(ImageVariant::class => [$identifier]));
     // This case shouldn't happen as the query will usually find at least the node that triggered this call, still if there is no relation we can remove the ImageVariant.
     if ($results === []) {
         $this->assetRepository->remove($oldValue);
         return;
     }
     // If the result contains exactly the node that got a new ImageVariant assigned then we are safe to remove the asset here.
     if ($results === [$node->getNodeData()]) {
         $this->assetRepository->remove($oldValue);
     }
 }
示例#27
0
 /**
  * @param string $language
  * @return string
  */
 public function getCacheFileName($language = NULL)
 {
     $fileName = $this->receiverGroupCache . '/' . $this->persistenceManager->getIdentifierByObject($this);
     if ($language) {
         $fileName .= '_' . $language;
     }
     return $fileName;
 }
 /**
  * Convert an object from \TYPO3\Media\Domain\Model\ImageInterface to a json representation
  *
  * @param ImageInterface $source
  * @param string $targetType must be 'string'
  * @param array $convertedChildProperties
  * @param PropertyMappingConfigurationInterface $configuration
  * @return string|Error The converted Image, a Validation Error or NULL
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), PropertyMappingConfigurationInterface $configuration = null)
 {
     $data = array('__identity' => $this->persistenceManager->getIdentifierByObject($source), '__type' => TypeHandling::getTypeForValue($source));
     if ($source instanceof ImageVariant) {
         $data['originalAsset'] = ['__identity' => $this->persistenceManager->getIdentifierByObject($source->getOriginalAsset())];
         $adjustments = array();
         foreach ($source->getAdjustments() as $adjustment) {
             $index = TypeHandling::getTypeForValue($adjustment);
             $adjustments[$index] = array();
             foreach (ObjectAccess::getGettableProperties($adjustment) as $propertyName => $propertyValue) {
                 $adjustments[$index][$propertyName] = $propertyValue;
             }
         }
         $data['adjustments'] = $adjustments;
     }
     return $data;
 }
示例#29
0
 /**
  * $resultsData should be array with following keys and values:
  * 't' in seconds (currently not used)
  * 's' integer score
  *
  *
  * @param \_OurBrand_\Quiz\Domain\Model\StudentQuizSession $studentQuizSession
  * @param \_OurBrand_\Quiz\Domain\Model\Exercise $exercise
  * @param array $resultsData
  */
 public function addResultToQuizSessionResultsStatistics($studentQuizSession, $exercise, $resultsData)
 {
     $studentQuizSessionIdentifier = $this->persistenceManager->getIdentifierByObject($studentQuizSession);
     $exerciseIdentifier = $this->persistenceManager->getIdentifierByObject($exercise);
     $quizSession = $studentQuizSession->getQuizSession();
     $quizSession->addResultToResultsStatistics($studentQuizSessionIdentifier, $exerciseIdentifier, $resultsData);
     $this->quizSessionRepository->update($quizSession);
     $this->writeLiveStatisticsFile($quizSession);
 }
 /**
  * @param Asset $asset
  * @return array
  */
 protected function getAssetProperties(Asset $asset)
 {
     $assetProperties = ['assetUuid' => $this->persistenceManager->getIdentifierByObject($asset), 'filename' => $asset->getResource()->getFilename()];
     $thumbnail = $this->thumbnailService->getThumbnail($asset, $this->thumbnailService->getThumbnailConfigurationForPreset('TYPO3.Neos:Thumbnail'));
     if ($thumbnail !== null) {
         $assetProperties['previewImageResourceUri'] = $this->thumbnailService->getUriForThumbnail($thumbnail);
         $assetProperties['previewSize'] = ['w' => $thumbnail->getWidth(), 'h' => $thumbnail->getHeight()];
     }
     return $assetProperties;
 }