SymfonyStyle example

$this->fillOption('locale', 'Locale', $input$output);
        $this->fillOption('password', 'Password', $input$output);
    }

    /** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->validateInput($input);

        $io = new SymfonyStyle($input$output);

        $user = $this->createAdminUser();

        $user->setLocaleId($this->getLocaleIdFromLocale($input->getOption('locale')));
        $user->setEmail($input->getOption('email'));
        $user->setUsername($input->getOption('username'));
        $user->setName($input->getOption('name'));
        $user->setLockedUntil(new DateTime('2010-01-01 00:00:00'));
        $this->setPassword($user$input->getOption('password'));

        $this->persistUser($user);

        
parent::__construct();
        $this->context = Context::createDefaultContext();
    }

    protected function configure(): void
    {
        $this->addArgument('theme-id', InputArgument::OPTIONAL, 'Theme ID');
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $this->io = new SymfonyStyle($input$output);

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('theme.salesChannels.typeId', Defaults::SALES_CHANNEL_TYPE_STOREFRONT));

        $id = $input->getArgument('theme-id');
        if ($id !== null) {
            $criteria->setIds([$id]);
        }

        $themes = $this->themeRepository->search($criteria$this->context);

        
 catch (Exception $e) {
            $output->writeln(sprintf('Plugin by name "%s" was not found.', $pluginName));

            return 1;
        }
        $em = $this->container->get(ModelManager::class);

        $shops = null;
        $shopId = null;

        if ($input->getOption('shop')) {
            $io = new SymfonyStyle($input$output);
            $io->warning('Option "--shop" will be replaced by option "--shopId" in the next major version');
            $shopId = $input->getOption('shop');
        } elseif ($input->getOption('shopId')) {
            $shopId = $input->getOption('shopId');
        }

        if ($shopId) {
            /** @var Shop|null $shop */
            $shop = $em->getRepository(Shop::class)->find($shopId);
            if (!$shop) {
                $output->writeln(sprintf('Could not find shop with id %s.', $shopId));

                
null,
            InputOption::VALUE_OPTIONAL,
            'Shop Basepath (deprecated, use shop-url option instead)'
        );
    }

    /** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input$output);

        if (!$input->getOption('steps')) {
            $io->error('Parameter --steps not given');

            return 1;
        }

        /** @var array<string, string> $dbConfig */
        $dbConfig = $this->getContainer()->getParameter('shopware.db');
        $rootDir = $this->getContainer()->getParameter('kernel.root_dir');

        
->addArgument('issue', InputArgument::OPTIONAL, 'The corresponding Jira ticket key. Can be the key of a single ticket or the key of an epic.')
            ->addOption('date', null, InputOption::VALUE_OPTIONAL, 'The date in `YYYY-MM-DD` format which indicates the creation date of the change. Default is current date.')
            ->addOption('flag', null, InputOption::VALUE_OPTIONAL, 'Feature Flag ID')
            ->addOption('author', null, InputOption::VALUE_OPTIONAL, 'The author of code changes')
            ->addOption('author-email', null, InputOption::VALUE_OPTIONAL, 'The author email of code changes')
            ->addOption('author-github', null, InputOption::VALUE_OPTIONAL, 'The author email of code changes')
            ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Use the --dry-run argument to preview the changelog content and prevent actually writing to file.');
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $IOHelper = new SymfonyStyle($input$output);
        $IOHelper->title('Create a changelog markdown file');

        $default = $this->getDefaultData();
        $title = $input->getArgument('title')
            ?? $IOHelper->ask('A short meaningful title of your change', null, function D$title) {
                if (!$title) {
                    throw new \RuntimeException('Title is required in changelog file');
                }

                return $title;
            });
        
