displayGeneralText example

protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $io = new SymfonyStyle($input$output);
        $name = $input->getArgument('name');
        $filter = $input->getOption('filter');

        if (null !== $name && [] === $this->getFilesystemLoaders()) {
            throw new InvalidArgumentException(sprintf('Argument "name" not supported, it requires the Twig loader "%s".', FilesystemLoader::class));
        }

        match ($input->getOption('format')) {
            'text' => $name ? $this->displayPathsText($io$name) : $this->displayGeneralText($io$filter),
            'json' => $name ? $this->displayPathsJson($io$name) : $this->displayGeneralJson($io$filter),
            default => throw new InvalidArgumentException(sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))),
        };

        return 0;
    }

    public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
    {
        if ($input->mustSuggestArgumentValuesFor('name')) {
            $suggestions->suggestValues(array_keys($this->getLoaderPaths()));
        }
Home | Imprint | This part of the site doesn't use cookies.