2017-01-02 13:43:40 +00:00
< ? 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\Component\DependencyInjection\Compiler ;
use Symfony\Component\DependencyInjection\ContainerBuilder ;
use Symfony\Component\DependencyInjection\ChildDefinition ;
2017-04-10 17:46:19 +01:00
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException ;
2017-01-02 13:43:40 +00:00
/**
* @ author Nicolas Grekas < p @ tchwork . com >
*/
class ResolveClassPass implements CompilerPassInterface
{
private $changes = array ();
/**
* { @ inheritdoc }
*/
public function process ( ContainerBuilder $container )
{
foreach ( $container -> getDefinitions () as $id => $definition ) {
2017-04-10 17:46:19 +01:00
if ( $definition -> isSynthetic () || null !== $definition -> getClass ()) {
2017-01-02 13:43:40 +00:00
continue ;
}
2017-01-29 15:34:49 +00:00
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 )) {
2017-04-10 17:46:19 +01:00
if ( $definition instanceof ChildDefinition && ! class_exists ( $id )) {
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 ));
}
2017-01-10 07:04:52 +00:00
$this -> changes [ strtolower ( $id )] = $id ;
$definition -> setClass ( $id );
2017-01-02 13:43:40 +00:00
}
}
}
/**
* @ internal
*
* @ deprecated since 3.3 , to be removed in 4.0 .
*/
public function getChanges ()
{
$changes = $this -> changes ;
$this -> changes = array ();
return $changes ;
}
}