/** * 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++; } }