Classes/Command/GcsCommandController.php
public function republishCommand(string $collection = 'persistent'): void
    {
        $collectionName = $collection;
        $collection = $this->resourceManager->getCollection($collectionName);
        if (!$collection) {
            $this->outputLine('<error>The collection %s does not exist.</error>', [$collectionName]);
            exit(1);
        }

        $target = $collection->getTarget();
        if (!$target instanceof GcsTarget) {
            $this->outputLine('<error>The target defined in collection %s is not a Google Cloud Storage target.</error>', [$collectionName]);
            exit(1);
        }

        $this->outputLine('Republishing collection ...');
        $this->output->progressStart();
        try {
            foreach ($collection->getObjects() as $object) {
                /** @var StorageObject $object */
                $resource = $this->resourceManager->getResourceBySha1($object->getSha1());
                if ($resource) {
                    $target->publishResource($resource, $collection);
                }
                $this->output->progressAdvance();
            }
        } catch (\Exception $e) {
            $this->outputLine('<error>Publishing failed</error>');
            $this->outputLine($e->getMessage());
            $this->outputLine(get_class($e));
            exit(2);
        }
        $this->output->progressFinish();
        $this->outputLine();
    }
public function republishCommand(string $collection = 'persistent'): void
    {
        $collectionName = $collection;
        $collection = $this->resourceManager->getCollection($collectionName);
        if (!$collection) {
            $this->outputLine('<error>The collection %s does not exist.</error>', [$collectionName]);
            exit(1);
        }

        $target = $collection->getTarget();
        if (!$target instanceof GcsTarget) {
            $this->outputLine('<error>The target defined in collection %s is not a Google Cloud Storage target.</error>', [$collectionName]);
            exit(1);
        }

        $this->outputLine('Republishing collection ...');
        $this->output->progressStart();
        try {
            foreach ($collection->getObjects() as $object) {
                /** @var StorageObject $object */
                $resource = $this->resourceManager->getResourceBySha1($object->getSha1());
                if ($resource) {
                    $target->publishResource($resource, $collection);
                }
                $this->output->progressAdvance();
            }
        } catch (\Exception $e) {
            $this->outputLine('<error>Publishing failed</error>');
            $this->outputLine($e->getMessage());
            $this->outputLine(get_class($e));
            exit(2);
        }
        $this->output->progressFinish();
        $this->outputLine();
    }
public function republishCommand ( string $ collection = 'persistent' ) : void { $ collectionName = $ collection ; $ collection = $ this -> resourceManager -> getCollection ( $ collectionName ) ; if ( ! $ collection ) { $ this -> outputLine ( '<error>The collection %s does not exist.</error>' , [ $ collectionName ] ) ; exit ( 1 ) ; } $ target = $ collection -> getTarget ( ) ; if ( ! $ target instanceof GcsTarget ) { $ this -> outputLine ( '<error>The target defined in collection %s is not a Google Cloud Storage target.</error>' , [ $ collectionName ] ) ; exit ( 1 ) ; } $ this -> outputLine ( 'Republishing collection ...' ) ; $ this -> output -> progressStart ( ) ; try { foreach ( $ collection -> getObjects ( ) as $ object ) { /** @var StorageObject $object */ $ resource = $ this -> resourceManager -> getResourceBySha1 ( $ object -> getSha1 ( ) ) ; if ( $ resource ) { $ target -> publishResource ( $ resource , $ collection ) ; } $ this -> output -> progressAdvance ( ) ; } } catch ( \ Exception $ e ) { $ this -> outputLine ( '<error>Publishing failed</error>' ) ; $ this -> outputLine ( $ e -> getMessage ( ) ) ; $ this -> outputLine ( get_class ( $ e ) ) ; exit ( 2 ) ; } $ this -> output -> progressFinish ( ) ; $ this -> outputLine ( ) ; }
Republish a collection

This command forces publishing resources of the given collection by copying resources from the respective storage
to target bucket.

@param string $collection Name of the collection to publish
Republish a collection