appRoot = $appRoot; $this->renderer = $renderer; parent::__construct(); } /** * {@inheritdoc} */ protected function configure() { $this ->setName('druplicon') ->setDescription($this->trans('application.commands.druplicon.description')); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $directory = sprintf( '%s/templates/core/druplicon/', $this->appRoot . DRUPAL_CONSOLE_CORE ); $finder = new Finder(); $finder->files() ->name('*.twig') ->in($directory); $templates = []; foreach ($finder as $template) { $templates[] = $template->getRelativePathname(); } $druplicon = $this->renderer->render( sprintf( 'core/druplicon/%s', $templates[array_rand($templates)] ) ); $io->writeln($druplicon); return 0; } }