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
974834
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);
        }
    }
833499
public function collections(array $collections) : void {
        foreach ($collections as $name => $callback) {
            $this->make($name, $callback);
        }
    }
308090
public function any( callable $callback )
    {
        foreach( $this->collection as $entity ) {
            if( call_user_func( $callback, $entity) ) {
                return true;
            }
        }
        return false;
    }
1056985
public function dispatch(EventInterface $event, \Closure $callback = null)
	{
		if( $this->isRun() )
		{
			throw new EventOverloadException("The event '{$this->name}' is already running");
		}

		// clean data

		$this->aborted = false;
		$this->complete = [];
		$dispatch = new Collection();

		if( !is_null($this->preparatory) )
		{
			$prepare = $this->preparatory;
			if( $prepare($this) === false )
			{
				$this->aborted = true;
				return $dispatch;
			}
		}

		if( ! $this->count() )
		{
			return $dispatch;
		}

		if( $event->getName() !== $this->name )
		{
			throw new \InvalidArgumentException("The name of the Event does not match the name of the Dispatcher");
		}

		$isCall = $callback instanceof \Closure;
		$this->is_run = true;

		foreach( clone $this->callbacks as $call )
		{
			if( $event->isPropagationStopped() )
			{
				$this->aborted = true;
				break;
			}

			try
			{
				$result = $call($event);
			}
			catch( EventAbortException $e )
			{
				continue;
			}

			if( $isCall )
			{
				$callback($result);
			}
			else if( $this->completable && $result instanceof \Closure )
			{
				$this->complete[] = $result;
			}
			else if( !is_null($result) )
			{
				$dispatch[] = $result;
			}
		}

		$this->is_run = false;

		return $dispatch;
	}
522886
public function previousAll(callable $callback = NULL) {
    $matches = [];
    foreach ($this->nodes as $node) {
      $matches = array_merge($matches, $node->previousAll($callback)->nodes);
    }
    return new NodeCollection($matches);
  }
361199
public function reject($callback): CollectionInterface
    {
        return $this->filter(function ($item, $key) use ($callback) {
            if (is_callable($callback)) {
                return !$callback($item, $key);
            }

            if (null === $item || is_scalar($item)) {
                return $item !== $callback;
            }

            return !$this->accessKey($item, $callback, $key);
        });
    }
1220644
protected function forEachElement(Collection $elements, $callback)
    {
        foreach ($this->flatNamedElements($elements) as $element) {
            $callback($element);
        }
    }
390058
public function publish(OutputInterface $output)
    {
        $callbacks = $this->getCallbacks();
        $publishDirectory = $this->getPublishDirectory();
        $fileSystem = $this->getFileSystem();

        if (empty($callbacks)) {
            throw new \Exception('No pages queued for publishing');
        }
        if ($fileSystem->directoryExists($publishDirectory)) {
            $fileSystem->recursiveRemoveDirectory($publishDirectory);
        }

        foreach ($callbacks as $path => $callback) {
            $pageSourcePath = $this->getPagePath($path);

            // Create a layout
            $layout = new Layout($this->getLayoutRenderer());
            $layout->setSource($this->getDefaultLayout());
            $layout->addAttributes($this->global);

            // Create a page
            $page = new Page($this->getPageRenderer());
            $page->setRawContent($fileSystem->getContents($pageSourcePath));
            $page->addAttributes($this->global);
            $page->setSource($path);

            // User callback
            call_user_func($callback, $page, $layout);

            // Render the page
            $page->setAttribute('url', $this->getPageUrl($page));
            $publishedContent = $page->render();
            $layoutSourcePath = $this->getLayoutPath($layout->getSource());

            if ($layout->isEnabled() && $fileSystem->fileExists($layoutSourcePath)) {
                $layout->setRawContent($fileSystem->getContents($layoutSourcePath));
                $publishedContent = $layout->render($page);
            }
            $pagePublishPath = $this->getPagePublishPath($page);
            $pagePublishDirectory = $this->getPagePublishDirectory($page);

            if (! $fileSystem->directoryExists($pagePublishDirectory)) {
                $fileSystem->createDirectory($pagePublishDirectory, 0755, true);
            }
            $fileSystem->putContents($pagePublishPath, $publishedContent);
            $output->writeln($this->publishMessage($pageSourcePath, $pagePublishPath));
            $this->pages[] = $page->getAttributes();
        }
        $fileSystem->copyDirectory($this->getAssetsDirectory(), $publishDirectory);
        $output->writeln($this->publishMessage($this->getAssetsDirectory(), $publishDirectory));

        return $this->pages;
    }
