/** * Publish resources * * This command publishes the resources of the given or - if none was specified, all - resource collections * to their respective configured publishing targets. * * @param string $collection If specified, only resources of this collection are published. Example: 'persistent' * @return void */ public function publishCommand($collection = NULL) { try { if ($collection === NULL) { $collections = $this->resourceManager->getCollections(); } else { $collections = array(); $collections[$collection] = $this->resourceManager->getCollection($collection); if ($collections[$collection] === NULL) { $this->outputLine('Collection "%s" does not exist.', array($collection)); $this->quit(1); } } foreach ($collections as $collection) { /** @var CollectionInterface $collection */ $this->outputLine('Publishing resources of collection "%s"', array($collection->getName())); $collection->publish(); } } catch (Exception $exception) { $this->outputLine(); $this->outputLine('An error occurred while publishing resources (see full description below). You can check and probably fix the integrity of the resource registry by using the resource:clean command.'); $this->outputLine('%s (Exception code: %s)', array(get_class($exception), $exception->getCode())); $this->outputLine($exception->getMessage()); $this->quit(1); } }
/** * 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 Resource $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, Resource $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; }
/** * @return \TYPO3\Flow\Resource\Resource * @throws \TYPO3\Flow\Resource\Exception */ protected function buildTestResource() { $testImagePath = Files::concatenatePaths([__DIR__, 'Fixtures/Resources/Lighthouse.jpg']); $resource = $this->resourceManager->importResource($testImagePath); $asset = new \TYPO3\Media\Domain\Model\Asset($resource); return $asset; }
/** * @param FlowResource $originalResource * @param array $adjustments * @return array resource, width, height as keys * @throws ImageFileException * @throws InvalidConfigurationException * @throws \TYPO3\Flow\Resource\Exception */ public function processImage(FlowResource $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); if ($this->imagineService instanceof \Imagine\Imagick\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; }
/** * 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())))); }
public function setUp() { parent::setUp(); if (!$this->persistenceManager instanceof \TYPO3\Flow\Persistence\Doctrine\PersistenceManager) { $this->markTestSkipped('Doctrine persistence is not enabled'); } $this->resourceManager = $this->objectManager->get('TYPO3\\Flow\\Resource\\ResourceManager'); $resource = $this->resourceManager->importResource(__DIR__ . '/Fixtures/ReferenceImage.jpg'); $this->originalImage = new Image($resource); }
/** * @test */ public function openResolvesAnUpperCaseSha1HashUsingTheResourceManager() { $sha1Hash = '68AC906495480A3404BEEE4874ED853A037A7A8F'; $tempFile = tmpfile(); $mockResource = $this->getMockBuilder(Resource::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->assertSame($tempFile, $this->resourceStreamWrapper->open('resource://' . $sha1Hash, 'r', 0, $openedPathAndFilename)); }
/** * @test */ public function openResolvesAnUpperCaseSha1HashUsingTheResourceManager() { $sha1Hash = '68AC906495480A3404BEEE4874ED853A037A7A8F'; $persistentResourcesStorageBaseUri = 'vfs://Foo/Some/'; $absoluteResourcePath = $persistentResourcesStorageBaseUri . $sha1Hash; mkdir($persistentResourcesStorageBaseUri); file_put_contents('vfs://Foo/Some/' . $sha1Hash, 'fixture'); $this->mockResourceManager->expects($this->once())->method('getPersistentResourcesStorageBaseUri')->will($this->returnValue($persistentResourcesStorageBaseUri)); $openedPathAndFilename = ''; $this->assertTrue($this->resourceStreamWrapper->open('resource://' . $sha1Hash, 'r', 0, $openedPathAndFilename)); $this->assertSame($absoluteResourcePath, $openedPathAndFilename); }
/** * @param AssetInterface $asset * @param integer $maximumWidth * @param integer $maximumHeight * @return array */ protected function getAssetThumbnailImage(AssetInterface $asset, $maximumWidth, $maximumHeight) { // TODO: Could be configurable at some point $iconPackage = 'TYPO3.Media'; $iconSize = $this->getDocumentIconSize($maximumWidth, $maximumHeight); if (is_file('resource://' . $iconPackage . '/Public/Icons/16px/' . $asset->getResource()->getFileExtension() . '.png')) { $icon = sprintf('Icons/%spx/' . $asset->getResource()->getFileExtension() . '.png', $iconSize); } else { $icon = sprintf('Icons/%spx/_blank.png', $iconSize); } return array('width' => $iconSize, 'height' => $iconSize, 'src' => $this->resourceManager->getPublicPackageResourceUri($iconPackage, $icon)); }
/** * Renders an <img> HTML tag for a filetype icon for a given TYPO3.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(); }
/** * @test */ public function convertFromReturnsAnErrorIfTheUploadedFileCantBeImported() { $source = array('tmp_name' => 'SomeFilename', 'error' => \UPLOAD_ERR_OK); $this->mockResourceManager->expects($this->once())->method('importUploadedResource')->with($source)->will($this->returnValue(FALSE)); $actualResult = $this->resourceTypeConverter->convertFrom($source, 'TYPO3\\Flow\\Resource\\Resource'); $this->assertInstanceOf('TYPO3\\Flow\\Error\\Error', $actualResult); }
/** * @return Asset * @throws \TYPO3\Flow\Resource\Exception */ protected function buildAssetObject() { $resource = $this->resourceManager->importResourceFromContent('Test', 'test.txt'); $asset = new Asset($resource); $this->assetRepository->add($asset); return $asset; }
/** * Creates a user based on the given information * * The created user and account are automatically added to their respective repositories and thus be persisted. * * @param string $username The username of the user to be created. * @param string $password Password of the user to be created * @param string $firstName First name of the user to be created * @param string $lastName Last name of the user to be created * @param string $department department of the user to be created * @param string $photo photo of the user to be created * @param array $roleIdentifiers A list of role identifiers to assign * @param string $authenticationProviderName Name of the authentication provider to use. Example: "Typo3BackendProvider" * @return User The created user instance * @api */ public function createUserPhlu($username, $password, $firstName, $lastName, $department, $photo, array $roleIdentifiers = null, $authenticationProviderName = null) { $collection = $this->assetCollectionRepository->findByCollectionName('phluCollection2')->getFirst(); if (!$collection) { $collection = new \TYPO3\Media\Domain\Model\AssetCollection('phluCollection2'); $this->assetCollectionRepository->add($collection); $this->persistenceManager->persistAll(); } $user = new User(); $user->setDepartment($department); $name = new PersonName('', $firstName, '', $lastName, '', $username); $user->setName($name); $resource = $this->resourceManager->importResource($photo); $image = new Image($resource); $image->setTitle($name->getFullName()); $tag = $this->tagRepository->findBySearchTerm('Hauswart')->getFirst(); if (!$tag) { $tag = new Tag(); $tag->setLabel('Hauswart'); $this->tagRepository->add($tag); $collection->addTag($tag); } $image->addTag($tag); $user->setPhoto($image); $this->assetRepository->add($image); $collection->addAsset($image); $this->assetCollectionRepository->update($collection); return $this->addUserPhlu($username, $password, $user, $roleIdentifiers, $authenticationProviderName); }
/** * 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 \TYPO3\Flow\Resource\Exception * @throws \InvalidArgumentException */ 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 = parse_url($requestedPath); if (!is_array($uriParts) || !isset($uriParts['host'])) { return FALSE; } if (preg_match('/^[0-9a-f]{40}$/i', $uriParts['host']) === 1) { $resourcePath = $this->resourceManager->getPersistentResourcesStorageBaseUri() . $uriParts['host']; if ($checkForExistence === FALSE || file_exists($resourcePath)) { return $resourcePath; } else { return FALSE; } } if (!$this->packageManager->isPackageAvailable($uriParts['host'])) { throw new \TYPO3\Flow\Resource\Exception(sprintf('Invalid resource URI "%s": Package "%s" is not available.', $requestedPath, $uriParts['host']), 1309269952); } $package = $this->packageManager->getPackage($uriParts['host']); $resourcePath = \TYPO3\Flow\Utility\Files::concatenatePaths(array($package->getResourcesPath(), $uriParts['path'])); if ($checkForExistence === FALSE || file_exists($resourcePath)) { return $resourcePath; } return FALSE; }
/** * @test */ public function convertFromReturnsAnErrorIfTheUploadedFileCantBeImported() { $this->inject($this->resourceTypeConverter, 'systemLogger', $this->createMock(\TYPO3\Flow\Log\SystemLoggerInterface::class)); $source = array('tmp_name' => 'SomeFilename', 'error' => \UPLOAD_ERR_OK); $this->mockResourceManager->expects($this->once())->method('importUploadedResource')->with($source)->will($this->throwException(new \TYPO3\Flow\Resource\Exception())); $actualResult = $this->resourceTypeConverter->convertFrom($source, \TYPO3\Flow\Resource\Resource::class); $this->assertInstanceOf(\TYPO3\Flow\Error\Error::class, $actualResult); }
/** * Opens the specified file. If a file is opened currently it gets closed first. * * @param string $odsFile: The ODS file to open * @return void */ public function openFile($odsFile) { if ($odsFile === $this->currentFile) { return; } if ($this->odsResource !== NULL) { $this->closeFile(); } // Create a local copy of the template $resource = $this->resourceManager->importResource($odsFile); $this->temporaryFileName = $resource->createTemporaryLocalCopy(); $this->odsResource = new \ZipArchive(); if ($this->odsResource->open($this->temporaryFileName) !== true) { throw new \Exception('Couldn\'t open ODS file!'); } $this->currentFile = $odsFile; }
/** * Retrieve all Objects stored in this storage. * * @return array<\TYPO3\Flow\Resource\Storage\Object> * @api */ public function getObjects() { $objects = array(); foreach ($this->resourceManager->getCollectionsByStorage($this) as $collection) { $objects = array_merge($objects, $this->getObjectsByCollection($collection)); } return $objects; }
protected function importImage($filename) { $resource = $this->resourceManager->importResource($filename); $image = new Image($resource); $this->imageRepository->add($image); $processingInstructions = array(); return $this->objectManager->get('TYPO3\\Media\\Domain\\Model\\ImageVariant', $image, $processingInstructions); }
/** * @param boolean $minified * @param string $include * @return string * @throws \Exception */ public function render($minified = true, $include = 'remaining') { if (!in_array($include, array('all', 'css', 'js', 'remaining'))) { throw new \Exception('invalid include parameter. valid values are "remaining", "all", "css" and "js".'); } if ($include == 'remaining') { if (self::$cssIncluded && self::$jsIncluded) { return ''; } else { if (!self::$cssIncluded && !self::$jsIncluded) { $include = 'all'; } else { if (!self::$cssIncluded) { $include = 'css'; } else { $include = 'js'; } } } } else { if ($include == 'all' && (self::$cssIncluded || self::$jsIncluded)) { throw new \Exception("Some Owlcarousel's dependencies are already included."); } else { if ($include == 'css' && self::$cssIncluded) { throw new \Exception("Owlcarousel's CSS is already included."); } else { if ($include == 'js' && self::$jsIncluded) { throw new \Exception("Owlcarousel's JavaScript is already included."); } } } } $return = ''; if ($include == 'css' || $include == 'all') { $css = $this->resourceManager->getPublicPackageResourceUri('Axovis.Flow.Owlcarousel', 'Styles/owl.carousel.css'); $return .= '<link rel="stylesheet" type="text/css" href="' . $css . '" />'; self::$cssIncluded = true; } if ($include == 'js' || $include == 'all') { $js = $this->resourceManager->getPublicPackageResourceUri('Axovis.Flow.Owlcarousel', 'JavaScript/owl.carousel' . ($minified ? '.min' : '') . '.js'); $return .= '<script type="text/javascript" src="' . $js . '"></script>'; self::$jsIncluded = true; } return $return; }
/** * 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()); }
public function inlineStyles($html) { //return $html; // TODO: the following won't work with Cloud Publishing... $staticResourceBaseUri = $this->resourceManager->getCollection(ResourceManager::DEFAULT_STATIC_COLLECTION_NAME)->getTarget()->getPublicStaticResourceUri(''); $stylesheetLinks = array(); $html = preg_replace_callback(self::STYLE_LINK_TAG_REGEX, function ($match) use(&$stylesheetLinks, $staticResourceBaseUri) { $stylesheetLink = $match[1]; $stylesheetLinks[] = FLOW_PATH_WEB . substr($stylesheetLink, strpos($staticResourceBaseUri, '_Resources')); return ''; }, $html); $finalCss = ''; foreach ($stylesheetLinks as $stylesheetLink) { $finalCss .= "\n{$stylesheetLink}\n" . file_get_contents($stylesheetLink) . "\n\n"; } $cssToInlineStyleConverter = new CssToInlineStyles($html, $finalCss); return $cssToInlineStyleConverter->convert(); }
/** * @param \GIB\GradingTool\Domain\Model\Project $project */ public function showAction($project) { $radarChartFileName = $this->submissionService->getRadarImage($project); $radarChartResource = $this->resourceManager->importResource($radarChartFileName); $radarChartResource->setFilename('radarChart.jpg'); $radarChartImage = new \TYPO3\Media\Domain\Model\Image($radarChartResource); $this->persistenceManager->persistAll(); $this->view->assignMultiple(array('project' => $project, 'submission' => $this->submissionService->getProcessedSubmission($project), 'radarChartImage' => $radarChartImage)); }
/** * @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('TYPO3.Neos:Preview')); if ($thumbnail !== null) { $imageProperties['previewImageResourceUri'] = $this->thumbnailService->getUriForThumbnail($thumbnail); $imageProperties['previewDimensions'] = ['width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()]; } return $imageProperties; }
/** * @param AssetInterface $asset * @param integer $maximumWidth * @param integer $maximumHeight * @return array */ public function getStaticThumbnailForAsset(AssetInterface $asset, $maximumWidth, $maximumHeight) { $iconSize = $this->getDocumentIconSize($maximumWidth, $maximumHeight); if (is_file('resource://TYPO3.Media/Public/Icons/16px/' . $asset->getResource()->getFileExtension() . '.png')) { $icon = sprintf('Icons/%spx/' . $asset->getResource()->getFileExtension() . '.png', $iconSize); } else { $icon = sprintf('Icons/%spx/_blank.png', $iconSize); } $icon = $this->resourceManager->getPublicPackageResourceUri('TYPO3.Media', $icon); return array('width' => $iconSize, 'height' => $iconSize, 'src' => $icon); }
/** * Review a submission * * The create action is missing because the project is added in the * SubmissionFinisher (see Form/Finishers) * * @param \GIB\GradingTool\Domain\Model\Project $project */ public function reviewSubmissionAction(\GIB\GradingTool\Domain\Model\Project $project) { // access check $this->checkOwnerOrAdministratorAndDenyIfNeeded($project); $submission = $this->submissionService->getProcessedSubmission($project); $radarChartImagePathAndFilename = $this->submissionService->getRadarImage($project); $radarChartImageResource = $this->resourceManager->importResource($radarChartImagePathAndFilename); $radarChartUri = $this->resourcePublisher->getPersistentResourceWebUri($radarChartImageResource); // this is necessary because we're in a safe request, but generate a resource $this->persistenceManager->persistAll(); $this->view->assignMultiple(array('submission' => $submission, 'project' => $project, 'radarChartUri' => $radarChartUri)); }
/** * @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); }
/** * Send a mail to the project manager with the spider graph as attachement * * @param Project $project */ public function sendGradingToProjectManager($project) { // send mail to project manager $radarChartImagePathAndFilename = $this->getRadarImage($project); $radarChartImageResource = $this->resourceManager->importResource($radarChartImagePathAndFilename); $radarChartUri = $this->resourcePublisher->getPersistentResourceWebUri($radarChartImageResource); // this is necessary because we're in a safe request, but generate a resource $this->persistenceManager->persistAll(); $attachements = array(array('source' => $radarChartUri, 'fileName' => 'gib-grading.png')); $templateIdentifierOverlay = $this->templateService->getTemplateIdentifierOverlay('newSubmissionProjectManagerNotification', $project); $this->notificationMailService->sendNotificationMail($templateIdentifierOverlay, $project, $project->getProjectManager(), $project->getProjectManager()->getName()->getFirstName() . ' ' . $project->getProjectManager()->getName()->getLastName(), $project->getProjectManager()->getPrimaryElectronicAddress()->getIdentifier(), '', $attachements); // CC to GIB $this->notificationMailService->sendNotificationMail($templateIdentifierOverlay, $project, $project->getProjectManager(), $project->getProjectManager()->getName()->getFirstName() . ' ' . $project->getProjectManager()->getName()->getLastName(), '*****@*****.**', '', $attachements); }
/** * 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(\TYPO3\Flow\Resource\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; }
/** * Calculates the dimensions of the thumbnail to be generated and returns the thumbnail URI. * In case of Images this is a thumbnail of the image, in case of other assets an icon representation. * * @param AssetInterface $asset * @param ThumbnailConfiguration $configuration * @param ActionRequest $request Request argument must be provided for asynchronous thumbnails * @return array|null Array with keys "width", "height" and "src" if the thumbnail generation work or null * @throws AssetServiceException */ public function getThumbnailUriAndSizeForAsset(AssetInterface $asset, ThumbnailConfiguration $configuration, ActionRequest $request = null) { $thumbnailImage = $this->thumbnailService->getThumbnail($asset, $configuration); if (!$thumbnailImage instanceof ImageInterface) { return null; } $resource = $thumbnailImage->getResource(); if ($thumbnailImage instanceof Thumbnail) { $staticResource = $thumbnailImage->getStaticResource(); if ($configuration->isAsync() === true && $resource === null && $staticResource === null) { if ($request === null) { throw new AssetServiceException('Request argument must be provided for async thumbnails.', 1447660835); } $this->uriBuilder->setRequest($request->getMainRequest()); $uri = $this->uriBuilder->reset()->setCreateAbsoluteUri(true)->uriFor('thumbnail', array('thumbnail' => $thumbnailImage), 'Thumbnail', 'TYPO3.Media'); } else { $uri = $this->thumbnailService->getUriForThumbnail($thumbnailImage); } } else { $uri = $this->resourceManager->getPublicPersistentResourceUri($resource); } return array('width' => $thumbnailImage->getWidth(), 'height' => $thumbnailImage->getHeight(), 'src' => $uri); }
/** * @param ComponentContext $componentContext * @return void * @throws FileNotFoundException|AccessDeniedException|FlowException */ public function handle(ComponentContext $componentContext) { $httpRequest = $componentContext->getHttpRequest(); if (!$httpRequest->hasArgument('__protectedResource')) { return; } try { $encodedResourceData = $this->hashService->validateAndStripHmac($httpRequest->getArgument('__protectedResource')); } catch (InvalidHashException $exception) { throw new AccessDeniedException('Invalid HMAC!', 1421241393, $exception); } $tokenData = json_decode(base64_decode($encodedResourceData), TRUE); $this->verifyExpiration($tokenData); $this->verifySecurityContextHash($tokenData, $httpRequest); $resource = $this->resourceManager->getResourceBySha1($tokenData['resourceIdentifier']); if ($resource === NULL) { throw new FileNotFoundException(sprintf('Unknown resource!%sCould not find resource with identifier "%s"', chr(10), $tokenData['resourceIdentifier']), 1429621743); } // TODO there should be a better way to determine the absolute path of the resource? Resource::createTemporaryLocalCopy() is too expensive $resourcePathAndFilename = Files::concatenatePaths(array($this->options['basePath'], $tokenData['resourceIdentifier'][0], $tokenData['resourceIdentifier'][1], $tokenData['resourceIdentifier'][2], $tokenData['resourceIdentifier'][3], $tokenData['resourceIdentifier'])); if (!is_file($resourcePathAndFilename)) { throw new FileNotFoundException(sprintf('File not found!%sThe file "%s" does not exist', chr(10), $resourcePathAndFilename), 1429702284); } if (!isset($this->options['serveStrategy'])) { throw new FlowException('No "serveStrategy" configured!', 1429704107); } $fileServeStrategy = $this->objectManager->get($this->options['serveStrategy']); if (!$fileServeStrategy instanceof FileServeStrategyInterface) { throw new FlowException(sprintf('The class "%s" does not implement the FileServeStrategyInterface', get_class($fileServeStrategy)), 1429704284); } $httpResponse = $componentContext->getHttpResponse(); $httpResponse->setHeader('Content-Type', $resource->getMediaType()); $this->emitResourceServed($resource, $httpRequest); $fileServeStrategy->serve($resourcePathAndFilename, $httpResponse); $componentContext->setParameter('TYPO3\\Flow\\Http\\Component\\ComponentChain', 'cancel', TRUE); }