/**
  * Publishes the whole collection to this target
  *
  * @param CollectionInterface $collection The collection to publish
  * @param callable $callback Function called after each resource publishing
  * @return void
  */
 public function publishCollection(CollectionInterface $collection, callable $callback = null)
 {
     $storage = $collection->getStorage();
     if ($storage instanceof PackageStorage) {
         foreach ($storage->getPublicResourcePaths() as $packageKey => $path) {
             $this->publishDirectory($path, $packageKey);
         }
     } else {
         parent::publishCollection($collection, $callback);
     }
 }
 /**
  * Handle missing data notification
  *
  * @param CollectionInterface $collection
  * @param ResourceMetaDataInterface $resource
  */
 protected function handleMissingData(ResourceMetaDataInterface $resource, CollectionInterface $collection)
 {
     $message = sprintf('Could not publish resource %s with SHA1 hash %s of collection %s because there seems to be no corresponding data in the storage.', $resource->getFilename(), $resource->getSha1(), $collection->getName());
     $this->messageCollector->append($message);
 }
 /**
  * Retrieve all Objects stored in this storage, filtered by the given collection name
  *
  * @param callable $callback Function called after each iteration
  * @param CollectionInterface $collection
  * @return \Generator<Object>
  */
 public function getObjectsByCollection(CollectionInterface $collection, callable $callback = null)
 {
     $iterator = $this->resourceRepository->findByCollectionNameIterator($collection->getName());
     $iteration = 0;
     foreach ($this->resourceRepository->iterate($iterator, $callback) as $resource) {
         /** @var PersistentResource $resource */
         $object = new StorageObject();
         $object->setFilename($resource->getFilename());
         $object->setSha1($resource->getSha1());
         $object->setMd5($resource->getMd5());
         $object->setFileSize($resource->getFileSize());
         $object->setStream(function () use($resource) {
             return $this->getStreamByResource($resource);
         });
         (yield $object);
         if (is_callable($callback)) {
             call_user_func($callback, $iteration, $object);
         }
         $iteration++;
     }
 }