786401
public function executeFor($id, Closure $callback): void
    {
        $callback(
            $this->newQuery()->findOrFail($id)
        );
    }
73054
private function trackCollection(Collection $collection)
    {
        $blocks = $collection->getBlocks();
        $this->trackBlocks($collection, $blocks);
    }
350394
public function extract(Collection $resources, Closure $callback)
    {
        foreach ($resources as $resource) {
            $callback($resource, [$this->inflector->singularize($this->getVariableName()) => $resource]);
        }
    }
782509
protected function registerEventsTo(EntityCollection $collection, $cid)
    {
        $collection->setId($cid);
        $collection->getEmitter()
            ->addListener(
                EntityAdded::ACTION_ADD,
                [$this, 'updateCollection']
            );
        $collection->getEmitter()
            ->addListener(
                EntityRemoved::ACTION_REMOVE,
                [$this, 'updateCollection']
            );
        $entity = $this->repository->getEntityDescriptor()->className();
        Orm::addListener(
            $entity,
            Delete::ACTION_AFTER_DELETE,
            function (Delete $event) use ($collection) {
                $collection->remove($event->getEntity());
            },
            EmitterInterface::P_HIGH
        );
        return $this;
    }
729212
protected function saveCollection(Collection $collection) {
		if ($collection->count() === 1) {
			return $this->save($collection->getFirst());
		}

		$transaction = $this->getTransactionsManager()->get(true);

		foreach ($collection as $model) {
			if (! $this->saveThroughPhalconModel($model, $transaction)) {
				$transaction->rollback();
			}
		}

		$transaction->commit();
		return true;
	}
695426
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);
    }
953250
public function filter(Closure $callback): CollectionInterface
    {
        $array = array_filter(
            $this->toArray(),
            $callback,
            ARRAY_FILTER_USE_BOTH
        );

        return static::make(array_values($array));
    }
1203844
public function merge(AbstractCollection $collection)
    {
        if (is_subclass_of($collection, get_class($this)) === true || get_class($collection) === get_class($this)) {
            $newData = array_merge($this->dataPlaceHolder, $collection->getDataPlaceHolder());
            $this->dataPlaceHolder = $newData;
        } else {
            $msg = "Only collections with compliant types can be merged ";
            $msg.= "('" . get_class($this) . "' vs '" . get_class($collection) . "').";
            throw new InvalidArgumentException($msg);
        }
    }
1272744
public function publishCollection(CollectionInterface $collection)
    {
        $storage = $collection->getStorage();
        $targetBucket = $this->getCurrentBucket();

        if ($storage instanceof GcsStorage && $storage->getBucketName() === $targetBucket->name()) {
            // Nothing to do: the storage bucket is (or should be) publicly accessible
            return;
        }

        if (!isset($this->existingObjectsInfo)) {
            $this->existingObjectsInfo = [];
            $parameters = [
                'prefix' => $this->keyPrefix
            ];

            foreach ($this->getCurrentBucket()->objects($parameters) as $storageObject) {
                /** @var StorageObject $storageObject */
                $this->existingObjectsInfo[$storageObject->name()] = true;
            }
        }

        $obsoleteObjects = $this->existingObjectsInfo;

        if ($storage instanceof GcsStorage) {
            $this->publishCollectionFromDifferentGoogleCloudStorage($collection, $storage, $this->existingObjectsInfo, $obsoleteObjects, $targetBucket);
        } else {
            foreach ($collection->getObjects() as $object) {
                /** @var \Neos\Flow\ResourceManagement\Storage\StorageObject $object */
                $this->publishFile($object->getStream(), $this->getRelativePublicationPathAndFilename($object), $object);
                unset($obsoleteObjects[$this->getRelativePublicationPathAndFilename($object)]);
            }
        }

        $this->systemLogger->log(sprintf('Removing %s obsolete objects from target bucket "%s".', count($obsoleteObjects), $this->bucketName), LOG_INFO);
        foreach (array_keys($obsoleteObjects) as $relativePathAndFilename) {
            try {
                $targetBucket->object($this->keyPrefix . $relativePathAndFilename)->delete();
            } catch (NotFoundException $e) {
            }
        }
    }