LintCommand.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\TwigBundle\Command;
  11. use Symfony\Bridge\Twig\Command\LintCommand as BaseLintCommand;
  12. use Symfony\Component\Finder\Finder;
  13. /**
  14. * Command that will validate your template syntax and output encountered errors.
  15. *
  16. * @author Marc Weistroff <marc.weistroff@sensiolabs.com>
  17. * @author Jérôme Tamarelle <jerome@tamarelle.net>
  18. */
  19. final class LintCommand extends BaseLintCommand
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. protected function configure()
  25. {
  26. parent::configure();
  27. $this
  28. ->setHelp(
  29. $this->getHelp().<<<'EOF'
  30. Or all template files in a bundle:
  31. <info>php %command.full_name% @AcmeDemoBundle</info>
  32. EOF
  33. )
  34. ;
  35. }
  36. protected function findFiles(string $filename): iterable
  37. {
  38. if (0 === strpos($filename, '@')) {
  39. $dir = $this->getApplication()->getKernel()->locateResource($filename);
  40. return Finder::create()->files()->in($dir)->name('*.twig');
  41. }
  42. return parent::findFiles($filename);
  43. }
  44. }