/**
  * Render the URI to the resource. The filename is used from child content.
  *
  * @param string $path The location of the resource, can be either a path relative to the Public resource directory of the package or a resource://... URI
  * @param string $package Target package key. If not set, the current package key will be used
  * @param PersistentResource $resource If specified, this resource object is used instead of the path and package information
  * @param boolean $localize Whether resource localization should be attempted or not
  * @return string The absolute URI to the resource
  * @throws InvalidVariableException
  * @api
  */
 public function render($path = null, $package = null, PersistentResource $resource = null, $localize = true)
 {
     if ($resource !== null) {
         $uri = $this->resourceManager->getPublicPersistentResourceUri($resource);
         if ($uri === false) {
             $uri = '404-Resource-Not-Found';
         }
     } else {
         if ($path === null) {
             throw new InvalidVariableException('The ResourceViewHelper did neither contain a valuable "resource" nor "path" argument.', 1353512742);
         }
         if ($package === null) {
             $package = $this->controllerContext->getRequest()->getControllerPackageKey();
         }
         if (strpos($path, 'resource://') === 0) {
             try {
                 list($package, $path) = $this->resourceManager->getPackageAndPathByPublicPath($path);
             } catch (Exception $exception) {
                 throw new InvalidVariableException(sprintf('The specified path "%s" does not point to a public resource.', $path), 1386458851);
             }
         }
         if ($localize === true) {
             $resourcePath = 'resource://' . $package . '/Public/' . $path;
             $localizedResourcePathData = $this->i18nService->getLocalizedFilename($resourcePath);
             $matches = array();
             if (preg_match('#resource://([^/]+)/Public/(.*)#', current($localizedResourcePathData), $matches) === 1) {
                 $package = $matches[1];
                 $path = $matches[2];
             }
         }
         $uri = $this->resourceManager->getPublicPackageResourceUri($package, $path);
     }
     return $uri;
 }
 /**
  * Upload a new image and return an image variant, a thumbnail and additional information like it would be
  * returned for the Neos backend.
  *
  * @param Image $image
  * @return string
  */
 public function uploadAction(Image $image)
 {
     $this->assetRepository->add($image);
     $imageVariant = new ImageVariant($image);
     $this->assetRepository->add($imageVariant);
     $thumbnail = $image->getThumbnail(100, 100);
     $this->response->setHeader('Content-Type', 'application/json');
     return json_encode(array('__identity' => $this->persistenceManager->getIdentifierByObject($image), '__resourceUri' => $this->resourceManager->getPublicPersistentResourceUri($image->getResource()), 'width' => $image->getWidth(), 'height' => $image->getHeight(), 'thumbnail' => array('__resourceUri' => $this->resourceManager->getPublicPersistentResourceUri($thumbnail->getResource()), 'width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()), 'variants' => array(array('__identity' => $this->persistenceManager->getIdentifierByObject($imageVariant), '__resourceUri' => $this->resourceManager->getPublicPersistentResourceUri($imageVariant->getResource()), 'width' => $imageVariant->getWidth(), 'height' => $imageVariant->getHeight()))));
 }
 /**
  * Get the header include code for including Twitter Bootstrap on a page. If needed
  * the jQuery library can be included, too.
  *
  * Example usage:
  * {namespace bootstrap=Neos\Twitter\Bootstrap\ViewHelpers}
  * <bootstrap:include />
  *
  * @param string $version The version to use, for example "2.2", "3.0" or also "2" or "3" meaning "2.x" and "3.x" respectively
  * @param boolean $minified If the minified version of Twitter Bootstrap should be used
  * @param boolean $includeJQuery If enabled, also includes jQuery
  * @param string $jQueryVersion The jQuery version to include
  * @return string
  */
 public function render($version, $minified = TRUE, $includeJQuery = FALSE, $jQueryVersion = '1.10.1')
 {
     $content = sprintf('<link rel="stylesheet" href="%s" />' . PHP_EOL, $this->resourceManager->getPublicPackageResourceUri('Neos\\Twitter.Bootstrap', $version . '/css/bootstrap' . ($minified === TRUE ? '.min' : '') . '.css'));
     if ($includeJQuery === TRUE) {
         $content .= sprintf('<script src="%s"></script>' . PHP_EOL, $this->resourceManager->getPublicPackageResourceUri('Neos\\Twitter.Bootstrap', 'Libraries/jQuery/jquery-' . $jQueryVersion . ($minified === TRUE ? '.min' : '') . '.js'));
     }
     $content .= sprintf('<script src="%s"></script>' . PHP_EOL, $this->resourceManager->getPublicPackageResourceUri('Neos\\Twitter.Bootstrap', $version . '/js/bootstrap' . ($minified === TRUE ? '.min' : '') . '.js'));
     return $content;
 }
 /**
  * @test
  */
 public function openResolvesAnUpperCaseSha1HashUsingTheResourceManager()
 {
     $sha1Hash = '68AC906495480A3404BEEE4874ED853A037A7A8F';
     $tempFile = tmpfile();
     $mockResource = $this->getMockBuilder(PersistentResource::class)->disableOriginalConstructor()->getMock();
     $this->mockResourceManager->expects($this->once())->method('getResourceBySha1')->with($sha1Hash)->will($this->returnValue($mockResource));
     $this->mockResourceManager->expects($this->once())->method('getStreamByResource')->with($mockResource)->will($this->returnValue($tempFile));
     $openedPathAndFilename = '';
     $this->assertTrue($this->resourceStreamWrapper->open('resource://' . $sha1Hash, 'r', 0, $openedPathAndFilename));
     $this->assertAttributeSame($tempFile, 'handle', $this->resourceStreamWrapper);
 }
 /**
  * Renders an <img> HTML tag for a filetype icon for a given Neos.Media's asset instance
  *
  * @param AssetInterface $file
  * @param integer|null $width
  * @param integer|null $height
  * @return string
  */
 public function render(AssetInterface $file, $width = null, $height = null)
 {
     $icon = FileTypeIconService::getIcon($file, $width, $height);
     $this->tag->addAttribute('src', $this->resourceManager->getPublicPackageResourceUriByPath($icon['src']));
     $this->tag->addAttribute('alt', $icon['alt']);
     if ($width !== null) {
         $this->tag->addAttribute('width', $width);
     }
     if ($height !== null) {
         $this->tag->addAttribute('height', $height);
     }
     return $this->tag->render();
 }
Example #6
0
 /**
  * @param string $presetName name of the preset to use
  * @return string the rendered form head
  */
 public function render($presetName = 'default')
 {
     $content = '';
     $presetConfiguration = $this->formBuilderFactory->getPresetConfiguration($presetName);
     $stylesheets = isset($presetConfiguration['stylesheets']) ? $presetConfiguration['stylesheets'] : [];
     foreach ($stylesheets as $stylesheet) {
         $content .= sprintf('<link href="%s" rel="stylesheet">', $this->resourceManager->getPublicPackageResourceUriByPath($stylesheet['source']));
     }
     $javaScripts = isset($presetConfiguration['javaScripts']) ? $presetConfiguration['javaScripts'] : [];
     foreach ($javaScripts as $javaScript) {
         $content .= sprintf('<script src="%s"></script>', $this->resourceManager->getPublicPackageResourceUriByPath($javaScript['source']));
     }
     return $content;
 }
 /**
  * @return Asset
  * @throws \Neos\Flow\ResourceManagement\Exception
  */
 protected function buildAssetObject()
 {
     $resource = $this->resourceManager->importResourceFromContent('Test', 'test.txt');
     $asset = new Asset($resource);
     $this->assetRepository->add($asset);
     return $asset;
 }
 /**
  * @test
  */
 public function convertFromReturnsAnErrorIfTheUploadedFileCantBeImported()
 {
     $this->inject($this->resourceTypeConverter, 'systemLogger', $this->createMock(SystemLoggerInterface::class));
     $source = ['tmp_name' => 'SomeFilename', 'error' => \UPLOAD_ERR_OK];
     $this->mockResourceManager->expects($this->once())->method('importUploadedResource')->with($source)->will($this->throwException(new Exception()));
     $actualResult = $this->resourceTypeConverter->convertFrom($source, PersistentResource::class);
     $this->assertInstanceOf(FlowError\Error::class, $actualResult);
 }
 /**
  * Resolves a given asset:// URI to a "normal" HTTP(S) URI for the addressed asset's resource.
  *
  * @param string|Uri $uri
  * @return string
  */
 public function resolveAssetUri($uri)
 {
     $targetObject = $this->convertUriToObject($uri);
     if ($targetObject === null) {
         $this->systemLogger->log(sprintf('Could not resolve "%s" to an existing asset; The asset was probably deleted.', $uri));
         return null;
     }
     return $this->resourceManager->getPublicPersistentResourceUri($targetObject->getResource());
 }
 /**
  * @param Image $image
  * @return array
  */
 protected function getImagePreviewData(Image $image)
 {
     $imageProperties = ['originalImageResourceUri' => $this->resourceManager->getPublicPersistentResourceUri($image->getResource()), 'originalDimensions' => ['width' => $image->getWidth(), 'height' => $image->getHeight(), 'aspectRatio' => $image->getAspectRatio()], 'mediaType' => $image->getResource()->getMediaType()];
     $thumbnail = $this->thumbnailService->getThumbnail($image, $this->thumbnailService->getThumbnailConfigurationForPreset('Neos.Media.Browser:Preview'));
     if ($thumbnail !== null) {
         $imageProperties['previewImageResourceUri'] = $this->thumbnailService->getUriForThumbnail($thumbnail);
         $imageProperties['previewDimensions'] = ['width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()];
     }
     return $imageProperties;
 }
 /**
  * @param ImageInterface $thumbnail
  * @return string
  * @throws ThumbnailServiceException
  */
 public function getUriForThumbnail(ImageInterface $thumbnail)
 {
     $resource = $thumbnail->getResource();
     if ($resource) {
         return $this->resourceManager->getPublicPersistentResourceUri($resource);
     }
     $staticResource = $thumbnail->getStaticResource();
     if ($staticResource === null) {
         throw new ThumbnailServiceException(sprintf('Could not generate URI for static thumbnail "%s".', $this->persistenceManager->getIdentifierByObject($thumbnail)), 1450178437);
     }
     return $this->resourceManager->getPublicPackageResourceUriByPath($staticResource);
 }
 /**
  * @param string $resourcePath
  * @return string
  */
 protected function getStaticResourceWebBaseUri($resourcePath)
 {
     $localizedResourcePathData = $this->i18nService->getLocalizedFilename($resourcePath);
     $matches = array();
     try {
         if (preg_match('#resource://([^/]+)/Public/(.*)#', current($localizedResourcePathData), $matches) === 1) {
             $packageKey = $matches[1];
             $path = $matches[2];
             return $this->resourceManager->getPublicPackageResourceUri($packageKey, $path);
         }
     } catch (\Exception $exception) {
         $this->systemLogger->logException($exception);
     }
     return '';
 }
 /**
  * Returns the absolute URL of a resource
  *
  * @return string
  * @throws TypoScriptException
  */
 public function evaluate()
 {
     $resource = $this->getResource();
     if ($resource !== null) {
         $uri = false;
         if ($resource instanceof PersistentResource) {
             $uri = $this->resourceManager->getPublicPersistentResourceUri($resource);
         }
         if ($uri === false) {
             throw new TypoScriptException('The specified resource is invalid', 1386458728);
         }
         return $uri;
     }
     $path = $this->getPath();
     if ($path === null) {
         throw new TypoScriptException('Neither "resource" nor "path" were specified', 1386458763);
     }
     if (strpos($path, 'resource://') === 0) {
         $matches = array();
         if (preg_match('#^resource://([^/]+)/Public/(.*)#', $path, $matches) !== 1) {
             throw new TypoScriptException(sprintf('The specified path "%s" does not point to a public resource.', $path), 1386458851);
         }
         $package = $matches[1];
         $path = $matches[2];
     } else {
         $package = $this->getPackage();
         if ($package === null) {
             $controllerContext = $this->tsRuntime->getControllerContext();
             /** @var $actionRequest ActionRequest */
             $actionRequest = $controllerContext->getRequest();
             $package = $actionRequest->getControllerPackageKey();
         }
     }
     $localize = $this->isLocalize();
     if ($localize === true) {
         $resourcePath = 'resource://' . $package . '/Public/' . $path;
         $localizedResourcePathData = $this->i18nService->getLocalizedFilename($resourcePath);
         $matches = array();
         if (preg_match('#resource://([^/]+)/Public/(.*)#', current($localizedResourcePathData), $matches) === 1) {
             $package = $matches[1];
             $path = $matches[2];
         }
     }
     return $this->resourceManager->getPublicPackageResourceUri($package, $path);
 }
 /**
  * Replace resource on an asset. Takes variants and redirect handling into account.
  *
  * @param AssetInterface $asset
  * @param PersistentResource $resource
  * @param array $options
  * @return void
  */
 public function replaceAssetResource(AssetInterface $asset, PersistentResource $resource, array $options = [])
 {
     $originalAssetResource = $asset->getResource();
     $asset->setResource($resource);
     if (isset($options['keepOriginalFilename']) && (bool) $options['keepOriginalFilename'] === true) {
         $asset->getResource()->setFilename($originalAssetResource->getFilename());
     }
     $uriMapping = [];
     $redirectHandlerEnabled = isset($options['generateRedirects']) && (bool) $options['generateRedirects'] === true && $this->packageManager->isPackageAvailable('Neos.RedirectHandler');
     if ($redirectHandlerEnabled) {
         $uriMapping[$this->resourceManager->getPublicPersistentResourceUri($originalAssetResource)] = $this->resourceManager->getPublicPersistentResourceUri($asset->getResource());
     }
     if (method_exists($asset, 'getVariants')) {
         $variants = $asset->getVariants();
         /** @var AssetVariantInterface $variant */
         foreach ($variants as $variant) {
             $originalVariantResource = $variant->getResource();
             $variant->refresh();
             if (method_exists($variant, 'getAdjustments')) {
                 foreach ($variant->getAdjustments() as $adjustment) {
                     if (method_exists($adjustment, 'refit')) {
                         $adjustment->refit($asset);
                     }
                 }
             }
             if ($redirectHandlerEnabled) {
                 $uriMapping[$this->resourceManager->getPublicPersistentResourceUri($originalVariantResource)] = $this->resourceManager->getPublicPersistentResourceUri($variant->getResource());
             }
             $this->getRepository($variant)->update($variant);
         }
     }
     if ($redirectHandlerEnabled) {
         /** @var \Neos\RedirectHandler\Storage\RedirectStorageInterface $redirectStorage */
         $redirectStorage = $this->objectManager->get(\Neos\RedirectHandler\Storage\RedirectStorageInterface::class);
         foreach ($uriMapping as $originalUri => $newUri) {
             $existingRedirect = $redirectStorage->getOneBySourceUriPathAndHost($originalUri);
             if ($existingRedirect === null) {
                 $redirectStorage->addRedirect($originalUri, $newUri, 301);
             }
         }
     }
     $this->getRepository($asset)->update($asset);
     $this->emitAssetResourceReplaced($asset);
 }
 /**
  * Resolve help message thumbnail url
  *
  * @param string $nodeTypeName
  * @param string $configurationThumbnail
  * @return string $thumbnailUrl
  */
 protected function resolveHelpMessageThumbnail($nodeTypeName, $configurationThumbnail)
 {
     if ($nodeTypeName !== null) {
         $thumbnailUrl = '';
         if (isset($configurationThumbnail)) {
             $thumbnailUrl = $configurationThumbnail;
             if (strpos($thumbnailUrl, 'resource://') === 0) {
                 $thumbnailUrl = $this->resourceManager->getPublicPackageResourceUriByPath($thumbnailUrl);
             }
         } else {
             # look in well know location
             $splitPrefix = $this->splitIdentifier($nodeTypeName);
             $relativePathAndFilename = 'NodeTypes/Thumbnails/' . $splitPrefix['id'] . '.png';
             $resourcePath = 'resource://' . $splitPrefix['packageKey'] . '/Public/' . $relativePathAndFilename;
             if (file_exists($resourcePath)) {
                 $thumbnailUrl = $this->resourceManager->getPublicPackageResourceUriByPath($resourcePath);
             }
         }
         return $thumbnailUrl;
     }
 }
 /**
  * Evaluates the absolute path and filename of the resource file specified
  * by the given path.
  *
  * @param string $requestedPath
  * @param boolean $checkForExistence Whether a (non-hash) path should be checked for existence before being returned
  * @return mixed The full path and filename or FALSE if the file doesn't exist
  * @throws \InvalidArgumentException|ResourceException
  */
 protected function evaluateResourcePath($requestedPath, $checkForExistence = true)
 {
     if (substr($requestedPath, 0, strlen(self::SCHEME)) !== self::SCHEME) {
         throw new \InvalidArgumentException('The ' . __CLASS__ . ' only supports the \'' . self::SCHEME . '\' scheme.', 1256052544);
     }
     $uriParts = Functions::parse_url($requestedPath);
     if (!is_array($uriParts) || !isset($uriParts['host'])) {
         return false;
     }
     if (preg_match('/^[0-9a-f]{40}$/i', $uriParts['host']) === 1) {
         $resource = $this->resourceManager->getResourceBySha1($uriParts['host']);
         return $this->resourceManager->getStreamByResource($resource);
     }
     if (!$this->packageManager->isPackageAvailable($uriParts['host'])) {
         throw new ResourceException(sprintf('Invalid resource URI "%s": Package "%s" is not available.', $requestedPath, $uriParts['host']), 1309269952);
     }
     $package = $this->packageManager->getPackage($uriParts['host']);
     $resourceUri = Files::concatenatePaths([$package->getResourcesPath(), $uriParts['path']]);
     if ($checkForExistence === false || file_exists($resourceUri)) {
         return $resourceUri;
     }
     return false;
 }
Example #17
0
 /**
  * Copy resources
  *
  * This command copies all resources from one collection to another storage identified by name.
  * The target storage must be empty and must not be identical to the current storage of the collection.
  *
  * This command merely copies the binary data from one storage to another, it does not change the related
  * PersistentResource objects in the database in any way. Since the PersistentResource objects in the database refer to a
  * collection name, you can use this command for migrating from one storage to another my configuring
  * the new storage with the name of the old storage collection after the resources have been copied.
  *
  * @param string $sourceCollection The name of the collection you want to copy the assets from
  * @param string $targetCollection The name of the collection you want to copy the assets to
  * @param boolean $publish If enabled, the target collection will be published after the resources have been copied
  * @return void
  */
 public function copyCommand($sourceCollection, $targetCollection, $publish = false)
 {
     $sourceCollectionName = $sourceCollection;
     $sourceCollection = $this->resourceManager->getCollection($sourceCollectionName);
     if ($sourceCollection === null) {
         $this->outputLine('The source collection "%s" does not exist.', array($sourceCollectionName));
         $this->quit(1);
     }
     $targetCollectionName = $targetCollection;
     $targetCollection = $this->resourceManager->getCollection($targetCollection);
     if ($targetCollection === null) {
         $this->outputLine('The target collection "%s" does not exist.', array($targetCollectionName));
         $this->quit(1);
     }
     if (!empty($targetCollection->getObjects())) {
         $this->outputLine('The target collection "%s" is not empty.', array($targetCollectionName));
         $this->quit(1);
     }
     $sourceObjects = $sourceCollection->getObjects();
     $this->outputLine('Copying resource objects from collection "%s" to collection "%s" ...', [$sourceCollectionName, $targetCollectionName]);
     $this->outputLine();
     $this->output->progressStart(count($sourceObjects));
     foreach ($sourceCollection->getObjects() as $resource) {
         /** @var \Neos\Flow\ResourceManagement\Storage\StorageObject $resource */
         $this->output->progressAdvance();
         $targetCollection->importResource($resource->getStream());
     }
     $this->output->progressFinish();
     $this->outputLine();
     if ($publish) {
         $this->outputLine('Publishing copied resources to the target "%s" ...', [$targetCollection->getTarget()->getName()]);
         $targetCollection->getTarget()->publishCollection($sourceCollection);
     }
     $this->outputLine('Done.');
     $this->outputLine('Hint: If you want to use the target collection as a replacement for your current one, you can now modify your settings accordingly.');
 }
 /**
  * Convert an object from $source to an \Neos\Media\Domain\Model\AssetInterface implementation
  *
  * @param mixed $source
  * @param string $targetType must implement 'Neos\Media\Domain\Model\AssetInterface'
  * @param array $convertedChildProperties
  * @param PropertyMappingConfigurationInterface $configuration
  * @return Error|AssetInterface The converted Asset, a Validation Error or NULL
  * @throws InvalidTargetException
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), PropertyMappingConfigurationInterface $configuration = null)
 {
     $object = null;
     if (is_string($source) && $source !== '') {
         $source = array('__identity' => $source);
     }
     if (isset($convertedChildProperties['resource']) && $convertedChildProperties['resource'] instanceof PersistentResource) {
         $resource = $convertedChildProperties['resource'];
         if (isset($this->resourcesAlreadyConvertedToAssets[$resource->getSha1()])) {
             $object = $this->resourcesAlreadyConvertedToAssets[$resource->getSha1()];
         }
         // This is pretty late to override the targetType, but usually you want to determine the model type from the resource when a new resource was uploaded...
         $targetType = $this->applyModelMappingStrategy($targetType, $resource, $source);
     }
     if ($object === null) {
         if ($configuration !== null && $configuration->getConfigurationValue(self::class, self::CONFIGURATION_ONE_PER_RESOURCE) === true && isset($convertedChildProperties['resource'])) {
             $resource = $convertedChildProperties['resource'];
             $possibleAsset = $this->assetRepository->findOneByResourceSha1($resource->getSha1());
             if ($possibleAsset !== null) {
                 $this->resourceManager->deleteResource($resource);
                 return $possibleAsset;
             }
         }
         $object = parent::convertFrom($source, $targetType, $convertedChildProperties, $configuration);
     }
     if ($object instanceof AssetInterface) {
         $object = $this->applyTypeSpecificHandling($object, $source, $convertedChildProperties, $configuration);
         if ($object !== null) {
             $this->resourcesAlreadyConvertedToAssets[$object->getResource()->getSha1()] = $object;
             if (isset($resource) && $resource !== $object->getResource()) {
                 $this->resourceManager->deleteResource($resource);
             }
         }
     }
     return $object;
 }
 /**
  * @test
  */
 public function fileGetContentsReturnFixtureContentForResourceUri()
 {
     $resource = $this->resourceManager->importResourceFromContent('fixture', 'fixture.txt');
     $this->assertEquals('fixture', file_get_contents('resource://' . $resource->getSha1()));
 }
 /**
  * @param PersistentResource $originalResource
  * @param array $adjustments
  * @return array resource, width, height as keys
  * @throws ImageFileException
  * @throws InvalidConfigurationException
  * @throws Exception
  */
 public function processImage(PersistentResource $originalResource, array $adjustments)
 {
     $additionalOptions = array();
     $adjustmentsApplied = false;
     // TODO: Special handling for SVG should be refactored at a later point.
     if ($originalResource->getMediaType() === 'image/svg+xml') {
         $originalResourceStream = $originalResource->getStream();
         $resource = $this->resourceManager->importResource($originalResourceStream, $originalResource->getCollectionName());
         fclose($originalResourceStream);
         $resource->setFilename($originalResource->getFilename());
         return ['width' => null, 'height' => null, 'resource' => $resource];
     }
     $resourceUri = $originalResource->createTemporaryLocalCopy();
     $resultingFileExtension = $originalResource->getFileExtension();
     $transformedImageTemporaryPathAndFilename = $this->environment->getPathToTemporaryDirectory() . uniqid('ProcessedImage-') . '.' . $resultingFileExtension;
     if (!file_exists($resourceUri)) {
         throw new ImageFileException(sprintf('An error occurred while transforming an image: the resource data of the original image does not exist (%s, %s).', $originalResource->getSha1(), $resourceUri), 1374848224);
     }
     $imagineImage = $this->imagineService->open($resourceUri);
     $convertCMYKToRGB = $this->getOptionsMergedWithDefaults()['convertCMYKToRGB'];
     if ($convertCMYKToRGB && $imagineImage->palette() instanceof CMYK) {
         $imagineImage->usePalette(new RGB());
     }
     if ($this->imagineService instanceof Imagine && $originalResource->getFileExtension() === 'gif' && $this->isAnimatedGif(file_get_contents($resourceUri)) === true) {
         $imagineImage->layers()->coalesce();
         $layers = $imagineImage->layers();
         $newLayers = array();
         foreach ($layers as $index => $imagineFrame) {
             $imagineFrame = $this->applyAdjustments($imagineFrame, $adjustments, $adjustmentsApplied);
             $newLayers[] = $imagineFrame;
         }
         $imagineImage = array_shift($newLayers);
         $layers = $imagineImage->layers();
         foreach ($newLayers as $imagineFrame) {
             $layers->add($imagineFrame);
         }
         $additionalOptions['animated'] = true;
     } else {
         $imagineImage = $this->applyAdjustments($imagineImage, $adjustments, $adjustmentsApplied);
     }
     if ($adjustmentsApplied === true) {
         $imagineImage->save($transformedImageTemporaryPathAndFilename, $this->getOptionsMergedWithDefaults($additionalOptions));
         $imageSize = $imagineImage->getSize();
         // TODO: In the future the collectionName of the new resource should be configurable.
         $resource = $this->resourceManager->importResource($transformedImageTemporaryPathAndFilename, $originalResource->getCollectionName());
         if ($resource === false) {
             throw new ImageFileException('An error occurred while importing a generated image file as a resource.', 1413562208);
         }
         unlink($transformedImageTemporaryPathAndFilename);
         $pathInfo = UnicodeFunctions::pathinfo($originalResource->getFilename());
         $resource->setFilename(sprintf('%s-%ux%u.%s', $pathInfo['filename'], $imageSize->getWidth(), $imageSize->getHeight(), $pathInfo['extension']));
     } else {
         $originalResourceStream = $originalResource->getStream();
         $resource = $this->resourceManager->importResource($originalResourceStream, $originalResource->getCollectionName());
         fclose($originalResourceStream);
         $resource->setFilename($originalResource->getFilename());
         $imageSize = $this->getImageSize($originalResource);
         $imageSize = new Box($imageSize['width'], $imageSize['height']);
     }
     $this->imageSizeCache->set($resource->getCacheEntryIdentifier(), array('width' => $imageSize->getWidth(), 'height' => $imageSize->getHeight()));
     $result = array('width' => $imageSize->getWidth(), 'height' => $imageSize->getHeight(), 'resource' => $resource);
     return $result;
 }
 /**
  * Doctrine lifecycle event callback which is triggered on "preRemove" events.
  * This method triggers the deletion of data related to this resource.
  *
  * @return void
  * @ORM\PreRemove
  */
 public function preRemove()
 {
     if ($this->lifecycleEventsActive && $this->deleted === false) {
         $this->resourceManager->deleteResource($this);
     }
 }
 /**
  * Get the collection name this resource will be stored in. Default will be ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME
  * The propertyMappingConfiguration CONFIGURATION_COLLECTION_NAME will directly override the default. Then if CONFIGURATION_ALLOW_COLLECTION_OVERRIDE is TRUE
  * and __collectionName is in the $source this will finally be the value.
  *
  * @param array $source
  * @param PropertyMappingConfigurationInterface $configuration
  * @return string
  * @throws InvalidPropertyMappingConfigurationException
  */
 protected function getCollectionName($source, PropertyMappingConfigurationInterface $configuration = null)
 {
     if ($configuration === null) {
         return ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME;
     }
     $collectionName = $configuration->getConfigurationValue(ResourceTypeConverter::class, self::CONFIGURATION_COLLECTION_NAME) ?: ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME;
     if (isset($source['__collectionName']) && $source['__collectionName'] !== '') {
         $collectionName = $source['__collectionName'];
     }
     if ($this->resourceManager->getCollection($collectionName) === null) {
         throw new InvalidPropertyMappingConfigurationException(sprintf('The selected resource collection named "%s" does not exist, a resource could not be imported.', $collectionName), 1416687475);
     }
     return $collectionName;
 }
 /**
  * Retrieve all Objects stored in this storage.
  *
  * @param callable $callback Function called after each iteration
  * @return \Generator<Object>
  */
 public function getObjects(callable $callback = null)
 {
     foreach ($this->resourceManager->getCollectionsByStorage($this) as $collection) {
         (yield $this->getObjectsByCollection($collection, $callback));
     }
 }
 /**
  * Returns the base URI for static resources
  *
  * IMPORTANT: This method merely exists in order to simplify migration from earlier versions of Flow which still
  * provided this method. This method has never been part of the public API and will be removed in the future.
  *
  * Note that, depending on your Resource Collection setup, this method will not always return the correct base URI,
  * because as of now there can be multiple publishing targets for static resources and URIs of the respective
  * target might not work by simply concatenating a base URI with the relative file name.
  *
  * This method will work for the default Flow setup using only the local file system.
  *
  * Make sure to refactor your client code to use the new resource management API instead. There is no direct
  * replacement for this method in the new API, but if you are dealing with static resources, use the resource stream
  * wrapper instead (through URLs like "resource://Neos.Flow/Public/Error/Debugger.css") or use
  * ResourceManager->getPublicPackageResourceUri() if you know the package key and relative path.
  *
  * Don't use this method. Ne pas utiliser cette méthode. No utilice este método. Finger weg!
  * U bent gewaarschuwd! You have been warned! Mēs jūs brīdinām! Mir hams euch fei gsagd! ;-)
  *
  * @return mixed Either the web URI of the published resource or FALSE if the resource source file doesn't exist or the resource could not be published for other reasons
  * @deprecated since Flow 3.0. You cannot retrieve a base path for static resources anymore, please use resource://* instead or call ResourceManager->getPublicPackageResourceUri()
  */
 public function getStaticResourcesWebBaseUri()
 {
     $this->systemLogger->log('The deprecated method ResourcePublisher->getStaticResourcesWebBaseUri() has been called' . $this->getCallee() . '. You cannot retrieve a base path for static resources anymore, please use resource://* instead or call ResourceManager->getPublicPackageResourceUri().', LOG_WARNING);
     return preg_replace('/\\/Packages\\/$/', '/', $this->resourceManager->getCollection(ResourceManager::DEFAULT_STATIC_COLLECTION_NAME)->getTarget()->getPublicStaticResourceUri(''));
 }