setFormatDefinition example

$style->comment('Setting visibility to public in asset bucket.');
        $this->setVisibility($this->filesystemAsset, $style, 'public');

        $style->info('Finished setting visibility of objects in all pre-defined buckets.');

        return Command::SUCCESS;
    }

    private function setVisibility(FilesystemOperator $filesystem, ShopwareStyle $style, string $visibility): void
    {
        $files = array_filter($filesystem->listContents('/', true)->toArray()fn (StorageAttributes $object): bool => $object->type() === 'file');
        ProgressBar::setFormatDefinition('custom', '[%bar%] %current%/%max% -- %message%');
        $progressBar = new ProgressBar($style, \count((array) $files));
        $progressBar->setFormat('custom');
        $progressBar->setMessage('');

        foreach ($files as $file) {
            $filesystem->setVisibility($file->path()$visibility);

            $progressBar->advance();
            $progressBar->setMessage($file->path());
        }

        
' 0/50 [>---------------------------] 0%'.\PHP_EOL.
            "\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL.
            "\x1b[2A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL.
            "\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL.
            ' 1/50 [>---------------------------] 2%'.\PHP_EOL,
            stream_get_contents($stream->getStream())
        );
    }

    public function testOverwritWithNewlinesInMessage()
    {
        ProgressBar::setFormatDefinition('test', '%current%/%max% [%bar%] %percent:3s%% %message% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.');

        $bar = new ProgressBar($output = $this->getOutputStream(), 50, 0);
        $bar->setFormat('test');
        $bar->start();
        $bar->display();
        $bar->setMessage("Twas brillig, and the slithy toves. Did gyre and gimble in the wabe: All mimsy were the borogoves, And the mome raths outgrabe.\nBeware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun The frumious Bandersnatch!");
        $bar->advance();
        $bar->setMessage("He took his vorpal sword in hand; Long time the manxome foe he sought— So rested he by the Tumtum tree And stood awhile in thought.\nAnd, as in uffish thought he stood, The Jabberwock, with eyes of flame, Came whiffling through the tulgey wood, And burbled as it came!");
        $bar->advance();

        rewind($output->getStream());
        
Home | Imprint | This part of the site doesn't use cookies.