/usr/share/php/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/FormPass.php is in php-symfony-framework-bundle 2.8.7+dfsg-1.3+deb9u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | <?php
/*
* This file is part of the Symfony 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\FrameworkBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
/**
* Adds all services with the tags "form.type" and "form.type_guesser" as
* arguments of the "form.extension" service.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class FormPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('form.extension')) {
return;
}
$definition = $container->getDefinition('form.extension');
// Builds an array with service IDs as keys and tag aliases as values
$types = array();
foreach ($container->findTaggedServiceIds('form.type') as $serviceId => $tag) {
$serviceDefinition = $container->getDefinition($serviceId);
if (!$serviceDefinition->isPublic()) {
throw new \InvalidArgumentException(sprintf('The service "%s" must be public as form types are lazy-loaded.', $serviceId));
}
// The following if-else block is deprecated and will be removed
// in Symfony 3.0
// Deprecation errors are triggered in the form registry
if (isset($tag[0]['alias'])) {
$types[$tag[0]['alias']] = $serviceId;
} else {
$types[$serviceId] = $serviceId;
}
// Support type access by FQCN
$types[$serviceDefinition->getClass()] = $serviceId;
}
$definition->replaceArgument(1, $types);
$typeExtensions = array();
foreach ($container->findTaggedServiceIds('form.type_extension') as $serviceId => $tag) {
$serviceDefinition = $container->getDefinition($serviceId);
if (!$serviceDefinition->isPublic()) {
throw new \InvalidArgumentException(sprintf('The service "%s" must be public as form type extensions are lazy-loaded.', $serviceId));
}
if (isset($tag[0]['extended_type'])) {
$extendedType = $tag[0]['extended_type'];
} elseif (isset($tag[0]['alias'])) {
@trigger_error(sprintf('The alias option of the form.type_extension tag of service "%s" is deprecated since version 2.8 and will be removed in 3.0. Use the extended_type option instead.', $serviceId), E_USER_DEPRECATED);
$extendedType = $tag[0]['alias'];
} else {
@trigger_error(sprintf('The extended_type option of the form.type_extension tag of service "%s" is required since version 2.8.', $serviceId), E_USER_DEPRECATED);
$extendedType = $serviceId;
}
$typeExtensions[$extendedType][] = $serviceId;
}
$definition->replaceArgument(2, $typeExtensions);
// Find all services annotated with "form.type_guesser"
$guessers = array_keys($container->findTaggedServiceIds('form.type_guesser'));
foreach ($guessers as $serviceId) {
$serviceDefinition = $container->getDefinition($serviceId);
if (!$serviceDefinition->isPublic()) {
throw new \InvalidArgumentException(sprintf('The service "%s" must be public as form type guessers are lazy-loaded.', $serviceId));
}
}
$definition->replaceArgument(3, $guessers);
}
}
|