[Symfony] Set few default common service names for Symfony App Analyzer

Allow to set custom ones via configuration
This commit is contained in:
Joseph Bielawski 2019-07-04 13:34:22 +02:00
parent 048ce8c545
commit 6d23c758a4

View File

@ -18,6 +18,8 @@ final class DefaultAnalyzedSymfonyApplicationContainer implements AnalyzedApplic
*/ */
private $commonNamesToTypes = [ private $commonNamesToTypes = [
'doctrine' => 'Doctrine\Bundle\DoctrineBundle\Registry', 'doctrine' => 'Doctrine\Bundle\DoctrineBundle\Registry',
'doctrine.orm.entity_manager' => 'Doctrine\ORM\EntityManagerInterface',
'doctrine.orm.default_entity_manager' => 'Doctrine\ORM\EntityManagerInterface',
]; ];
/** /**
@ -35,14 +37,19 @@ final class DefaultAnalyzedSymfonyApplicationContainer implements AnalyzedApplic
*/ */
private $containerFactory; private $containerFactory;
/**
* @param array<string, string> $commonNamesToTypes
*/
public function __construct( public function __construct(
ParameterProvider $parameterProvider, ParameterProvider $parameterProvider,
SymfonyKernelParameterGuard $symfonyKernelParameterGuard, SymfonyKernelParameterGuard $symfonyKernelParameterGuard,
ContainerFactory $containerFactory ContainerFactory $containerFactory,
array $commonNamesToTypes = []
) { ) {
$this->parameterProvider = $parameterProvider; $this->parameterProvider = $parameterProvider;
$this->symfonyKernelParameterGuard = $symfonyKernelParameterGuard; $this->symfonyKernelParameterGuard = $symfonyKernelParameterGuard;
$this->containerFactory = $containerFactory; $this->containerFactory = $containerFactory;
$this->commonNamesToTypes = array_merge($this->commonNamesToTypes, $commonNamesToTypes);
} }
public function getTypeForName(string $name): ?string public function getTypeForName(string $name): ?string