XliffLintCommand.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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\FrameworkBundle\Command;
  11. use Symfony\Component\Translation\Command\XliffLintCommand as BaseLintCommand;
  12. /**
  13. * Validates XLIFF files syntax and outputs encountered errors.
  14. *
  15. * @author Grégoire Pineau <lyrixx@lyrixx.info>
  16. * @author Robin Chalas <robin.chalas@gmail.com>
  17. * @author Javier Eguiluz <javier.eguiluz@gmail.com>
  18. *
  19. * @final
  20. */
  21. class XliffLintCommand extends BaseLintCommand
  22. {
  23. protected static $defaultName = 'lint:xliff';
  24. public function __construct()
  25. {
  26. $directoryIteratorProvider = function ($directory, $default) {
  27. if (!is_dir($directory)) {
  28. $directory = $this->getApplication()->getKernel()->locateResource($directory);
  29. }
  30. return $default($directory);
  31. };
  32. $isReadableProvider = function ($fileOrDirectory, $default) {
  33. return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory);
  34. };
  35. parent::__construct(null, $directoryIteratorProvider, $isReadableProvider);
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. protected function configure()
  41. {
  42. parent::configure();
  43. $this->setHelp($this->getHelp().<<<'EOF'
  44. Or find all files in a bundle:
  45. <info>php %command.full_name% @AcmeDemoBundle</info>
  46. EOF
  47. );
  48. }
  49. }