Neos\Flow\ResourceManagement\ResourceManager::getCollection PHP Метод

getCollection() публичный Метод

Returns a Collection instance by the given name
public getCollection ( string $collectionName ) : Neos\Flow\ResourceManagement\CollectionInterface
$collectionName string Name of the collection as defined in the settings
Результат Neos\Flow\ResourceManagement\CollectionInterface or NULL
    public function getCollection($collectionName)
    {
        $this->initialize();
        return isset($this->collections[$collectionName]) ? $this->collections[$collectionName] : null;
    }

Usage Example

Пример #1
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.');
 }
All Usage Examples Of Neos\Flow\ResourceManagement\ResourceManager::getCollection