initial commit
This commit is contained in:
77
vendor/symfony/maker-bundle/src/DependencyInjection/CompilerPass/MakeCommandRegistrationPass.php
vendored
Normal file
77
vendor/symfony/maker-bundle/src/DependencyInjection/CompilerPass/MakeCommandRegistrationPass.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony MakerBundle package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\MakerBundle\DependencyInjection\CompilerPass;
|
||||
|
||||
use Symfony\Bundle\MakerBundle\Command\MakerCommand;
|
||||
use Symfony\Bundle\MakerBundle\MakerInterface;
|
||||
use Symfony\Bundle\MakerBundle\Str;
|
||||
use Symfony\Component\Console\Command\LazyCommand;
|
||||
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class MakeCommandRegistrationPass implements CompilerPassInterface
|
||||
{
|
||||
public const MAKER_TAG = 'maker.command';
|
||||
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
foreach ($container->findTaggedServiceIds(self::MAKER_TAG) as $id => $tags) {
|
||||
$def = $container->getDefinition($id);
|
||||
if ($def->isDeprecated()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = $container->getParameterBag()->resolveValue($def->getClass());
|
||||
if (!is_subclass_of($class, MakerInterface::class)) {
|
||||
throw new InvalidArgumentException(\sprintf('Service "%s" must implement interface "%s".', $id, MakerInterface::class));
|
||||
}
|
||||
|
||||
$commandDefinition = new ChildDefinition('maker.auto_command.abstract');
|
||||
$commandDefinition->setClass(MakerCommand::class);
|
||||
$commandDefinition->replaceArgument(0, new Reference($id));
|
||||
|
||||
$tagAttributes = ['command' => $class::getCommandName()];
|
||||
|
||||
if (!method_exists($class, 'getCommandDescription')) {
|
||||
// no-op
|
||||
} elseif (class_exists(LazyCommand::class)) {
|
||||
$tagAttributes['description'] = $class::getCommandDescription();
|
||||
} else {
|
||||
$commandDefinition->addMethodCall('setDescription', [$class::getCommandDescription()]);
|
||||
}
|
||||
|
||||
$commandDefinition->addTag('console.command', $tagAttributes);
|
||||
|
||||
/*
|
||||
* @deprecated remove this block when removing make:unit-test and make:functional-test
|
||||
*/
|
||||
if (method_exists($class, 'getCommandAliases')) {
|
||||
foreach ($class::getCommandAliases() as $alias) {
|
||||
$commandDefinition->addTag('console.command', ['command' => $alias, 'description' => 'Deprecated alias of "make:test"']);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @deprecated remove this block when removing make:subscriber
|
||||
*/
|
||||
if (method_exists($class, 'getCommandAlias')) {
|
||||
$alias = $class::getCommandAlias();
|
||||
$commandDefinition->addTag('console.command', ['command' => $alias, 'description' => 'Deprecated alias of "make:listener"']);
|
||||
}
|
||||
|
||||
$container->setDefinition(\sprintf('maker.auto_command.%s', Str::asTwigVariable($class::getCommandName())), $commandDefinition);
|
||||
}
|
||||
}
|
||||
}
|
||||
31
vendor/symfony/maker-bundle/src/DependencyInjection/CompilerPass/RemoveMissingParametersPass.php
vendored
Normal file
31
vendor/symfony/maker-bundle/src/DependencyInjection/CompilerPass/RemoveMissingParametersPass.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony MakerBundle package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\MakerBundle\DependencyInjection\CompilerPass;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* Removes injected parameter arguments if they don't exist in this app.
|
||||
*
|
||||
* @author Ryan Weaver <ryan@symfonycasts.com>
|
||||
*/
|
||||
class RemoveMissingParametersPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasParameter('twig.default_path')) {
|
||||
$container->getDefinition('maker.file_manager')
|
||||
->replaceArgument(4, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony MakerBundle package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\MakerBundle\DependencyInjection\CompilerPass;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class SetDoctrineAnnotatedPrefixesPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$annotatedPrefixes = null;
|
||||
|
||||
foreach ($container->findTaggedServiceIds('doctrine.orm.configuration') as $id => $tags) {
|
||||
$metadataDriverImpl = null;
|
||||
foreach ($container->getDefinition($id)->getMethodCalls() as [$method, $arguments]) {
|
||||
if ('setMetadataDriverImpl' === $method) {
|
||||
$metadataDriverImpl = $container->getDefinition($arguments[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $metadataDriverImpl || !preg_match('/^doctrine\.orm\.(.+)_configuration$/D', $id, $m)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$managerName = $m[1];
|
||||
$methodCalls = $metadataDriverImpl->getMethodCalls();
|
||||
|
||||
foreach ($methodCalls as $i => [$method, $arguments]) {
|
||||
if ('addDriver' !== $method) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($arguments[0] instanceof Definition) {
|
||||
$class = $arguments[0]->getClass();
|
||||
|
||||
$id = \sprintf('.%d_doctrine_metadata_driver~%s', $i, ContainerBuilder::hash($arguments));
|
||||
$container->setDefinition($id, $arguments[0]);
|
||||
$arguments[0] = new Reference($id);
|
||||
$methodCalls[$i] = [$method, $arguments];
|
||||
}
|
||||
|
||||
$annotatedPrefixes[$managerName][] = [
|
||||
$arguments[1],
|
||||
new Reference($arguments[0]),
|
||||
];
|
||||
}
|
||||
|
||||
$metadataDriverImpl->setMethodCalls($methodCalls);
|
||||
}
|
||||
|
||||
if (null !== $annotatedPrefixes) {
|
||||
$container->getDefinition('maker.doctrine_helper')->setArgument(2, $annotatedPrefixes);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user