本文整理汇总了PHP中TYPO3\Flow\Resource\ResourceManager::getCollections方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceManager::getCollections方法的具体用法?PHP ResourceManager::getCollections怎么用?PHP ResourceManager::getCollections使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Resource\ResourceManager
的用法示例。
在下文中一共展示了ResourceManager::getCollections方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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 = [];
$collections[$collection] = $this->resourceManager->getCollection($collection);
if ($collections[$collection] === null) {
$this->outputLine('Collection "%s" does not exist.', [$collection]);
$this->quit(1);
}
}
foreach ($collections as $collection) {
/** @var CollectionInterface $collection */
$this->outputLine('Publishing resources of collection "%s"', [$collection->getName()]);
$target = $collection->getTarget();
$target->publishCollection($collection, function ($iteration) {
$this->clearState($iteration);
});
}
if ($this->messageCollector->hasMessages()) {
$this->outputLine();
$this->outputLine('The resources were published, but a few inconsistencies were detected. You can check and probably fix the integrity of the resource registry by using the resource:clean command.');
$this->messageCollector->flush(function (Message $notification) {
$this->outputLine($notification->getSeverity() . ': ' . $notification->getMessage());
});
}
} 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)', [get_class($exception), $exception->getCode()]);
$this->outputLine($exception->getMessage());
$this->quit(1);
}
}