Example #1
0
 /**
  * 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\FLOW3\Persistence\Generic\Exception\InvalidObjectDataException $e) {
                 // when security query rewriting holds back an object here, we skip it...
             }
         }
         $this->objectIdentifiers = NULL;
     }
 }
Example #2
0
 /**
  * Helper function which creates or fetches a resource pointer object for a given hash.
  *
  * If a ResourcePointer with the given hash exists, this one is used. Else, a new one
  * is created. This is a workaround for missing ValueObject support in Doctrine.
  *
  * @param string $hash
  * @return \TYPO3\FLOW3\Resource\ResourcePointer
  */
 public function getResourcePointerForHash($hash)
 {
     $resourcePointer = $this->persistenceManager->getObjectByIdentifier($hash, 'TYPO3\\FLOW3\\Resource\\ResourcePointer');
     if (!$resourcePointer) {
         $resourcePointer = new \TYPO3\FLOW3\Resource\ResourcePointer($hash);
         $this->persistenceManager->add($resourcePointer);
     }
     return $resourcePointer;
 }
 public function deleteObject($being, $id)
 {
     $object = $this->persistenceManager->getObjectByIdentifier($id, $being);
     if ($object == null) {
         return;
     }
     $repositoryObject = $this->objectManager->get($this->getRepositoryForModel($being));
     $repositoryObject->remove($object);
     $this->persistenceManager->persistAll();
 }
 /**
  * Fetch an object from persistence layer.
  *
  * @param mixed $identity
  * @param string $targetType
  * @return object
  * @throws \TYPO3\FLOW3\Property\Exception\TargetNotFoundException
  * @throws \TYPO3\FLOW3\Property\Exception\InvalidSourceException
  */
 protected function fetchObjectFromPersistence($identity, $targetType)
 {
     if (is_string($identity)) {
         $object = $this->persistenceManager->getObjectByIdentifier($identity, $targetType);
     } elseif (is_array($identity)) {
         $object = $this->findObjectByIdentityProperties($identity, $targetType);
     } else {
         throw new \TYPO3\FLOW3\Property\Exception\InvalidSourceException('The identity property "' . $identity . '" is neither a string nor an array.', 1297931020);
     }
     if ($object === NULL) {
         throw new \TYPO3\FLOW3\Property\Exception\TargetNotFoundException('Object with identity "' . print_r($identity, TRUE) . '" not found.', 1297933823);
     }
     return $object;
 }
Example #5
0
 /**
  * Converts the given string or array to a ResourcePointer object.
  *
  * If the input format is an array, this method assumes the resource to be a
  * fresh file upload and imports the temporary upload file through the
  * resource manager.
  *
  * @param array $source The upload info (expected keys: error, name, tmp_name)
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param \TYPO3\FLOW3\Property\PropertyMappingConfigurationInterface $configuration
  * @return \TYPO3\FLOW3\Resource\Resource|TYPO3\FLOW3\Error\Error if the input format is not supported or could not be converted for other reasons
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), \TYPO3\FLOW3\Property\PropertyMappingConfigurationInterface $configuration = NULL)
 {
     if (!isset($source['error']) || $source['error'] === \UPLOAD_ERR_NO_FILE) {
         if (isset($source['submittedFile']) && isset($source['submittedFile']['filename']) && isset($source['submittedFile']['resourcePointer'])) {
             $resourcePointer = $this->persistenceManager->getObjectByIdentifier($source['submittedFile']['resourcePointer'], 'TYPO3\\FLOW3\\Resource\\ResourcePointer');
             if ($resourcePointer) {
                 $resource = new Resource();
                 $resource->setFilename($source['submittedFile']['filename']);
                 $resource->setResourcePointer($resourcePointer);
                 return $resource;
             }
         }
         return NULL;
     }
     if ($source['error'] !== \UPLOAD_ERR_OK) {
         switch ($source['error']) {
             case \UPLOAD_ERR_INI_SIZE:
             case \UPLOAD_ERR_FORM_SIZE:
             case \UPLOAD_ERR_PARTIAL:
                 return new \TYPO3\FLOW3\Error\Error(\TYPO3\FLOW3\Utility\Files::getUploadErrorMessage($source['error']), 1264440823);
             default:
                 $this->systemLogger->log(sprintf('A server error occurred while converting an uploaded resource: "%s"', \TYPO3\FLOW3\Utility\Files::getUploadErrorMessage($source['error'])), LOG_ERR);
                 return new \TYPO3\FLOW3\Error\Error('An error occurred while uploading. Please try again or contact the administrator if the problem remains', 1340193849);
         }
     }
     if (isset($this->convertedResources[$source['tmp_name']])) {
         return $this->convertedResources[$source['tmp_name']];
     }
     $resource = $this->resourceManager->importUploadedResource($source);
     if ($resource === FALSE) {
         return new \TYPO3\FLOW3\Error\Error('The resource manager could not create a Resource instance.', 1264517906);
     } else {
         $this->convertedResources[$source['tmp_name']] = $resource;
         return $resource;
     }
 }
Example #6
0
 /**
  * Reconstitutes a persistence object (entity or valueobject) identified by the given UUID.
  *
  * @param string $className The class name of the object to retrieve
  * @param string $uuid The UUID of the object
  * @return object The reconstituted persistence object, NULL if none was found
  */
 protected function reconstitutePersistenceObject($className, $uuid)
 {
     return $this->persistenceManager->getObjectByIdentifier($uuid, $className);
 }
Example #7
0
 /**
  * Finds an object matching the given identifier.
  *
  * @param mixed $identifier The identifier of the object to find
  * @return object The matching object if found, otherwise NULL
  * @api
  */
 public function findByIdentifier($identifier)
 {
     return $this->persistenceManager->getObjectByIdentifier($identifier, $this->entityClassName);
 }