/** * @internal */
    public function __construct(private readonly KernelInterface $kernel)
    {
        parent::__construct();
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $fs = new Filesystem();
        $io = new SymfonyStyle($input$output);

        foreach ($this->kernel->getBundles() as $bundle) {
            if (!$bundle instanceof Bundle) {
                continue;
            }

            $bundlePath = $bundle->getPath();
            $publicPath = $bundlePath . '/Resources/public';

            if (!is_dir($publicPath)) {
                continue;
            }

        $this->addOption('private-key-path', null, InputOption::VALUE_OPTIONAL, 'JWT public key path')
            ->addOption('public-key-path', null, InputOption::VALUE_OPTIONAL, 'JWT public key path')
            ->addOption('jwt-passphrase', null, InputOption::VALUE_OPTIONAL, 'JWT private key passphrase', 'shopware')
            ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force recreation')
            ->addOption('use-env', null, InputOption::VALUE_NONE, 'Print JWT secret to console to use it as environment variable')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $io = new SymfonyStyle($input$output);

        $passphrase = $input->getOption('jwt-passphrase');

        $privateKeyPath = $input->getOption('private-key-path') ?? ($this->projectDir . '/config/jwt/private.pem');
        $publicKeyPath = $input->getOption('public-key-path') ?? ($this->projectDir . '/config/jwt/public.pem');

        if (!\is_string($passphrase)) {
            $io->error('Passphrase is invalid');

            return self::FAILURE;
        }

        

        $this->setName('sw:thumbnail:cleanup')
            ->setDescription('Deletes thumbnails for images whose original file has been deleted.')
            ->setHelp('The <info>%command.name%</info> deletes unused thumbnails.');
    }

    /** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input$output);

        $this->removeThumbnails($io);

        return 0;
    }

    private function removeThumbnails(SymfonyStyle $io): void
    {
        $filesystem = $this->getContainer()->get(MediaServiceInterface::class)->getFilesystem();

        $thumbnailFiles = $this->searchThumbnails($io$filesystem);

        
/** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $lastBackLogId = $this->backlogReader->getLastBacklogId();
        $backlogs = $this->backlogReader->read($lastBackLogId$this->batchSize);

        $output->writeln(sprintf('Current last backlog id: %d', $lastBackLogId));

        $io = new SymfonyStyle($input$output);

        if (empty($backlogs)) {
            $io->success('Backlog is empty');

            return 0;
        }

        foreach ($this->identifierSelector->getShops() as $shop) {
            foreach ($this->mappings as $mapping) {
                $index = $this->indexFactory->createShopIndex($shop$mapping->getType());

                
EOF
            )
        ;
    }

    /** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input$output);

        if ($this->container->getParameter('shopware.session.save_handler') === 'file') {
            $io->error('Session save handler "file" is not supported');

            return 1;
        }

        /** @var Shop $shop */
        $shop = $this->container->get('models')->getRepository(Shop::class)->getDefault();
        $this->container->get('shopware.components.shop_registration_service')->registerShop($shop);

        
protected function configure(): void
    {
        $this->setHelp('Collect all markdown files, which do not have a flag meta field, inside the `/changelog/_unreleased` directory and move them to a new directory for the release in `/changelog/release-6-x-x-x`. After that the command will update the global `/CHANGELOG.md` file with a new section for the release with a list of links to the single changelog files. For major and minor releases it will also create or update the corresponding UPGRADE-6.x.md file with the markdown content from the "Upgrade Information" section of the single changelog files.')
            ->addArgument('version', InputArgument::OPTIONAL, 'A version of release. It should be 4-digits type')
            ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Use the --dry-run argument to preview the changelog content and prevent actually writing to file.')
            ->addOption('force', 'f', InputOption::VALUE_NONE, 'Use the --force argument to override an existing release.');
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $IOHelper = new SymfonyStyle($input$output);
        $IOHelper->title('Creating or updating the final changelog for a new release');

        $version = $input->getArgument('version')
            ?? $IOHelper->ask('A version of release', null, function D$version) {
                if (!$version) {
                    throw new \RuntimeException('Version of release is required.');
                }

                return $version;
            });
        if (!preg_match("/^\d+(\.\d+){3}$/", (string) $version)) {
            

        $this->database = $this->container->get(Connection::class);
        $this->modules = $this->container->get('modules');
        $this->modelManager = $this->container->get(ModelManager::class);
        $this->seoIndex = $this->container->get('seoindex');
        $this->rewriteTable = $this->modules->RewriteTable();
        $this->events = $this->container->get('events');

        $shops = null;

        if ($input->getArgument('shopId')) {
            $io = new SymfonyStyle($input$output);
            $io->warning('Argument "shopId" will be replaced by option "--shopId" in the next major version');
            $shops = $input->getArgument('shopId');
        } elseif ($input->getOption('shopId')) {
            $shops = $input->getOption('shopId');
        }

        if (empty($shops)) {
            $query = $this->database->createQueryBuilder();
            $shops = $query->select('id')
                ->from('s_core_shops', 'shops')
                ->where('active', 1)
                

    public function configure(): void
    {
        $this->setDescription('Clear backlog sync');
    }

    public function execute(InputInterface $input, OutputInterface $output)
    {
        $backlogService = $this->container->get('shopware_bundle_es_backend.backlog_service');
        $backlogService->clear();

        $io = new SymfonyStyle($input$output);

        $io->success('Backlog has been cleared');

        return 0;
    }
}
->method('fetchOne')
            ->with('SELECT JSON_OVERLAPS(JSON_ARRAY(1), JSON_ARRAY(1));')
            ->willThrowException(new \Exception('Not available'));

        $command = new DeleteNotUsedMediaCommand($service$connection);

        $commandTester = new CommandTester($command);
        $commandTester->execute([]);

        $output = new BufferedOutput();

        $io = new SymfonyStyle(
            new ArrayInput([]),
            $output,
        );

        $io->error('Your database does not support the JSON_OVERLAPS function. Please update your database to MySQL 8.0 or MariaDB 10.9 or higher.');

        static::assertStringContainsString($output->fetch()$commandTester->getDisplay());
    }

    public function testExecuteWithConfirm(): void
    {
        
->setName('sw:cache:clear')
            ->setDescription('Clears the cache')
        ;
    }

    /** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $outputIsVerbose = $output->isVerbose();
        $io = new SymfonyStyle($input$output);

        $realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir');

        if (!\is_string($realCacheDir)) {
            throw new RuntimeException('Parameter kernel.cache_dir needs to be a string');
        }

        // the old cache dir name must not be longer than the real one to avoid exceeding         // the maximum length of a directory or file path within it (esp. Windows MAX_PATH)         $oldCacheDir = substr($realCacheDir, 0, -1) . (substr($realCacheDir, -1) === '~' ? '+' : '~');
        $filesystem = $this->getContainer()->get('file_system');

        
Home | Imprint | This part of the site doesn't use cookies.