[FrameworkBundle] Commands as a service
This commit is contained in:
parent
8e517f6326
commit
de1dc0b469
@ -100,7 +100,7 @@ EOF
|
|||||||
if (__CLASS__ !== get_class($this)) {
|
if (__CLASS__ !== get_class($this)) {
|
||||||
$r = new \ReflectionMethod($this, 'getTwigEnvironment');
|
$r = new \ReflectionMethod($this, 'getTwigEnvironment');
|
||||||
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
|
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
|
||||||
@trigger_error(sprintf('Usage of method "%s" is deprecated since version 3.4 and will no longer be supported in 4.0.', get_class($this).'::getTwigEnvironment'), E_USER_DEPRECATED);
|
@trigger_error(sprintf('Usage of method "%s" is deprecated since version 3.4 and will no longer be supported in 4.0. Construct the command with its required arguments instead.', get_class($this).'::getTwigEnvironment'), E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->twig = $this->getTwigEnvironment();
|
$this->twig = $this->getTwigEnvironment();
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ EOF
|
|||||||
if (__CLASS__ !== get_class($this)) {
|
if (__CLASS__ !== get_class($this)) {
|
||||||
$r = new \ReflectionMethod($this, 'getTwigEnvironment');
|
$r = new \ReflectionMethod($this, 'getTwigEnvironment');
|
||||||
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
|
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
|
||||||
@trigger_error(sprintf('Usage of method "%s" is deprecated since version 3.4 and will no longer be supported in 4.0.', get_class($this).'::getTwigEnvironment'), E_USER_DEPRECATED);
|
@trigger_error(sprintf('Usage of method "%s" is deprecated since version 3.4 and will no longer be supported in 4.0. Construct the command with its required arguments instead.', get_class($this).'::getTwigEnvironment'), E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->twig = $this->getTwigEnvironment();
|
$this->twig = $this->getTwigEnvironment();
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ use Symfony\Component\HttpKernel\KernelInterface;
|
|||||||
* A console command to display information about the current installation.
|
* A console command to display information about the current installation.
|
||||||
*
|
*
|
||||||
* @author Roland Franssen <franssen.roland@gmail.com>
|
* @author Roland Franssen <franssen.roland@gmail.com>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class AboutCommand extends ContainerAwareCommand
|
class AboutCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
@ -45,7 +47,7 @@ class AboutCommand extends ContainerAwareCommand
|
|||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
/** @var $kernel KernelInterface */
|
/** @var $kernel KernelInterface */
|
||||||
$kernel = $this->getContainer()->get('kernel');
|
$kernel = $this->getApplication()->getKernel();
|
||||||
|
|
||||||
$io->table(array(), array(
|
$io->table(array(), array(
|
||||||
array('<info>Symfony</>'),
|
array('<info>Symfony</>'),
|
||||||
|
@ -31,7 +31,7 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
|
|||||||
$headers = array('Bundle name', 'Extension alias');
|
$headers = array('Bundle name', 'Extension alias');
|
||||||
$rows = array();
|
$rows = array();
|
||||||
|
|
||||||
$bundles = $this->getContainer()->get('kernel')->getBundles();
|
$bundles = $this->getApplication()->getKernel()->getBundles();
|
||||||
usort($bundles, function ($bundleA, $bundleB) {
|
usort($bundles, function ($bundleA, $bundleB) {
|
||||||
return strcmp($bundleA->getName(), $bundleB->getName());
|
return strcmp($bundleA->getName(), $bundleB->getName());
|
||||||
});
|
});
|
||||||
@ -117,7 +117,7 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
|
|||||||
// Re-build bundle manually to initialize DI extensions that can be extended by other bundles in their build() method
|
// Re-build bundle manually to initialize DI extensions that can be extended by other bundles in their build() method
|
||||||
// as this method is not called when the container is loaded from the cache.
|
// as this method is not called when the container is loaded from the cache.
|
||||||
$container = $this->getContainerBuilder();
|
$container = $this->getContainerBuilder();
|
||||||
$bundles = $this->getContainer()->get('kernel')->getBundles();
|
$bundles = $this->getApplication()->getKernel()->getBundles();
|
||||||
foreach ($bundles as $bundle) {
|
foreach ($bundles as $bundle) {
|
||||||
if ($extension = $bundle->getContainerExtension()) {
|
if ($extension = $bundle->getContainerExtension()) {
|
||||||
$container->registerExtension($extension);
|
$container->registerExtension($extension);
|
||||||
|
@ -26,6 +26,8 @@ use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
|||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
* @author Gábor Egyed <gabor.egyed@gmail.com>
|
* @author Gábor Egyed <gabor.egyed@gmail.com>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class AssetsInstallCommand extends ContainerAwareCommand
|
class AssetsInstallCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
@ -33,11 +35,26 @@ class AssetsInstallCommand extends ContainerAwareCommand
|
|||||||
const METHOD_ABSOLUTE_SYMLINK = 'absolute symlink';
|
const METHOD_ABSOLUTE_SYMLINK = 'absolute symlink';
|
||||||
const METHOD_RELATIVE_SYMLINK = 'relative symlink';
|
const METHOD_RELATIVE_SYMLINK = 'relative symlink';
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Filesystem
|
|
||||||
*/
|
|
||||||
private $filesystem;
|
private $filesystem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Filesystem $filesystem
|
||||||
|
*/
|
||||||
|
public function __construct($filesystem = null)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
if (!$filesystem instanceof Filesystem) {
|
||||||
|
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$this->setName(null === $filesystem ? 'assets:install' : $filesystem);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->filesystem = $filesystem;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -79,10 +96,17 @@ EOT
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
// BC to be removed in 4.0
|
||||||
|
if (null === $this->filesystem) {
|
||||||
|
$this->filesystem = $this->getContainer()->get('filesystem');
|
||||||
|
$baseDir = $this->getContainer()->getParameter('kernel.project_dir');
|
||||||
|
}
|
||||||
|
|
||||||
|
$kernel = $this->getApplication()->getKernel();
|
||||||
$targetArg = rtrim($input->getArgument('target'), '/');
|
$targetArg = rtrim($input->getArgument('target'), '/');
|
||||||
|
|
||||||
if (!is_dir($targetArg)) {
|
if (!is_dir($targetArg)) {
|
||||||
$targetArg = $this->getContainer()->getParameter('kernel.project_dir').'/'.$targetArg;
|
$targetArg = (isset($baseDir) ? $baseDir : $kernel->getContainer()->getParameter('kernel.project_dir')).'/'.$targetArg;
|
||||||
|
|
||||||
if (!is_dir($targetArg)) {
|
if (!is_dir($targetArg)) {
|
||||||
// deprecated, logic to be removed in 4.0
|
// deprecated, logic to be removed in 4.0
|
||||||
@ -95,8 +119,6 @@ EOT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->filesystem = $this->getContainer()->get('filesystem');
|
|
||||||
|
|
||||||
// Create the bundles directory otherwise symlink will fail.
|
// Create the bundles directory otherwise symlink will fail.
|
||||||
$bundlesDir = $targetArg.'/bundles/';
|
$bundlesDir = $targetArg.'/bundles/';
|
||||||
$this->filesystem->mkdir($bundlesDir, 0777);
|
$this->filesystem->mkdir($bundlesDir, 0777);
|
||||||
@ -122,7 +144,7 @@ EOT
|
|||||||
$exitCode = 0;
|
$exitCode = 0;
|
||||||
$validAssetDirs = array();
|
$validAssetDirs = array();
|
||||||
/** @var BundleInterface $bundle */
|
/** @var BundleInterface $bundle */
|
||||||
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
|
foreach ($kernel->getBundles() as $bundle) {
|
||||||
if (!is_dir($originDir = $bundle->getPath().'/Resources/public')) {
|
if (!is_dir($originDir = $bundle->getPath().'/Resources/public')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
|
||||||
use Symfony\Component\HttpKernel\KernelInterface;
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
use Symfony\Component\Finder\Finder;
|
use Symfony\Component\Finder\Finder;
|
||||||
|
|
||||||
@ -23,9 +25,34 @@ use Symfony\Component\Finder\Finder;
|
|||||||
*
|
*
|
||||||
* @author Francis Besset <francis.besset@gmail.com>
|
* @author Francis Besset <francis.besset@gmail.com>
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class CacheClearCommand extends ContainerAwareCommand
|
class CacheClearCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
|
private $cacheClearer;
|
||||||
|
private $filesystem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param CacheClearerInterface $cacheClearer
|
||||||
|
* @param Filesystem|null $filesystem
|
||||||
|
*/
|
||||||
|
public function __construct($cacheClearer = null, Filesystem $filesystem = null)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
if (!$cacheClearer instanceof CacheClearerInterface) {
|
||||||
|
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$this->setName(null === $cacheClearer ? 'cache:clear' : $cacheClearer);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->cacheClearer = $cacheClearer;
|
||||||
|
$this->filesystem = $filesystem ?: new Filesystem();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -54,28 +81,34 @@ EOF
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
// BC to be removed in 4.0
|
||||||
|
if (null === $this->cacheClearer) {
|
||||||
|
$this->cacheClearer = $this->getContainer()->get('cache_clearer');
|
||||||
|
$this->filesystem = $this->getContainer()->get('filesystem');
|
||||||
|
$realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
|
||||||
|
}
|
||||||
|
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
|
$kernel = $this->getApplication()->getKernel();
|
||||||
|
$realCacheDir = isset($realCacheDir) ? $realCacheDir : $kernel->getContainer()->getParameter('kernel.cache_dir');
|
||||||
// the old cache dir name must not be longer than the real one to avoid exceeding
|
// 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)
|
// the maximum length of a directory or file path within it (esp. Windows MAX_PATH)
|
||||||
$oldCacheDir = substr($realCacheDir, 0, -1).('~' === substr($realCacheDir, -1) ? '+' : '~');
|
$oldCacheDir = substr($realCacheDir, 0, -1).('~' === substr($realCacheDir, -1) ? '+' : '~');
|
||||||
$filesystem = $this->getContainer()->get('filesystem');
|
|
||||||
|
|
||||||
if (!is_writable($realCacheDir)) {
|
if (!is_writable($realCacheDir)) {
|
||||||
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir));
|
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filesystem->exists($oldCacheDir)) {
|
if ($this->filesystem->exists($oldCacheDir)) {
|
||||||
$filesystem->remove($oldCacheDir);
|
$this->filesystem->remove($oldCacheDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
$kernel = $this->getContainer()->get('kernel');
|
|
||||||
$io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
|
$io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
|
||||||
$this->getContainer()->get('cache_clearer')->clear($realCacheDir);
|
$this->cacheClearer->clear($realCacheDir);
|
||||||
|
|
||||||
if ($input->getOption('no-warmup')) {
|
if ($input->getOption('no-warmup')) {
|
||||||
$filesystem->rename($realCacheDir, $oldCacheDir);
|
$this->filesystem->rename($realCacheDir, $oldCacheDir);
|
||||||
} else {
|
} else {
|
||||||
$warning = 'Calling cache:clear without the --no-warmup option is deprecated since version 3.3. Cache warmup should be done with the cache:warmup command instead.';
|
$warning = 'Calling cache:clear without the --no-warmup option is deprecated since version 3.3. Cache warmup should be done with the cache:warmup command instead.';
|
||||||
|
|
||||||
@ -90,7 +123,7 @@ EOF
|
|||||||
$io->comment('Removing old cache directory...');
|
$io->comment('Removing old cache directory...');
|
||||||
}
|
}
|
||||||
|
|
||||||
$filesystem->remove($oldCacheDir);
|
$this->filesystem->remove($oldCacheDir);
|
||||||
|
|
||||||
if ($output->isVerbose()) {
|
if ($output->isVerbose()) {
|
||||||
$io->comment('Finished');
|
$io->comment('Finished');
|
||||||
@ -101,7 +134,6 @@ EOF
|
|||||||
|
|
||||||
private function warmupCache(InputInterface $input, OutputInterface $output, $realCacheDir, $oldCacheDir)
|
private function warmupCache(InputInterface $input, OutputInterface $output, $realCacheDir, $oldCacheDir)
|
||||||
{
|
{
|
||||||
$filesystem = $this->getContainer()->get('filesystem');
|
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
// the warmup cache dir name must have the same length than the real one
|
// the warmup cache dir name must have the same length than the real one
|
||||||
@ -109,11 +141,11 @@ EOF
|
|||||||
$realCacheDir = realpath($realCacheDir);
|
$realCacheDir = realpath($realCacheDir);
|
||||||
$warmupDir = substr($realCacheDir, 0, -1).('_' === substr($realCacheDir, -1) ? '-' : '_');
|
$warmupDir = substr($realCacheDir, 0, -1).('_' === substr($realCacheDir, -1) ? '-' : '_');
|
||||||
|
|
||||||
if ($filesystem->exists($warmupDir)) {
|
if ($this->filesystem->exists($warmupDir)) {
|
||||||
if ($output->isVerbose()) {
|
if ($output->isVerbose()) {
|
||||||
$io->comment('Clearing outdated warmup directory...');
|
$io->comment('Clearing outdated warmup directory...');
|
||||||
}
|
}
|
||||||
$filesystem->remove($warmupDir);
|
$this->filesystem->remove($warmupDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($output->isVerbose()) {
|
if ($output->isVerbose()) {
|
||||||
@ -121,11 +153,11 @@ EOF
|
|||||||
}
|
}
|
||||||
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
|
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
|
||||||
|
|
||||||
$filesystem->rename($realCacheDir, $oldCacheDir);
|
$this->filesystem->rename($realCacheDir, $oldCacheDir);
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
sleep(1); // workaround for Windows PHP rename bug
|
sleep(1); // workaround for Windows PHP rename bug
|
||||||
}
|
}
|
||||||
$filesystem->rename($warmupDir, $realCacheDir);
|
$this->filesystem->rename($warmupDir, $realCacheDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,7 +170,7 @@ EOF
|
|||||||
protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = true)
|
protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = true)
|
||||||
{
|
{
|
||||||
// create a temporary kernel
|
// create a temporary kernel
|
||||||
$realKernel = $this->getContainer()->get('kernel');
|
$realKernel = $this->getApplication()->getKernel();
|
||||||
$realKernelClass = get_class($realKernel);
|
$realKernelClass = get_class($realKernel);
|
||||||
$namespace = '';
|
$namespace = '';
|
||||||
if (false !== $pos = strrpos($realKernelClass, '\\')) {
|
if (false !== $pos = strrpos($realKernelClass, '\\')) {
|
||||||
@ -274,7 +306,7 @@ namespace $namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOF;
|
EOF;
|
||||||
$this->getContainer()->get('filesystem')->mkdir($warmupDir);
|
$this->filesystem->mkdir($warmupDir);
|
||||||
file_put_contents($file = $warmupDir.'/kernel.tmp', $code);
|
file_put_contents($file = $warmupDir.'/kernel.tmp', $code);
|
||||||
require_once $file;
|
require_once $file;
|
||||||
$class = "$namespace\\$class";
|
$class = "$namespace\\$class";
|
||||||
|
@ -25,6 +25,26 @@ use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
|
|||||||
*/
|
*/
|
||||||
final class CachePoolClearCommand extends ContainerAwareCommand
|
final class CachePoolClearCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
|
private $poolClearer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Psr6CacheClearer $poolClearer
|
||||||
|
*/
|
||||||
|
public function __construct($poolClearer = null)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
if (!$poolClearer instanceof Psr6CacheClearer) {
|
||||||
|
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$this->setName(null === $poolClearer ? 'cache:pool:clear' : $poolClearer);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->poolClearer = $poolClearer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -50,18 +70,22 @@ EOF
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
// BC to be removed in 4.0
|
||||||
|
if (null === $this->poolClearer) {
|
||||||
|
$this->poolClearer = $this->getContainer()->get('cache.global_clearer');
|
||||||
|
$cacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
|
||||||
|
}
|
||||||
|
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
$kernel = $this->getApplication()->getKernel();
|
||||||
$pools = array();
|
$pools = array();
|
||||||
$clearers = array();
|
$clearers = array();
|
||||||
$container = $this->getContainer();
|
|
||||||
$cacheDir = $container->getParameter('kernel.cache_dir');
|
|
||||||
$globalClearer = $container->get('cache.global_clearer');
|
|
||||||
|
|
||||||
foreach ($input->getArgument('pools') as $id) {
|
foreach ($input->getArgument('pools') as $id) {
|
||||||
if ($globalClearer->hasPool($id)) {
|
if ($this->poolClearer->hasPool($id)) {
|
||||||
$pools[$id] = $id;
|
$pools[$id] = $id;
|
||||||
} else {
|
} else {
|
||||||
$pool = $container->get($id);
|
$pool = $kernel->getContainer()->get($id);
|
||||||
|
|
||||||
if ($pool instanceof CacheItemPoolInterface) {
|
if ($pool instanceof CacheItemPoolInterface) {
|
||||||
$pools[$id] = $pool;
|
$pools[$id] = $pool;
|
||||||
@ -75,7 +99,7 @@ EOF
|
|||||||
|
|
||||||
foreach ($clearers as $id => $clearer) {
|
foreach ($clearers as $id => $clearer) {
|
||||||
$io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id));
|
$io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id));
|
||||||
$clearer->clear($cacheDir);
|
$clearer->clear(isset($cacheDir) ? $cacheDir : $kernel->getContainer()->getParameter('kernel.cache_dir'));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($pools as $id => $pool) {
|
foreach ($pools as $id => $pool) {
|
||||||
@ -84,7 +108,7 @@ EOF
|
|||||||
if ($pool instanceof CacheItemPoolInterface) {
|
if ($pool instanceof CacheItemPoolInterface) {
|
||||||
$pool->clear();
|
$pool->clear();
|
||||||
} else {
|
} else {
|
||||||
$globalClearer->clearPool($id);
|
$this->poolClearer->clearPool($id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,14 +15,37 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warmup the cache.
|
* Warmup the cache.
|
||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class CacheWarmupCommand extends ContainerAwareCommand
|
class CacheWarmupCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
|
private $cacheWarmer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param CacheWarmerAggregate $cacheWarmer
|
||||||
|
*/
|
||||||
|
public function __construct($cacheWarmer = null)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
if (!$cacheWarmer instanceof CacheWarmerAggregate) {
|
||||||
|
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$this->setName(null === $cacheWarmer ? 'cache:warmup' : $cacheWarmer);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->cacheWarmer = $cacheWarmer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -54,18 +77,22 @@ EOF
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$io = new SymfonyStyle($input, $output);
|
// BC to be removed in 4.0
|
||||||
|
if (null === $this->cacheWarmer) {
|
||||||
$kernel = $this->getContainer()->get('kernel');
|
$this->cacheWarmer = $this->getContainer()->get('cache_warmer');
|
||||||
$io->comment(sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
|
$cacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
|
||||||
|
|
||||||
$warmer = $this->getContainer()->get('cache_warmer');
|
|
||||||
|
|
||||||
if (!$input->getOption('no-optional-warmers')) {
|
|
||||||
$warmer->enableOptionalWarmers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$warmer->warmUp($this->getContainer()->getParameter('kernel.cache_dir'));
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
|
$kernel = $this->getApplication()->getKernel();
|
||||||
|
$io->comment(sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
|
||||||
|
|
||||||
|
if (!$input->getOption('no-optional-warmers')) {
|
||||||
|
$this->cacheWarmer->enableOptionalWarmers();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->cacheWarmer->warmUp(isset($cacheDir) ? $cacheDir : $kernel->getContainer()->getParameter('kernel.cache_dir'));
|
||||||
|
|
||||||
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
|
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ use Symfony\Component\Yaml\Yaml;
|
|||||||
* A console command for dumping available configuration reference.
|
* A console command for dumping available configuration reference.
|
||||||
*
|
*
|
||||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class ConfigDebugCommand extends AbstractConfigCommand
|
class ConfigDebugCommand extends AbstractConfigCommand
|
||||||
{
|
{
|
||||||
@ -111,7 +113,7 @@ EOF
|
|||||||
|
|
||||||
private function compileContainer()
|
private function compileContainer()
|
||||||
{
|
{
|
||||||
$kernel = clone $this->getContainer()->get('kernel');
|
$kernel = clone $this->getApplication()->getKernel();
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
|
|
||||||
$method = new \ReflectionMethod($kernel, 'buildContainer');
|
$method = new \ReflectionMethod($kernel, 'buildContainer');
|
||||||
|
@ -25,6 +25,8 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||||||
* @author Kevin Bond <kevinbond@gmail.com>
|
* @author Kevin Bond <kevinbond@gmail.com>
|
||||||
* @author Wouter J <waldio.webdesign@gmail.com>
|
* @author Wouter J <waldio.webdesign@gmail.com>
|
||||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class ConfigDumpReferenceCommand extends AbstractConfigCommand
|
class ConfigDumpReferenceCommand extends AbstractConfigCommand
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,8 @@ use Symfony\Component\Config\FileLocator;
|
|||||||
* A console command for retrieving information about services.
|
* A console command for retrieving information about services.
|
||||||
*
|
*
|
||||||
* @author Ryan Weaver <ryan@thatsquality.com>
|
* @author Ryan Weaver <ryan@thatsquality.com>
|
||||||
|
*
|
||||||
|
* @internal since version 3.4
|
||||||
*/
|
*/
|
||||||
class ContainerDebugCommand extends ContainerAwareCommand
|
class ContainerDebugCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
|
@ -23,9 +23,31 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|||||||
* A console command for retrieving information about event dispatcher.
|
* A console command for retrieving information about event dispatcher.
|
||||||
*
|
*
|
||||||
* @author Matthieu Auger <mail@matthieuauger.com>
|
* @author Matthieu Auger <mail@matthieuauger.com>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class EventDispatcherDebugCommand extends ContainerAwareCommand
|
class EventDispatcherDebugCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
|
private $dispatcher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param EventDispatcherInterface $dispatcher
|
||||||
|
*/
|
||||||
|
public function __construct($dispatcher = null)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
if (!$dispatcher instanceof EventDispatcherInterface) {
|
||||||
|
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$this->setName(null === $dispatcher ? 'debug:event-dispatcher' : $dispatcher);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->dispatcher = $dispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -59,12 +81,16 @@ EOF
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
// BC to be removed in 4.0
|
||||||
|
if (null === $this->dispatcher) {
|
||||||
|
$this->dispatcher = $this->getEventDispatcher();
|
||||||
|
}
|
||||||
|
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
$dispatcher = $this->getEventDispatcher();
|
|
||||||
|
|
||||||
$options = array();
|
$options = array();
|
||||||
if ($event = $input->getArgument('event')) {
|
if ($event = $input->getArgument('event')) {
|
||||||
if (!$dispatcher->hasListeners($event)) {
|
if (!$this->dispatcher->hasListeners($event)) {
|
||||||
$io->getErrorStyle()->warning(sprintf('The event "%s" does not have any registered listeners.', $event));
|
$io->getErrorStyle()->warning(sprintf('The event "%s" does not have any registered listeners.', $event));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -77,12 +103,14 @@ EOF
|
|||||||
$options['format'] = $input->getOption('format');
|
$options['format'] = $input->getOption('format');
|
||||||
$options['raw_text'] = $input->getOption('raw');
|
$options['raw_text'] = $input->getOption('raw');
|
||||||
$options['output'] = $io;
|
$options['output'] = $io;
|
||||||
$helper->describe($io, $dispatcher, $options);
|
$helper->describe($io, $this->dispatcher, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the Event Dispatcher from the container.
|
* Loads the Event Dispatcher from the container.
|
||||||
*
|
*
|
||||||
|
* BC to removed in 4.0
|
||||||
|
*
|
||||||
* @return EventDispatcherInterface
|
* @return EventDispatcherInterface
|
||||||
*/
|
*/
|
||||||
protected function getEventDispatcher()
|
protected function getEventDispatcher()
|
||||||
|
@ -27,14 +27,41 @@ use Symfony\Component\Routing\Route;
|
|||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
* @author Tobias Schultze <http://tobion.de>
|
* @author Tobias Schultze <http://tobion.de>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class RouterDebugCommand extends ContainerAwareCommand
|
class RouterDebugCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
|
private $router;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param RouterInterface $router
|
||||||
|
*/
|
||||||
|
public function __construct($router = null)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
if (!$router instanceof RouterInterface) {
|
||||||
|
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$this->setName(null === $router ? 'debug:router' : $router);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->router = $router;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* BC to be removed in 4.0
|
||||||
*/
|
*/
|
||||||
public function isEnabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
|
if (null !== $this->router) {
|
||||||
|
return parent::isEnabled();
|
||||||
|
}
|
||||||
if (!$this->getContainer()->has('router')) {
|
if (!$this->getContainer()->has('router')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -77,10 +104,15 @@ EOF
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
// BC to be removed in 4.0
|
||||||
|
if (null === $this->router) {
|
||||||
|
$this->router = $this->getContainer()->get('router');
|
||||||
|
}
|
||||||
|
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
$name = $input->getArgument('name');
|
$name = $input->getArgument('name');
|
||||||
$helper = new DescriptorHelper();
|
$helper = new DescriptorHelper();
|
||||||
$routes = $this->getContainer()->get('router')->getRouteCollection();
|
$routes = $this->router->getRouteCollection();
|
||||||
|
|
||||||
if ($name) {
|
if ($name) {
|
||||||
if (!$route = $routes->get($name)) {
|
if (!$route = $routes->get($name)) {
|
||||||
@ -132,7 +164,7 @@ EOF
|
|||||||
if (1 === substr_count($controller, ':')) {
|
if (1 === substr_count($controller, ':')) {
|
||||||
list($service, $method) = explode(':', $controller);
|
list($service, $method) = explode(':', $controller);
|
||||||
try {
|
try {
|
||||||
return sprintf('%s::%s', get_class($this->getContainer()->get($service)), $method);
|
return sprintf('%s::%s', get_class($this->getApplication()->getKernel()->getContainer()->get($service)), $method);
|
||||||
} catch (ServiceNotFoundException $e) {
|
} catch (ServiceNotFoundException $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,41 @@ use Symfony\Component\Routing\Matcher\TraceableUrlMatcher;
|
|||||||
* A console command to test route matching.
|
* A console command to test route matching.
|
||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class RouterMatchCommand extends ContainerAwareCommand
|
class RouterMatchCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
|
private $router;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param RouterInterface $router
|
||||||
|
*/
|
||||||
|
public function __construct($router = null)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
if (!$router instanceof RouterInterface) {
|
||||||
|
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$this->setName(null === $router ? 'router:match' : $router);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->router = $router;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* BC to be removed in 4.0
|
||||||
*/
|
*/
|
||||||
public function isEnabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
|
if (null !== $this->router) {
|
||||||
|
return parent::isEnabled();
|
||||||
|
}
|
||||||
if (!$this->getContainer()->has('router')) {
|
if (!$this->getContainer()->has('router')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -76,10 +103,14 @@ EOF
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
// BC to be removed in 4.0
|
||||||
|
if (null === $this->router) {
|
||||||
|
$this->router = $this->getContainer()->get('router');
|
||||||
|
}
|
||||||
|
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$router = $this->getContainer()->get('router');
|
$context = $this->router->getContext();
|
||||||
$context = $router->getContext();
|
|
||||||
if (null !== $method = $input->getOption('method')) {
|
if (null !== $method = $input->getOption('method')) {
|
||||||
$context->setMethod($method);
|
$context->setMethod($method);
|
||||||
}
|
}
|
||||||
@ -90,7 +121,7 @@ EOF
|
|||||||
$context->setHost($host);
|
$context->setHost($host);
|
||||||
}
|
}
|
||||||
|
|
||||||
$matcher = new TraceableUrlMatcher($router->getRouteCollection(), $context);
|
$matcher = new TraceableUrlMatcher($this->router->getRouteCollection(), $context);
|
||||||
|
|
||||||
$traces = $matcher->getTraces($input->getArgument('path_info'));
|
$traces = $matcher->getTraces($input->getArgument('path_info'));
|
||||||
|
|
||||||
|
@ -17,25 +17,55 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\HttpKernel\Kernel;
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
use Symfony\Component\Translation\Catalogue\MergeOperation;
|
use Symfony\Component\Translation\Catalogue\MergeOperation;
|
||||||
|
use Symfony\Component\Translation\Extractor\ExtractorInterface;
|
||||||
use Symfony\Component\Translation\MessageCatalogue;
|
use Symfony\Component\Translation\MessageCatalogue;
|
||||||
use Symfony\Component\Translation\Translator;
|
use Symfony\Component\Translation\Translator;
|
||||||
use Symfony\Component\Translation\DataCollectorTranslator;
|
use Symfony\Component\Translation\DataCollectorTranslator;
|
||||||
use Symfony\Component\Translation\LoggingTranslator;
|
use Symfony\Component\Translation\LoggingTranslator;
|
||||||
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helps finding unused or missing translation messages in a given locale
|
* Helps finding unused or missing translation messages in a given locale
|
||||||
* and comparing them with the fallback ones.
|
* and comparing them with the fallback ones.
|
||||||
*
|
*
|
||||||
* @author Florian Voutzinos <florian@voutzinos.com>
|
* @author Florian Voutzinos <florian@voutzinos.com>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class TranslationDebugCommand extends ContainerAwareCommand
|
class TranslationDebugCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
|
private $translator;
|
||||||
|
private $loader;
|
||||||
|
private $extractor;
|
||||||
|
|
||||||
const MESSAGE_MISSING = 0;
|
const MESSAGE_MISSING = 0;
|
||||||
const MESSAGE_UNUSED = 1;
|
const MESSAGE_UNUSED = 1;
|
||||||
const MESSAGE_EQUALS_FALLBACK = 2;
|
const MESSAGE_EQUALS_FALLBACK = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TranslatorInterface $translator
|
||||||
|
* @param TranslationLoader $loader
|
||||||
|
* @param ExtractorInterface $extractor
|
||||||
|
*/
|
||||||
|
public function __construct($translator = null, TranslationLoader $loader = null, ExtractorInterface $extractor = null)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
if (!$translator instanceof TranslatorInterface) {
|
||||||
|
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$this->setName(null === $translator ? 'debug:translation' : $translator);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->translator = $translator;
|
||||||
|
$this->loader = $loader;
|
||||||
|
$this->extractor = $extractor;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -88,9 +118,14 @@ EOF
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* BC to be removed in 4.0
|
||||||
*/
|
*/
|
||||||
public function isEnabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
|
if (null !== $this->translator) {
|
||||||
|
return parent::isEnabled();
|
||||||
|
}
|
||||||
if (!class_exists('Symfony\Component\Translation\Translator')) {
|
if (!class_exists('Symfony\Component\Translation\Translator')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -103,14 +138,19 @@ EOF
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
// BC to be removed in 4.0
|
||||||
|
if (null === $this->translator) {
|
||||||
|
$this->translator = $this->getContainer()->get('translator');
|
||||||
|
$this->loader = $this->getContainer()->get('translation.loader');
|
||||||
|
$this->extractor = $this->getContainer()->get('translation.extractor');
|
||||||
|
}
|
||||||
|
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$locale = $input->getArgument('locale');
|
$locale = $input->getArgument('locale');
|
||||||
$domain = $input->getOption('domain');
|
$domain = $input->getOption('domain');
|
||||||
/** @var TranslationLoader $loader */
|
/** @var KernelInterface $kernel */
|
||||||
$loader = $this->getContainer()->get('translation.loader');
|
$kernel = $this->getApplication()->getKernel();
|
||||||
/** @var Kernel $kernel */
|
|
||||||
$kernel = $this->getContainer()->get('kernel');
|
|
||||||
|
|
||||||
// Define Root Path to App folder
|
// Define Root Path to App folder
|
||||||
$transPaths = array($kernel->getRootDir().'/Resources/');
|
$transPaths = array($kernel->getRootDir().'/Resources/');
|
||||||
@ -142,7 +182,7 @@ EOF
|
|||||||
$extractedCatalogue = $this->extractMessages($locale, $transPaths);
|
$extractedCatalogue = $this->extractMessages($locale, $transPaths);
|
||||||
|
|
||||||
// Load defined messages
|
// Load defined messages
|
||||||
$currentCatalogue = $this->loadCurrentMessages($locale, $transPaths, $loader);
|
$currentCatalogue = $this->loadCurrentMessages($locale, $transPaths);
|
||||||
|
|
||||||
// Merge defined and extracted messages to get all message ids
|
// Merge defined and extracted messages to get all message ids
|
||||||
$mergeOperation = new MergeOperation($extractedCatalogue, $currentCatalogue);
|
$mergeOperation = new MergeOperation($extractedCatalogue, $currentCatalogue);
|
||||||
@ -165,7 +205,7 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the fallback catalogues
|
// Load the fallback catalogues
|
||||||
$fallbackCatalogues = $this->loadFallbackCatalogues($locale, $transPaths, $loader);
|
$fallbackCatalogues = $this->loadFallbackCatalogues($locale, $transPaths);
|
||||||
|
|
||||||
// Display header line
|
// Display header line
|
||||||
$headers = array('State', 'Domain', 'Id', sprintf('Message Preview (%s)', $locale));
|
$headers = array('State', 'Domain', 'Id', sprintf('Message Preview (%s)', $locale));
|
||||||
@ -271,7 +311,7 @@ EOF
|
|||||||
foreach ($transPaths as $path) {
|
foreach ($transPaths as $path) {
|
||||||
$path = $path.'views';
|
$path = $path.'views';
|
||||||
if (is_dir($path)) {
|
if (is_dir($path)) {
|
||||||
$this->getContainer()->get('translation.extractor')->extract($path, $extractedCatalogue);
|
$this->extractor->extract($path, $extractedCatalogue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,17 +321,16 @@ EOF
|
|||||||
/**
|
/**
|
||||||
* @param string $locale
|
* @param string $locale
|
||||||
* @param array $transPaths
|
* @param array $transPaths
|
||||||
* @param TranslationLoader $loader
|
|
||||||
*
|
*
|
||||||
* @return MessageCatalogue
|
* @return MessageCatalogue
|
||||||
*/
|
*/
|
||||||
private function loadCurrentMessages($locale, $transPaths, TranslationLoader $loader)
|
private function loadCurrentMessages($locale, $transPaths)
|
||||||
{
|
{
|
||||||
$currentCatalogue = new MessageCatalogue($locale);
|
$currentCatalogue = new MessageCatalogue($locale);
|
||||||
foreach ($transPaths as $path) {
|
foreach ($transPaths as $path) {
|
||||||
$path = $path.'translations';
|
$path = $path.'translations';
|
||||||
if (is_dir($path)) {
|
if (is_dir($path)) {
|
||||||
$loader->loadMessages($path, $currentCatalogue);
|
$this->loader->loadMessages($path, $currentCatalogue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,16 +340,14 @@ EOF
|
|||||||
/**
|
/**
|
||||||
* @param string $locale
|
* @param string $locale
|
||||||
* @param array $transPaths
|
* @param array $transPaths
|
||||||
* @param TranslationLoader $loader
|
|
||||||
*
|
*
|
||||||
* @return MessageCatalogue[]
|
* @return MessageCatalogue[]
|
||||||
*/
|
*/
|
||||||
private function loadFallbackCatalogues($locale, $transPaths, TranslationLoader $loader)
|
private function loadFallbackCatalogues($locale, $transPaths)
|
||||||
{
|
{
|
||||||
$fallbackCatalogues = array();
|
$fallbackCatalogues = array();
|
||||||
$translator = $this->getContainer()->get('translator');
|
if ($this->translator instanceof Translator || $this->translator instanceof DataCollectorTranslator || $this->translator instanceof LoggingTranslator) {
|
||||||
if ($translator instanceof Translator || $translator instanceof DataCollectorTranslator || $translator instanceof LoggingTranslator) {
|
foreach ($this->translator->getFallbackLocales() as $fallbackLocale) {
|
||||||
foreach ($translator->getFallbackLocales() as $fallbackLocale) {
|
|
||||||
if ($fallbackLocale === $locale) {
|
if ($fallbackLocale === $locale) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -319,7 +356,7 @@ EOF
|
|||||||
foreach ($transPaths as $path) {
|
foreach ($transPaths as $path) {
|
||||||
$path = $path.'translations';
|
$path = $path.'translations';
|
||||||
if (is_dir($path)) {
|
if (is_dir($path)) {
|
||||||
$loader->loadMessages($path, $fallbackCatalogue);
|
$this->loader->loadMessages($path, $fallbackCatalogue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$fallbackCatalogues[] = $fallbackCatalogue;
|
$fallbackCatalogues[] = $fallbackCatalogue;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\Command;
|
namespace Symfony\Bundle\FrameworkBundle\Command;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
use Symfony\Component\Translation\Catalogue\TargetOperation;
|
use Symfony\Component\Translation\Catalogue\TargetOperation;
|
||||||
use Symfony\Component\Translation\Catalogue\MergeOperation;
|
use Symfony\Component\Translation\Catalogue\MergeOperation;
|
||||||
@ -18,16 +19,49 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Translation\Extractor\ExtractorInterface;
|
||||||
use Symfony\Component\Translation\MessageCatalogue;
|
use Symfony\Component\Translation\MessageCatalogue;
|
||||||
|
use Symfony\Component\Translation\Writer\TranslationWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A command that parses templates to extract translation messages and adds them
|
* A command that parses templates to extract translation messages and adds them
|
||||||
* into the translation files.
|
* into the translation files.
|
||||||
*
|
*
|
||||||
* @author Michel Salib <michelsalib@hotmail.com>
|
* @author Michel Salib <michelsalib@hotmail.com>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class TranslationUpdateCommand extends ContainerAwareCommand
|
class TranslationUpdateCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
|
private $writer;
|
||||||
|
private $loader;
|
||||||
|
private $extractor;
|
||||||
|
private $defaultLocale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TranslationWriter $writer
|
||||||
|
* @param TranslationLoader $loader
|
||||||
|
* @param ExtractorInterface $extractor
|
||||||
|
* @param string $defaultLocale
|
||||||
|
*/
|
||||||
|
public function __construct($writer = null, TranslationLoader $loader = null, ExtractorInterface $extractor = null, $defaultLocale = null)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
if (!$writer instanceof TranslationWriter) {
|
||||||
|
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$this->setName(null === $writer ? 'translation:update' : $writer);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->writer = $writer;
|
||||||
|
$this->loader = $loader;
|
||||||
|
$this->extractor = $extractor;
|
||||||
|
$this->defaultLocale = $defaultLocale;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -69,9 +103,14 @@ EOF
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* BC to be removed in 4.0
|
||||||
*/
|
*/
|
||||||
public function isEnabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
|
if (null !== $this->writer) {
|
||||||
|
return parent::isEnabled();
|
||||||
|
}
|
||||||
if (!class_exists('Symfony\Component\Translation\Translator')) {
|
if (!class_exists('Symfony\Component\Translation\Translator')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -84,6 +123,14 @@ EOF
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
// BC to be removed in 4.0
|
||||||
|
if (null === $this->writer) {
|
||||||
|
$this->writer = $this->getContainer()->get('translation.writer');
|
||||||
|
$this->loader = $this->getContainer()->get('translation.loader');
|
||||||
|
$this->extractor = $this->getContainer()->get('translation.extractor');
|
||||||
|
$this->defaultLocale = $this->getContainer()->getParameter('kernel.default_locale');
|
||||||
|
}
|
||||||
|
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
$errorIo = $io->getErrorStyle();
|
$errorIo = $io->getErrorStyle();
|
||||||
|
|
||||||
@ -95,14 +142,13 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check format
|
// check format
|
||||||
$writer = $this->getContainer()->get('translation.writer');
|
$supportedFormats = $this->writer->getFormats();
|
||||||
$supportedFormats = $writer->getFormats();
|
|
||||||
if (!in_array($input->getOption('output-format'), $supportedFormats)) {
|
if (!in_array($input->getOption('output-format'), $supportedFormats)) {
|
||||||
$errorIo->error(array('Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.'));
|
$errorIo->error(array('Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.'));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
$kernel = $this->getContainer()->get('kernel');
|
$kernel = $this->getApplication()->getKernel();
|
||||||
|
|
||||||
// Define Root Path to App folder
|
// Define Root Path to App folder
|
||||||
$transPaths = array($kernel->getRootDir().'/Resources/');
|
$transPaths = array($kernel->getRootDir().'/Resources/');
|
||||||
@ -134,29 +180,27 @@ EOF
|
|||||||
// load any messages from templates
|
// load any messages from templates
|
||||||
$extractedCatalogue = new MessageCatalogue($input->getArgument('locale'));
|
$extractedCatalogue = new MessageCatalogue($input->getArgument('locale'));
|
||||||
$errorIo->comment('Parsing templates...');
|
$errorIo->comment('Parsing templates...');
|
||||||
$extractor = $this->getContainer()->get('translation.extractor');
|
|
||||||
$prefix = $input->getOption('prefix');
|
$prefix = $input->getOption('prefix');
|
||||||
// @deprecated since version 3.4, to be removed in 4.0 along with the --no-prefix option
|
// @deprecated since version 3.4, to be removed in 4.0 along with the --no-prefix option
|
||||||
if ($input->getOption('no-prefix')) {
|
if ($input->getOption('no-prefix')) {
|
||||||
@trigger_error('The "--no-prefix" option is deprecated since version 3.4 and will be removed in 4.0. Use the "--prefix" option with an empty string as value instead.', E_USER_DEPRECATED);
|
@trigger_error('The "--no-prefix" option is deprecated since version 3.4 and will be removed in 4.0. Use the "--prefix" option with an empty string as value instead.', E_USER_DEPRECATED);
|
||||||
$prefix = '';
|
$prefix = '';
|
||||||
}
|
}
|
||||||
$extractor->setPrefix($prefix);
|
$this->extractor->setPrefix($prefix);
|
||||||
foreach ($transPaths as $path) {
|
foreach ($transPaths as $path) {
|
||||||
$path .= 'views';
|
$path .= 'views';
|
||||||
if (is_dir($path)) {
|
if (is_dir($path)) {
|
||||||
$extractor->extract($path, $extractedCatalogue);
|
$this->extractor->extract($path, $extractedCatalogue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// load any existing messages from the translation files
|
// load any existing messages from the translation files
|
||||||
$currentCatalogue = new MessageCatalogue($input->getArgument('locale'));
|
$currentCatalogue = new MessageCatalogue($input->getArgument('locale'));
|
||||||
$errorIo->comment('Loading translation files...');
|
$errorIo->comment('Loading translation files...');
|
||||||
$loader = $this->getContainer()->get('translation.loader');
|
|
||||||
foreach ($transPaths as $path) {
|
foreach ($transPaths as $path) {
|
||||||
$path .= 'translations';
|
$path .= 'translations';
|
||||||
if (is_dir($path)) {
|
if (is_dir($path)) {
|
||||||
$loader->loadMessages($path, $currentCatalogue);
|
$this->loader->loadMessages($path, $currentCatalogue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +257,7 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($input->getOption('no-backup') === true) {
|
if ($input->getOption('no-backup') === true) {
|
||||||
$writer->disableBackup();
|
$this->writer->disableBackup();
|
||||||
}
|
}
|
||||||
|
|
||||||
// save the files
|
// save the files
|
||||||
@ -232,7 +276,7 @@ EOF
|
|||||||
$bundleTransPath = end($transPaths).'translations';
|
$bundleTransPath = end($transPaths).'translations';
|
||||||
}
|
}
|
||||||
|
|
||||||
$writer->writeTranslations($operation->getResult(), $input->getOption('output-format'), array('path' => $bundleTransPath, 'default_locale' => $this->getContainer()->getParameter('kernel.default_locale')));
|
$this->writer->writeTranslations($operation->getResult(), $input->getOption('output-format'), array('path' => $bundleTransPath, 'default_locale' => $this->defaultLocale));
|
||||||
|
|
||||||
if (true === $input->getOption('dump-messages')) {
|
if (true === $input->getOption('dump-messages')) {
|
||||||
$resultMessage .= ' and translation files were updated';
|
$resultMessage .= ' and translation files were updated';
|
||||||
|
@ -20,9 +20,16 @@ use Symfony\Component\Workflow\Marking;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class WorkflowDumpCommand extends ContainerAwareCommand
|
class WorkflowDumpCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* BC to be removed in 4.0
|
||||||
|
*/
|
||||||
public function isEnabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
return $this->getContainer()->has('workflow.registry');
|
return $this->getContainer()->has('workflow.registry');
|
||||||
@ -56,7 +63,7 @@ EOF
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$container = $this->getContainer();
|
$container = $this->getApplication()->getKernel()->getContainer();
|
||||||
$serviceId = $input->getArgument('name');
|
$serviceId = $input->getArgument('name');
|
||||||
if ($container->has('workflow.'.$serviceId)) {
|
if ($container->has('workflow.'.$serviceId)) {
|
||||||
$workflow = $container->get('workflow.'.$serviceId);
|
$workflow = $container->get('workflow.'.$serviceId);
|
||||||
|
@ -22,6 +22,8 @@ use Symfony\Component\Translation\Command\XliffLintCommand as BaseLintCommand;
|
|||||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||||
* @author Robin Chalas <robin.chalas@gmail.com>
|
* @author Robin Chalas <robin.chalas@gmail.com>
|
||||||
* @author Javier Eguiluz <javier.eguiluz@gmail.com>
|
* @author Javier Eguiluz <javier.eguiluz@gmail.com>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class XliffLintCommand extends Command
|
class XliffLintCommand extends Command
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,8 @@ use Symfony\Component\Yaml\Command\LintCommand as BaseLintCommand;
|
|||||||
*
|
*
|
||||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||||
* @author Robin Chalas <robin.chalas@gmail.com>
|
* @author Robin Chalas <robin.chalas@gmail.com>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class YamlLintCommand extends Command
|
class YamlLintCommand extends Command
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,11 @@ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
|
|||||||
|
|
||||||
use Doctrine\Common\Annotations\Reader;
|
use Doctrine\Common\Annotations\Reader;
|
||||||
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
|
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Command\WorkflowDumpCommand;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
|
use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
|
||||||
@ -231,11 +236,7 @@ class FrameworkExtension extends Extension
|
|||||||
$this->registerCacheConfiguration($config['cache'], $container);
|
$this->registerCacheConfiguration($config['cache'], $container);
|
||||||
$this->registerWorkflowConfiguration($config['workflows'], $container, $loader);
|
$this->registerWorkflowConfiguration($config['workflows'], $container, $loader);
|
||||||
$this->registerDebugConfiguration($config['php_errors'], $container, $loader);
|
$this->registerDebugConfiguration($config['php_errors'], $container, $loader);
|
||||||
|
|
||||||
if ($this->isConfigEnabled($container, $config['router'])) {
|
|
||||||
$this->registerRouterConfiguration($config['router'], $container, $loader);
|
$this->registerRouterConfiguration($config['router'], $container, $loader);
|
||||||
}
|
|
||||||
|
|
||||||
$this->registerAnnotationsConfiguration($config['annotations'], $container, $loader);
|
$this->registerAnnotationsConfiguration($config['annotations'], $container, $loader);
|
||||||
$this->registerPropertyAccessConfiguration($config['property_access'], $container);
|
$this->registerPropertyAccessConfiguration($config['property_access'], $container);
|
||||||
|
|
||||||
@ -519,6 +520,10 @@ class FrameworkExtension extends Extension
|
|||||||
private function registerWorkflowConfiguration(array $workflows, ContainerBuilder $container, XmlFileLoader $loader)
|
private function registerWorkflowConfiguration(array $workflows, ContainerBuilder $container, XmlFileLoader $loader)
|
||||||
{
|
{
|
||||||
if (!$workflows) {
|
if (!$workflows) {
|
||||||
|
if (!class_exists(Workflow\Workflow::class)) {
|
||||||
|
$container->removeDefinition(WorkflowDumpCommand::class);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,6 +700,13 @@ class FrameworkExtension extends Extension
|
|||||||
*/
|
*/
|
||||||
private function registerRouterConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
|
private function registerRouterConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
|
||||||
{
|
{
|
||||||
|
if (!$this->isConfigEnabled($container, $config)) {
|
||||||
|
$container->removeDefinition(RouterDebugCommand::class);
|
||||||
|
$container->removeDefinition(RouterMatchCommand::class);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$loader->load('routing.xml');
|
$loader->load('routing.xml');
|
||||||
|
|
||||||
$container->setParameter('router.resource', $config['resource']);
|
$container->setParameter('router.resource', $config['resource']);
|
||||||
@ -1028,6 +1040,9 @@ class FrameworkExtension extends Extension
|
|||||||
private function registerTranslatorConfiguration(array $config, ContainerBuilder $container, LoaderInterface $loader)
|
private function registerTranslatorConfiguration(array $config, ContainerBuilder $container, LoaderInterface $loader)
|
||||||
{
|
{
|
||||||
if (!$this->isConfigEnabled($container, $config)) {
|
if (!$this->isConfigEnabled($container, $config)) {
|
||||||
|
$container->removeDefinition(TranslationDebugCommand::class);
|
||||||
|
$container->removeDefinition(TranslationUpdateCommand::class);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLan
|
|||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
|
||||||
use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
|
use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
|
||||||
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
|
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass;
|
use Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\AddCacheWarmerPass;
|
use Symfony\Component\HttpKernel\DependencyInjection\AddCacheWarmerPass;
|
||||||
@ -129,4 +130,9 @@ class FrameworkBundle extends Bundle
|
|||||||
$container->addCompilerPass(new $class(), $type, $priority);
|
$container->addCompilerPass(new $class(), $type, $priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function registerCommands(Application $application)
|
||||||
|
{
|
||||||
|
// noop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,11 +100,6 @@
|
|||||||
</call>
|
</call>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="cache.command.pool_pruner" class="Symfony\Bundle\FrameworkBundle\Command\CachePoolPruneCommand">
|
|
||||||
<argument type="iterator" />
|
|
||||||
<tag name="console.command" command="cache:pool:prune" />
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="cache.default_clearer" class="Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer" public="true">
|
<service id="cache.default_clearer" class="Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer" public="true">
|
||||||
<tag name="kernel.cache_clearer" />
|
<tag name="kernel.cache_clearer" />
|
||||||
</service>
|
</service>
|
||||||
|
@ -12,5 +12,89 @@
|
|||||||
<tag name="kernel.event_subscriber" />
|
<tag name="kernel.event_subscriber" />
|
||||||
<tag name="monolog.logger" channel="console" />
|
<tag name="monolog.logger" channel="console" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\AboutCommand">
|
||||||
|
<tag name="console.command" command="about" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\AssetsInstallCommand">
|
||||||
|
<argument type="service" id="filesystem" />
|
||||||
|
<tag name="console.command" command="assets:install" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand">
|
||||||
|
<argument type="service" id="cache_clearer" />
|
||||||
|
<argument type="service" id="filesystem" />
|
||||||
|
<tag name="console.command" command="cache:clear" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand">
|
||||||
|
<argument type="service" id="cache.global_clearer" />
|
||||||
|
<tag name="console.command" command="cache:pool:clear" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\CachePoolPruneCommand">
|
||||||
|
<argument type="iterator" />
|
||||||
|
<tag name="console.command" command="cache:pool:prune" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\CacheWarmupCommand">
|
||||||
|
<argument type="service" id="cache_warmer" />
|
||||||
|
<tag name="console.command" command="cache:warmup" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\ConfigDebugCommand">
|
||||||
|
<tag name="console.command" command="debug:config" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\ConfigDumpReferenceCommand">
|
||||||
|
<tag name="console.command" command="config:dump-reference" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\ContainerDebugCommand">
|
||||||
|
<tag name="console.command" command="debug:container" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\EventDispatcherDebugCommand">
|
||||||
|
<argument type="service" id="event_dispatcher" />
|
||||||
|
<tag name="console.command" command="debug:event-dispatcher" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand">
|
||||||
|
<argument type="service" id="router" />
|
||||||
|
<tag name="console.command" command="debug:router" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand">
|
||||||
|
<argument type="service" id="router" />
|
||||||
|
<tag name="console.command" command="router:match" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand">
|
||||||
|
<argument type="service" id="translator" />
|
||||||
|
<argument type="service" id="translation.loader" />
|
||||||
|
<argument type="service" id="translation.extractor" />
|
||||||
|
<tag name="console.command" command="debug:translation" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand">
|
||||||
|
<argument type="service" id="translation.writer" />
|
||||||
|
<argument type="service" id="translation.loader" />
|
||||||
|
<argument type="service" id="translation.extractor" />
|
||||||
|
<argument>%kernel.default_locale%</argument>
|
||||||
|
<tag name="console.command" command="translation:update" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\WorkflowDumpCommand">
|
||||||
|
<tag name="console.command" command="workflow:dump" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\XliffLintCommand">
|
||||||
|
<tag name="console.command" command="lint:xliff" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\FrameworkBundle\Command\YamlLintCommand">
|
||||||
|
<tag name="console.command" command="lint:yaml" />
|
||||||
|
</service>
|
||||||
</services>
|
</services>
|
||||||
</container>
|
</container>
|
||||||
|
@ -47,20 +47,34 @@ class RouterDebugCommandTest extends TestCase
|
|||||||
$this->createCommandTester()->execute(array('name' => 'test'));
|
$this->createCommandTester()->execute(array('name' => 'test'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
* @expectedDeprecation Passing a command name as the first argument of "Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand::__construct" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.
|
||||||
|
*/
|
||||||
|
public function testLegacyDebugCommand()
|
||||||
|
{
|
||||||
|
$application = new Application($this->getKernel());
|
||||||
|
$application->add(new RouterDebugCommand());
|
||||||
|
|
||||||
|
$tester = new CommandTester($application->find('debug:router'));
|
||||||
|
|
||||||
|
$tester->execute(array());
|
||||||
|
|
||||||
|
$this->assertRegExp('/foo\s+ANY\s+ANY\s+ANY\s+\\/foo/', $tester->getDisplay());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return CommandTester
|
* @return CommandTester
|
||||||
*/
|
*/
|
||||||
private function createCommandTester()
|
private function createCommandTester()
|
||||||
{
|
{
|
||||||
$application = new Application($this->getKernel());
|
$application = new Application($this->getKernel());
|
||||||
|
$application->add(new RouterDebugCommand($this->getRouter()));
|
||||||
$command = new RouterDebugCommand();
|
|
||||||
$application->add($command);
|
|
||||||
|
|
||||||
return new CommandTester($application->find('debug:router'));
|
return new CommandTester($application->find('debug:router'));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getKernel()
|
private function getRouter()
|
||||||
{
|
{
|
||||||
$routeCollection = new RouteCollection();
|
$routeCollection = new RouteCollection();
|
||||||
$routeCollection->add('foo', new Route('foo'));
|
$routeCollection->add('foo', new Route('foo'));
|
||||||
@ -68,9 +82,13 @@ class RouterDebugCommandTest extends TestCase
|
|||||||
$router
|
$router
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getRouteCollection')
|
->method('getRouteCollection')
|
||||||
->will($this->returnValue($routeCollection))
|
->will($this->returnValue($routeCollection));
|
||||||
;
|
|
||||||
|
|
||||||
|
return $router;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getKernel()
|
||||||
|
{
|
||||||
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
||||||
$container
|
$container
|
||||||
->expects($this->atLeastOnce())
|
->expects($this->atLeastOnce())
|
||||||
@ -87,7 +105,7 @@ class RouterDebugCommandTest extends TestCase
|
|||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->with('router')
|
->with('router')
|
||||||
->willReturn($router)
|
->willReturn($this->getRouter())
|
||||||
;
|
;
|
||||||
|
|
||||||
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
||||||
|
@ -42,18 +42,36 @@ class RouterMatchCommandTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return CommandTester
|
* @group legacy
|
||||||
|
* @expectedDeprecation Passing a command name as the first argument of "Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand::__construct" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.
|
||||||
|
* @expectedDeprecation Passing a command name as the first argument of "Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand::__construct" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.
|
||||||
*/
|
*/
|
||||||
private function createCommandTester()
|
public function testLegacyMatchCommand()
|
||||||
{
|
{
|
||||||
$application = new Application($this->getKernel());
|
$application = new Application($this->getKernel());
|
||||||
$application->add(new RouterMatchCommand());
|
$application->add(new RouterMatchCommand());
|
||||||
$application->add(new RouterDebugCommand());
|
$application->add(new RouterDebugCommand());
|
||||||
|
|
||||||
|
$tester = new CommandTester($application->find('router:match'));
|
||||||
|
|
||||||
|
$tester->execute(array('path_info' => '/'));
|
||||||
|
|
||||||
|
$this->assertContains('None of the routes match the path "/"', $tester->getDisplay());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return CommandTester
|
||||||
|
*/
|
||||||
|
private function createCommandTester()
|
||||||
|
{
|
||||||
|
$application = new Application($this->getKernel());
|
||||||
|
$application->add(new RouterMatchCommand($this->getRouter()));
|
||||||
|
$application->add(new RouterDebugCommand($this->getRouter()));
|
||||||
|
|
||||||
return new CommandTester($application->find('router:match'));
|
return new CommandTester($application->find('router:match'));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getKernel()
|
private function getRouter()
|
||||||
{
|
{
|
||||||
$routeCollection = new RouteCollection();
|
$routeCollection = new RouteCollection();
|
||||||
$routeCollection->add('foo', new Route('foo'));
|
$routeCollection->add('foo', new Route('foo'));
|
||||||
@ -62,14 +80,17 @@ class RouterMatchCommandTest extends TestCase
|
|||||||
$router
|
$router
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getRouteCollection')
|
->method('getRouteCollection')
|
||||||
->will($this->returnValue($routeCollection))
|
->will($this->returnValue($routeCollection));
|
||||||
;
|
|
||||||
$router
|
$router
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getContext')
|
->method('getContext')
|
||||||
->will($this->returnValue($requestContext))
|
->will($this->returnValue($requestContext));
|
||||||
;
|
|
||||||
|
|
||||||
|
return $router;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getKernel()
|
||||||
|
{
|
||||||
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
||||||
$container
|
$container
|
||||||
->expects($this->atLeastOnce())
|
->expects($this->atLeastOnce())
|
||||||
@ -85,7 +106,9 @@ class RouterMatchCommandTest extends TestCase
|
|||||||
$container
|
$container
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->willReturn($router);
|
->with('router')
|
||||||
|
->willReturn($this->getRouter())
|
||||||
|
;
|
||||||
|
|
||||||
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
||||||
$kernel
|
$kernel
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
|
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand;
|
use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
@ -24,7 +24,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
|
|
||||||
public function testDebugMissingMessages()
|
public function testDebugMissingMessages()
|
||||||
{
|
{
|
||||||
$tester = $this->createCommandTester($this->getContainer(array('foo' => 'foo')));
|
$tester = $this->createCommandTester(array('foo' => 'foo'));
|
||||||
$tester->execute(array('locale' => 'en', 'bundle' => 'foo'));
|
$tester->execute(array('locale' => 'en', 'bundle' => 'foo'));
|
||||||
|
|
||||||
$this->assertRegExp('/missing/', $tester->getDisplay());
|
$this->assertRegExp('/missing/', $tester->getDisplay());
|
||||||
@ -32,7 +32,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
|
|
||||||
public function testDebugUnusedMessages()
|
public function testDebugUnusedMessages()
|
||||||
{
|
{
|
||||||
$tester = $this->createCommandTester($this->getContainer(array(), array('foo' => 'foo')));
|
$tester = $this->createCommandTester(array(), array('foo' => 'foo'));
|
||||||
$tester->execute(array('locale' => 'en', 'bundle' => 'foo'));
|
$tester->execute(array('locale' => 'en', 'bundle' => 'foo'));
|
||||||
|
|
||||||
$this->assertRegExp('/unused/', $tester->getDisplay());
|
$this->assertRegExp('/unused/', $tester->getDisplay());
|
||||||
@ -40,7 +40,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
|
|
||||||
public function testDebugFallbackMessages()
|
public function testDebugFallbackMessages()
|
||||||
{
|
{
|
||||||
$tester = $this->createCommandTester($this->getContainer(array(), array('foo' => 'foo')));
|
$tester = $this->createCommandTester(array(), array('foo' => 'foo'));
|
||||||
$tester->execute(array('locale' => 'fr', 'bundle' => 'foo'));
|
$tester->execute(array('locale' => 'fr', 'bundle' => 'foo'));
|
||||||
|
|
||||||
$this->assertRegExp('/fallback/', $tester->getDisplay());
|
$this->assertRegExp('/fallback/', $tester->getDisplay());
|
||||||
@ -48,7 +48,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
|
|
||||||
public function testNoDefinedMessages()
|
public function testNoDefinedMessages()
|
||||||
{
|
{
|
||||||
$tester = $this->createCommandTester($this->getContainer());
|
$tester = $this->createCommandTester();
|
||||||
$tester->execute(array('locale' => 'fr', 'bundle' => 'test'));
|
$tester->execute(array('locale' => 'fr', 'bundle' => 'test'));
|
||||||
|
|
||||||
$this->assertRegExp('/No defined or extracted messages for locale "fr"/', $tester->getDisplay());
|
$this->assertRegExp('/No defined or extracted messages for locale "fr"/', $tester->getDisplay());
|
||||||
@ -56,7 +56,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
|
|
||||||
public function testDebugDefaultDirectory()
|
public function testDebugDefaultDirectory()
|
||||||
{
|
{
|
||||||
$tester = $this->createCommandTester($this->getContainer(array('foo' => 'foo'), array('bar' => 'bar')));
|
$tester = $this->createCommandTester(array('foo' => 'foo'), array('bar' => 'bar'));
|
||||||
$tester->execute(array('locale' => 'en'));
|
$tester->execute(array('locale' => 'en'));
|
||||||
|
|
||||||
$this->assertRegExp('/missing/', $tester->getDisplay());
|
$this->assertRegExp('/missing/', $tester->getDisplay());
|
||||||
@ -71,7 +71,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
->with($this->equalTo($this->translationDir))
|
->with($this->equalTo($this->translationDir))
|
||||||
->willThrowException(new \InvalidArgumentException());
|
->willThrowException(new \InvalidArgumentException());
|
||||||
|
|
||||||
$tester = $this->createCommandTester($this->getContainer(array('foo' => 'foo'), array('bar' => 'bar'), $kernel));
|
$tester = $this->createCommandTester(array('foo' => 'foo'), array('bar' => 'bar'), $kernel);
|
||||||
$tester->execute(array('locale' => 'en', 'bundle' => $this->translationDir));
|
$tester->execute(array('locale' => 'en', 'bundle' => $this->translationDir));
|
||||||
|
|
||||||
$this->assertRegExp('/missing/', $tester->getDisplay());
|
$this->assertRegExp('/missing/', $tester->getDisplay());
|
||||||
@ -89,7 +89,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
->with($this->equalTo('dir'))
|
->with($this->equalTo('dir'))
|
||||||
->will($this->throwException(new \InvalidArgumentException()));
|
->will($this->throwException(new \InvalidArgumentException()));
|
||||||
|
|
||||||
$tester = $this->createCommandTester($this->getContainer(array(), array(), $kernel));
|
$tester = $this->createCommandTester(array(), array(), $kernel);
|
||||||
$tester->execute(array('locale' => 'en', 'bundle' => 'dir'));
|
$tester->execute(array('locale' => 'en', 'bundle' => 'dir'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,18 +109,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @return CommandTester
|
* @return CommandTester
|
||||||
*/
|
*/
|
||||||
private function createCommandTester($container)
|
private function createCommandTester($extractedMessages = array(), $loadedMessages = array(), $kernel = null)
|
||||||
{
|
|
||||||
$command = new TranslationDebugCommand();
|
|
||||||
$command->setContainer($container);
|
|
||||||
|
|
||||||
$application = new Application();
|
|
||||||
$application->add($command);
|
|
||||||
|
|
||||||
return new CommandTester($application->find('debug:translation'));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getContainer($extractedMessages = array(), $loadedMessages = array(), $kernel = null)
|
|
||||||
{
|
{
|
||||||
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
|
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
@ -167,6 +156,41 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
->method('getRootDir')
|
->method('getRootDir')
|
||||||
->will($this->returnValue($this->translationDir));
|
->will($this->returnValue($this->translationDir));
|
||||||
|
|
||||||
|
$kernel
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getBundles')
|
||||||
|
->will($this->returnValue(array()));
|
||||||
|
|
||||||
|
$kernel
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getContainer')
|
||||||
|
->will($this->returnValue($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock()));
|
||||||
|
|
||||||
|
$command = new TranslationDebugCommand($translator, $loader, $extractor);
|
||||||
|
|
||||||
|
$application = new Application($kernel);
|
||||||
|
$application->add($command);
|
||||||
|
|
||||||
|
return new CommandTester($application->find('debug:translation'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
* @expectedDeprecation Passing a command name as the first argument of "Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand::__construct" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.
|
||||||
|
*/
|
||||||
|
public function testLegacyDebugCommand()
|
||||||
|
{
|
||||||
|
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
|
||||||
|
$loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader')->getMock();
|
||||||
|
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||||
|
$kernel
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getBundles')
|
||||||
|
->will($this->returnValue(array()));
|
||||||
|
|
||||||
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
||||||
$container
|
$container
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
@ -178,7 +202,21 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
array('kernel', 1, $kernel),
|
array('kernel', 1, $kernel),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
return $container;
|
$kernel
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getContainer')
|
||||||
|
->will($this->returnValue($container));
|
||||||
|
|
||||||
|
$command = new TranslationDebugCommand();
|
||||||
|
$command->setContainer($container);
|
||||||
|
|
||||||
|
$application = new Application($kernel);
|
||||||
|
$application->add($command);
|
||||||
|
|
||||||
|
$tester = new CommandTester($application->find('debug:translation'));
|
||||||
|
$tester->execute(array('locale' => 'en'));
|
||||||
|
|
||||||
|
$this->assertContains('No defined or extracted', $tester->getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getBundle($path)
|
private function getBundle($path)
|
||||||
|
@ -12,11 +12,10 @@
|
|||||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
|
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand;
|
use Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use Symfony\Component\DependencyInjection;
|
|
||||||
use Symfony\Component\HttpKernel;
|
use Symfony\Component\HttpKernel;
|
||||||
|
|
||||||
class TranslationUpdateCommandTest extends TestCase
|
class TranslationUpdateCommandTest extends TestCase
|
||||||
@ -26,7 +25,7 @@ class TranslationUpdateCommandTest extends TestCase
|
|||||||
|
|
||||||
public function testDumpMessagesAndClean()
|
public function testDumpMessagesAndClean()
|
||||||
{
|
{
|
||||||
$tester = $this->createCommandTester($this->getContainer(array('messages' => array('foo' => 'foo'))));
|
$tester = $this->createCommandTester(array('messages' => array('foo' => 'foo')));
|
||||||
$tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true));
|
$tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true));
|
||||||
$this->assertRegExp('/foo/', $tester->getDisplay());
|
$this->assertRegExp('/foo/', $tester->getDisplay());
|
||||||
$this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay());
|
$this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay());
|
||||||
@ -34,7 +33,7 @@ class TranslationUpdateCommandTest extends TestCase
|
|||||||
|
|
||||||
public function testDumpTwoMessagesAndClean()
|
public function testDumpTwoMessagesAndClean()
|
||||||
{
|
{
|
||||||
$tester = $this->createCommandTester($this->getContainer(array('messages' => array('foo' => 'foo', 'bar' => 'bar'))));
|
$tester = $this->createCommandTester(array('messages' => array('foo' => 'foo', 'bar' => 'bar')));
|
||||||
$tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true));
|
$tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true));
|
||||||
$this->assertRegExp('/foo/', $tester->getDisplay());
|
$this->assertRegExp('/foo/', $tester->getDisplay());
|
||||||
$this->assertRegExp('/bar/', $tester->getDisplay());
|
$this->assertRegExp('/bar/', $tester->getDisplay());
|
||||||
@ -43,7 +42,7 @@ class TranslationUpdateCommandTest extends TestCase
|
|||||||
|
|
||||||
public function testDumpMessagesForSpecificDomain()
|
public function testDumpMessagesForSpecificDomain()
|
||||||
{
|
{
|
||||||
$tester = $this->createCommandTester($this->getContainer(array('messages' => array('foo' => 'foo'), 'mydomain' => array('bar' => 'bar'))));
|
$tester = $this->createCommandTester(array('messages' => array('foo' => 'foo'), 'mydomain' => array('bar' => 'bar')));
|
||||||
$tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--domain' => 'mydomain'));
|
$tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--domain' => 'mydomain'));
|
||||||
$this->assertRegExp('/bar/', $tester->getDisplay());
|
$this->assertRegExp('/bar/', $tester->getDisplay());
|
||||||
$this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay());
|
$this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay());
|
||||||
@ -51,14 +50,14 @@ class TranslationUpdateCommandTest extends TestCase
|
|||||||
|
|
||||||
public function testWriteMessages()
|
public function testWriteMessages()
|
||||||
{
|
{
|
||||||
$tester = $this->createCommandTester($this->getContainer(array('messages' => array('foo' => 'foo'))));
|
$tester = $this->createCommandTester(array('messages' => array('foo' => 'foo')));
|
||||||
$tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true));
|
$tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true));
|
||||||
$this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay());
|
$this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWriteMessagesForSpecificDomain()
|
public function testWriteMessagesForSpecificDomain()
|
||||||
{
|
{
|
||||||
$tester = $this->createCommandTester($this->getContainer(array('messages' => array('foo' => 'foo'), 'mydomain' => array('bar' => 'bar'))));
|
$tester = $this->createCommandTester(array('messages' => array('foo' => 'foo'), 'mydomain' => array('bar' => 'bar')));
|
||||||
$tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true, '--domain' => 'mydomain'));
|
$tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true, '--domain' => 'mydomain'));
|
||||||
$this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay());
|
$this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay());
|
||||||
}
|
}
|
||||||
@ -79,18 +78,7 @@ class TranslationUpdateCommandTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @return CommandTester
|
* @return CommandTester
|
||||||
*/
|
*/
|
||||||
private function createCommandTester(DependencyInjection\ContainerInterface $container)
|
private function createCommandTester($extractedMessages = array(), $loadedMessages = array(), HttpKernel\KernelInterface $kernel = null)
|
||||||
{
|
|
||||||
$command = new TranslationUpdateCommand();
|
|
||||||
$command->setContainer($container);
|
|
||||||
|
|
||||||
$application = new Application();
|
|
||||||
$application->add($command);
|
|
||||||
|
|
||||||
return new CommandTester($application->find('translation:update'));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getContainer($extractedMessages = array(), $loadedMessages = array(), HttpKernel\KernelInterface $kernel = null)
|
|
||||||
{
|
{
|
||||||
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
|
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
@ -147,6 +135,42 @@ class TranslationUpdateCommandTest extends TestCase
|
|||||||
->method('getRootDir')
|
->method('getRootDir')
|
||||||
->will($this->returnValue($this->translationDir));
|
->will($this->returnValue($this->translationDir));
|
||||||
|
|
||||||
|
$kernel
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getBundles')
|
||||||
|
->will($this->returnValue(array()));
|
||||||
|
|
||||||
|
$kernel
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getContainer')
|
||||||
|
->will($this->returnValue($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock()));
|
||||||
|
|
||||||
|
$command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en');
|
||||||
|
|
||||||
|
$application = new Application($kernel);
|
||||||
|
$application->add($command);
|
||||||
|
|
||||||
|
return new CommandTester($application->find('translation:update'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
* @expectedDeprecation Passing a command name as the first argument of "Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand::__construct" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.
|
||||||
|
*/
|
||||||
|
public function testLegacyUpdateCommand()
|
||||||
|
{
|
||||||
|
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
|
||||||
|
$loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader')->getMock();
|
||||||
|
$writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock();
|
||||||
|
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||||
|
$kernel
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getBundles')
|
||||||
|
->will($this->returnValue(array()));
|
||||||
|
|
||||||
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
||||||
$container
|
$container
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
@ -159,7 +183,21 @@ class TranslationUpdateCommandTest extends TestCase
|
|||||||
array('kernel', 1, $kernel),
|
array('kernel', 1, $kernel),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
return $container;
|
$kernel
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getContainer')
|
||||||
|
->will($this->returnValue($container));
|
||||||
|
|
||||||
|
$command = new TranslationUpdateCommand();
|
||||||
|
$command->setContainer($container);
|
||||||
|
|
||||||
|
$application = new Application($kernel);
|
||||||
|
$application->add($command);
|
||||||
|
|
||||||
|
$tester = new CommandTester($application->find('translation:update'));
|
||||||
|
$tester->execute(array('locale' => 'en'));
|
||||||
|
|
||||||
|
$this->assertContains('You must choose one of --force or --dump-messages', $tester->getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getBundle($path)
|
private function getBundle($path)
|
||||||
|
@ -977,6 +977,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
'kernel.bundles' => array('FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'),
|
'kernel.bundles' => array('FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'),
|
||||||
'kernel.bundles_metadata' => array('FrameworkBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle', 'path' => __DIR__.'/../..', 'parent' => null)),
|
'kernel.bundles_metadata' => array('FrameworkBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle', 'path' => __DIR__.'/../..', 'parent' => null)),
|
||||||
'kernel.cache_dir' => __DIR__,
|
'kernel.cache_dir' => __DIR__,
|
||||||
|
'kernel.project_dir' => __DIR__,
|
||||||
'kernel.debug' => false,
|
'kernel.debug' => false,
|
||||||
'kernel.environment' => 'test',
|
'kernel.environment' => 'test',
|
||||||
'kernel.name' => 'kernel',
|
'kernel.name' => 'kernel',
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
|
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand;
|
use Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,11 +75,28 @@ class CachePoolClearCommandTest extends WebTestCase
|
|||||||
->execute(array('pools' => array('unknown_pool')), array('decorated' => false));
|
->execute(array('pools' => array('unknown_pool')), array('decorated' => false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
* @expectedDeprecation Passing a command name as the first argument of "Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand::__construct" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.
|
||||||
|
*/
|
||||||
|
public function testLegacyClearCommand()
|
||||||
|
{
|
||||||
|
$application = new Application(static::$kernel);
|
||||||
|
$application->add(new CachePoolClearCommand());
|
||||||
|
|
||||||
|
$tester = new CommandTester($application->find('cache:pool:clear'));
|
||||||
|
|
||||||
|
$tester->execute(array('pools' => array()));
|
||||||
|
|
||||||
|
$this->assertContains('Cache was successfully cleared', $tester->getDisplay());
|
||||||
|
}
|
||||||
|
|
||||||
private function createCommandTester()
|
private function createCommandTester()
|
||||||
{
|
{
|
||||||
$command = new CachePoolClearCommand();
|
$container = static::$kernel->getContainer();
|
||||||
$command->setContainer(static::$kernel->getContainer());
|
$application = new Application(static::$kernel);
|
||||||
|
$application->add(new CachePoolClearCommand($container->get('cache.global_clearer')));
|
||||||
|
|
||||||
return new CommandTester($command);
|
return new CommandTester($application->find('cache:pool:clear'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@ use Doctrine\DBAL\Schema\SchemaException;
|
|||||||
* Installs the tables required by the ACL system.
|
* Installs the tables required by the ACL system.
|
||||||
*
|
*
|
||||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class InitAclCommand extends ContainerAwareCommand
|
class InitAclCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,8 @@ use Symfony\Component\Security\Acl\Model\MutableAclProviderInterface;
|
|||||||
* Sets ACL for objects.
|
* Sets ACL for objects.
|
||||||
*
|
*
|
||||||
* @author Kévin Dunglas <kevin@les-tilleuls.coop>
|
* @author Kévin Dunglas <kevin@les-tilleuls.coop>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class SetAclCommand extends ContainerAwareCommand
|
class SetAclCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,8 @@ use Symfony\Component\Security\Core\User\User;
|
|||||||
* Encode a user's password.
|
* Encode a user's password.
|
||||||
*
|
*
|
||||||
* @author Sarah Khalil <mkhalil.sarah@gmail.com>
|
* @author Sarah Khalil <mkhalil.sarah@gmail.com>
|
||||||
|
*
|
||||||
|
* @final since version 3.4
|
||||||
*/
|
*/
|
||||||
class UserPasswordEncoderCommand extends ContainerAwareCommand
|
class UserPasswordEncoderCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
@ -46,18 +48,6 @@ class UserPasswordEncoderCommand extends ContainerAwareCommand
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @deprecated since version 3.3, to be removed in 4.0
|
|
||||||
*/
|
|
||||||
protected function getContainer()
|
|
||||||
{
|
|
||||||
@trigger_error(sprintf('Method "%s" is deprecated since version 3.3 and "%s" won\'t extend "%s" nor implement "%s" anymore in 4.0.', __METHOD__, __CLASS__, ContainerAwareCommand::class, ContainerAwareInterface::class), E_USER_DEPRECATED);
|
|
||||||
|
|
||||||
return parent::getContainer();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -125,7 +115,7 @@ EOF
|
|||||||
$userClass = $this->getUserClass($input, $io);
|
$userClass = $this->getUserClass($input, $io);
|
||||||
$emptySalt = $input->getOption('empty-salt');
|
$emptySalt = $input->getOption('empty-salt');
|
||||||
|
|
||||||
$encoderFactory = $this->encoderFactory ?: parent::getContainer()->get('security.encoder_factory');
|
$encoderFactory = $this->encoderFactory ?: $this->getContainer()->get('security.encoder_factory');
|
||||||
$encoder = $encoderFactory->getEncoder($userClass);
|
$encoder = $encoderFactory->getEncoder($userClass);
|
||||||
$bcryptWithoutEmptySalt = !$emptySalt && $encoder instanceof BCryptPasswordEncoder;
|
$bcryptWithoutEmptySalt = !$emptySalt && $encoder instanceof BCryptPasswordEncoder;
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\SecurityBundle\DependencyInjection;
|
namespace Symfony\Bundle\SecurityBundle\DependencyInjection;
|
||||||
|
|
||||||
|
use Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand;
|
||||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
|
||||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface;
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface;
|
||||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||||
@ -107,7 +108,7 @@ class SecurityExtension extends Extension
|
|||||||
|
|
||||||
if (class_exists(Application::class)) {
|
if (class_exists(Application::class)) {
|
||||||
$loader->load('console.xml');
|
$loader->load('console.xml');
|
||||||
$container->getDefinition('security.console.user_password_encoder_command')->replaceArgument(1, array_keys($config['encoders']));
|
$container->getDefinition(UserPasswordEncoderCommand::class)->replaceArgument(1, array_keys($config['encoders']));
|
||||||
}
|
}
|
||||||
|
|
||||||
// load ACL
|
// load ACL
|
||||||
|
@ -7,7 +7,15 @@
|
|||||||
<services>
|
<services>
|
||||||
<defaults public="false" />
|
<defaults public="false" />
|
||||||
|
|
||||||
<service id="security.console.user_password_encoder_command" class="Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand">
|
<service id="Symfony\Bundle\SecurityBundle\Command\InitAclCommand">
|
||||||
|
<tag name="console.command" command="init:acl" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\SecurityBundle\Command\SetAclCommand">
|
||||||
|
<tag name="console.command" command="acl:set" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand">
|
||||||
<argument type="service" id="security.encoder_factory"/>
|
<argument type="service" id="security.encoder_factory"/>
|
||||||
<argument type="collection" /> <!-- encoders' user classes -->
|
<argument type="collection" /> <!-- encoders' user classes -->
|
||||||
<tag name="console.command" command="security:encode-password" />
|
<tag name="console.command" command="security:encode-password" />
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Bundle\SecurityBundle;
|
namespace Symfony\Bundle\SecurityBundle;
|
||||||
|
|
||||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\JsonLoginFactory;
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\JsonLoginFactory;
|
||||||
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddSecurityVotersPass;
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddSecurityVotersPass;
|
||||||
@ -58,4 +59,9 @@ class SecurityBundle extends Bundle
|
|||||||
$extension->addUserProviderFactory(new LdapFactory());
|
$extension->addUserProviderFactory(new LdapFactory());
|
||||||
$container->addCompilerPass(new AddSecurityVotersPass());
|
$container->addCompilerPass(new AddSecurityVotersPass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function registerCommands(Application $application)
|
||||||
|
{
|
||||||
|
// noop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
|
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand;
|
||||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
||||||
@ -355,7 +356,7 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||||||
|
|
||||||
public function testUserPasswordEncoderCommandIsRegistered()
|
public function testUserPasswordEncoderCommandIsRegistered()
|
||||||
{
|
{
|
||||||
$this->assertTrue($this->getContainer('remember_me_options')->has('security.console.user_password_encoder_command'));
|
$this->assertTrue($this->getContainer('remember_me_options')->has(UserPasswordEncoderCommand::class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultAccessDecisionManagerStrategyIsAffirmative()
|
public function testDefaultAccessDecisionManagerStrategyIsAffirmative()
|
||||||
|
@ -7,19 +7,14 @@
|
|||||||
<services>
|
<services>
|
||||||
<defaults public="false" />
|
<defaults public="false" />
|
||||||
|
|
||||||
<service id="twig.command.debug" class="Symfony\Bridge\Twig\Command\DebugCommand">
|
<service id="Symfony\Bridge\Twig\Command\DebugCommand">
|
||||||
<argument type="service" id="twig" />
|
<argument type="service" id="twig" />
|
||||||
<tag name="console.command" command="debug:twig" />
|
<tag name="console.command" command="debug:twig" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="twig.command.lint" class="Symfony\Bundle\TwigBundle\Command\LintCommand">
|
<service id="Symfony\Bundle\TwigBundle\Command\LintCommand">
|
||||||
<argument type="service" id="twig" />
|
<argument type="service" id="twig" />
|
||||||
<tag name="console.command" command="lint:twig" />
|
<tag name="console.command" command="lint:twig" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- BC to be removed in 4.0 -->
|
|
||||||
<service id="console.command.symfony_bundle_twigbundle_command_debugcommand" class="Symfony\Bundle\TwigBundle\Command\DebugCommand" public="true">
|
|
||||||
<deprecated>The "%service_id%" service is deprecated since Symfony 3.4 and will be removed in 4.0. Use "twig.command.debug" instead.</deprecated>
|
|
||||||
</service>
|
|
||||||
</services>
|
</services>
|
||||||
</container>
|
</container>
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\TwigBundle;
|
namespace Symfony\Bundle\TwigBundle;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||||
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
|
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
@ -37,4 +38,9 @@ class TwigBundle extends Bundle
|
|||||||
$container->addCompilerPass(new ExceptionListenerPass());
|
$container->addCompilerPass(new ExceptionListenerPass());
|
||||||
$container->addCompilerPass(new RuntimeLoaderPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
$container->addCompilerPass(new RuntimeLoaderPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function registerCommands(Application $application)
|
||||||
|
{
|
||||||
|
// noop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user