本文整理汇总了PHP中TYPO3\Flow\Resource\ResourceManager::getCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceManager::getCollection方法的具体用法?PHP ResourceManager::getCollection怎么用?PHP ResourceManager::getCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Resource\ResourceManager
的用法示例。
在下文中一共展示了ResourceManager::getCollection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: publishCommand
/**
* 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);
}
}
示例2: inlineStyles
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();
}
示例3: getCollectionName
/**
* 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;
}
示例4: copyCommand
/**
* 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
* Resource objects in the database in any way. Since the Resource 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 \TYPO3\Flow\Resource\Storage\Object $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.');
}
示例5: getStaticResourcesWebBaseUri
/**
* 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://TYPO3.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(''));
}
示例6: postPersist
/**
* Doctrine lifecycle event callback which is triggered on "postPersist" events.
* This method triggers the publication of this resource.
*
* @return void
* @ORM\PostPersist
*/
public function postPersist()
{
if ($this->lifecycleEventsActive) {
$collection = $this->resourceManager->getCollection($this->collectionName);
$collection->getTarget()->publishResource($this, $collection);
}
}