Chris@14
|
1 <?php
|
Chris@14
|
2
|
Chris@14
|
3 /*
|
Chris@14
|
4 * This file is part of the Symfony package.
|
Chris@14
|
5 *
|
Chris@14
|
6 * (c) Fabien Potencier <fabien@symfony.com>
|
Chris@14
|
7 *
|
Chris@14
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@14
|
9 * file that was distributed with this source code.
|
Chris@14
|
10 */
|
Chris@14
|
11
|
Chris@14
|
12 namespace Symfony\Component\DependencyInjection\Compiler;
|
Chris@14
|
13
|
Chris@17
|
14 use Symfony\Component\DependencyInjection\ChildDefinition;
|
Chris@14
|
15 use Symfony\Component\DependencyInjection\ContainerBuilder;
|
Chris@14
|
16 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
Chris@14
|
17
|
Chris@14
|
18 /**
|
Chris@14
|
19 * @author Nicolas Grekas <p@tchwork.com>
|
Chris@14
|
20 */
|
Chris@14
|
21 class ResolveClassPass implements CompilerPassInterface
|
Chris@14
|
22 {
|
Chris@17
|
23 private $changes = [];
|
Chris@14
|
24
|
Chris@14
|
25 /**
|
Chris@14
|
26 * {@inheritdoc}
|
Chris@14
|
27 */
|
Chris@14
|
28 public function process(ContainerBuilder $container)
|
Chris@14
|
29 {
|
Chris@14
|
30 foreach ($container->getDefinitions() as $id => $definition) {
|
Chris@14
|
31 if ($definition->isSynthetic() || null !== $definition->getClass()) {
|
Chris@14
|
32 continue;
|
Chris@14
|
33 }
|
Chris@14
|
34 if (preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)++$/', $id)) {
|
Chris@14
|
35 if ($definition instanceof ChildDefinition && !class_exists($id)) {
|
Chris@14
|
36 throw new InvalidArgumentException(sprintf('Service definition "%s" has a parent but no class, and its name looks like a FQCN. Either the class is missing or you want to inherit it from the parent service. To resolve this ambiguity, please rename this service to a non-FQCN (e.g. using dots), or create the missing class.', $id));
|
Chris@14
|
37 }
|
Chris@14
|
38 $this->changes[strtolower($id)] = $id;
|
Chris@14
|
39 $definition->setClass($id);
|
Chris@14
|
40 }
|
Chris@14
|
41 }
|
Chris@14
|
42 }
|
Chris@14
|
43
|
Chris@14
|
44 /**
|
Chris@14
|
45 * @internal
|
Chris@14
|
46 *
|
Chris@14
|
47 * @deprecated since 3.3, to be removed in 4.0.
|
Chris@14
|
48 */
|
Chris@14
|
49 public function getChanges()
|
Chris@14
|
50 {
|
Chris@14
|
51 $changes = $this->changes;
|
Chris@17
|
52 $this->changes = [];
|
Chris@14
|
53
|
Chris@14
|
54 return $changes;
|
Chris@14
|
55 }
|
Chris@14
|
56 }
|