Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like DoctrineExtension often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DoctrineExtension, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 33 | class DoctrineExtension extends AbstractDoctrineExtension |
||
| 34 | { |
||
| 35 | /** @var string */ |
||
| 36 | private $defaultConnection; |
||
| 37 | |||
| 38 | /** @var SymfonyBridgeAdapter */ |
||
| 39 | private $adapter; |
||
| 40 | |||
| 41 | public function __construct(SymfonyBridgeAdapter $adapter = null) |
||
| 42 | { |
||
| 43 | $this->adapter = $adapter ?: new SymfonyBridgeAdapter(new CacheProviderLoader(), 'doctrine.orm', 'orm'); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * {@inheritDoc} |
||
| 48 | */ |
||
| 49 | public function load(array $configs, ContainerBuilder $container) |
||
| 50 | { |
||
| 51 | $configuration = $this->getConfiguration($configs, $container); |
||
| 52 | $config = $this->processConfiguration($configuration, $configs); |
||
|
|
|||
| 53 | |||
| 54 | $this->adapter->loadServicesConfiguration($container); |
||
| 55 | |||
| 56 | if (! empty($config['dbal'])) { |
||
| 57 | $this->dbalLoad($config['dbal'], $container); |
||
| 58 | } |
||
| 59 | |||
| 60 | if (empty($config['orm'])) { |
||
| 61 | return; |
||
| 62 | } |
||
| 63 | |||
| 64 | if (empty($config['dbal'])) { |
||
| 65 | throw new LogicException('Configuring the ORM layer requires to configure the DBAL layer as well.'); |
||
| 66 | } |
||
| 67 | |||
| 68 | if (! class_exists('Doctrine\ORM\Version')) { |
||
| 69 | throw new LogicException('To configure the ORM layer, you must first install the doctrine/orm package.'); |
||
| 70 | } |
||
| 71 | |||
| 72 | $this->ormLoad($config['orm'], $container); |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Loads the DBAL configuration. |
||
| 77 | * |
||
| 78 | * Usage example: |
||
| 79 | * |
||
| 80 | * <doctrine:dbal id="myconn" dbname="sfweb" user="root" /> |
||
| 81 | * |
||
| 82 | * @param array $config An array of configuration settings |
||
| 83 | * @param ContainerBuilder $container A ContainerBuilder instance |
||
| 84 | */ |
||
| 85 | protected function dbalLoad(array $config, ContainerBuilder $container) |
||
| 86 | { |
||
| 87 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
||
| 88 | $loader->load('dbal.xml'); |
||
| 89 | |||
| 90 | if (empty($config['default_connection'])) { |
||
| 91 | $keys = array_keys($config['connections']); |
||
| 92 | $config['default_connection'] = reset($keys); |
||
| 93 | } |
||
| 94 | |||
| 95 | $this->defaultConnection = $config['default_connection']; |
||
| 96 | |||
| 97 | $container->setAlias('database_connection', sprintf('doctrine.dbal.%s_connection', $this->defaultConnection)); |
||
| 98 | $container->getAlias('database_connection')->setPublic(true); |
||
| 99 | $container->setAlias('doctrine.dbal.event_manager', new Alias(sprintf('doctrine.dbal.%s_connection.event_manager', $this->defaultConnection), false)); |
||
| 100 | |||
| 101 | $container->setParameter('doctrine.dbal.connection_factory.types', $config['types']); |
||
| 102 | |||
| 103 | $connections = []; |
||
| 104 | |||
| 105 | foreach (array_keys($config['connections']) as $name) { |
||
| 106 | $connections[$name] = sprintf('doctrine.dbal.%s_connection', $name); |
||
| 107 | } |
||
| 108 | |||
| 109 | $container->setParameter('doctrine.connections', $connections); |
||
| 110 | $container->setParameter('doctrine.default_connection', $this->defaultConnection); |
||
| 111 | |||
| 112 | foreach ($config['connections'] as $name => $connection) { |
||
| 113 | $this->loadDbalConnection($name, $connection, $container); |
||
| 114 | } |
||
| 115 | } |
||
| 116 | |||
| 117 | /** |
||
| 118 | * Loads a configured DBAL connection. |
||
| 119 | * |
||
| 120 | * @param string $name The name of the connection |
||
| 121 | * @param array $connection A dbal connection configuration. |
||
| 122 | * @param ContainerBuilder $container A ContainerBuilder instance |
||
| 123 | */ |
||
| 124 | protected function loadDbalConnection($name, array $connection, ContainerBuilder $container) |
||
| 125 | { |
||
| 126 | // configuration |
||
| 127 | $definitionClassname = $this->getDefinitionClassname(); |
||
| 128 | |||
| 129 | $configuration = $container->setDefinition(sprintf('doctrine.dbal.%s_connection.configuration', $name), new $definitionClassname('doctrine.dbal.connection.configuration')); |
||
| 130 | $logger = null; |
||
| 131 | if ($connection['logging']) { |
||
| 132 | $logger = new Reference('doctrine.dbal.logger'); |
||
| 133 | } |
||
| 134 | unset($connection['logging']); |
||
| 135 | if ($connection['profiling']) { |
||
| 136 | $profilingLoggerId = 'doctrine.dbal.logger.profiling.' . $name; |
||
| 137 | $container->setDefinition($profilingLoggerId, new $definitionClassname('doctrine.dbal.logger.profiling')); |
||
| 138 | $profilingLogger = new Reference($profilingLoggerId); |
||
| 139 | $container->getDefinition('data_collector.doctrine')->addMethodCall('addLogger', [$name, $profilingLogger]); |
||
| 140 | |||
| 141 | if ($logger !== null) { |
||
| 142 | $chainLogger = new $definitionClassname('doctrine.dbal.logger.chain'); |
||
| 143 | $chainLogger->addMethodCall('addLogger', [$profilingLogger]); |
||
| 144 | |||
| 145 | $loggerId = 'doctrine.dbal.logger.chain.' . $name; |
||
| 146 | $container->setDefinition($loggerId, $chainLogger); |
||
| 147 | $logger = new Reference($loggerId); |
||
| 148 | } else { |
||
| 149 | $logger = $profilingLogger; |
||
| 150 | } |
||
| 151 | } |
||
| 152 | unset($connection['profiling']); |
||
| 153 | |||
| 154 | if (isset($connection['auto_commit'])) { |
||
| 155 | $configuration->addMethodCall('setAutoCommit', [$connection['auto_commit']]); |
||
| 156 | } |
||
| 157 | |||
| 158 | unset($connection['auto_commit']); |
||
| 159 | |||
| 160 | if (isset($connection['schema_filter']) && $connection['schema_filter']) { |
||
| 161 | $configuration->addMethodCall('setFilterSchemaAssetsExpression', [$connection['schema_filter']]); |
||
| 162 | } |
||
| 163 | |||
| 164 | unset($connection['schema_filter']); |
||
| 165 | |||
| 166 | if ($logger) { |
||
| 167 | $configuration->addMethodCall('setSQLLogger', [$logger]); |
||
| 168 | } |
||
| 169 | |||
| 170 | // event manager |
||
| 171 | $container->setDefinition(sprintf('doctrine.dbal.%s_connection.event_manager', $name), new $definitionClassname('doctrine.dbal.connection.event_manager')); |
||
| 172 | |||
| 173 | // connection |
||
| 174 | $options = $this->getConnectionOptions($connection); |
||
| 175 | |||
| 176 | $def = $container |
||
| 177 | ->setDefinition(sprintf('doctrine.dbal.%s_connection', $name), new $definitionClassname('doctrine.dbal.connection')) |
||
| 178 | ->setPublic(true) |
||
| 179 | ->setArguments([ |
||
| 180 | $options, |
||
| 181 | new Reference(sprintf('doctrine.dbal.%s_connection.configuration', $name)), |
||
| 182 | new Reference(sprintf('doctrine.dbal.%s_connection.event_manager', $name)), |
||
| 183 | $connection['mapping_types'], |
||
| 184 | ]); |
||
| 185 | |||
| 186 | // Set class in case "wrapper_class" option was used to assist IDEs |
||
| 187 | if (isset($options['wrapperClass'])) { |
||
| 188 | $def->setClass($options['wrapperClass']); |
||
| 189 | } |
||
| 190 | |||
| 191 | if (! empty($connection['use_savepoints'])) { |
||
| 192 | $def->addMethodCall('setNestTransactionsWithSavepoints', [$connection['use_savepoints']]); |
||
| 193 | } |
||
| 194 | |||
| 195 | // Create a shard_manager for this connection |
||
| 196 | if (! isset($options['shards'])) { |
||
| 197 | return; |
||
| 198 | } |
||
| 199 | |||
| 200 | $shardManagerDefinition = new Definition($options['shardManagerClass'], [new Reference(sprintf('doctrine.dbal.%s_connection', $name))]); |
||
| 201 | $container->setDefinition(sprintf('doctrine.dbal.%s_shard_manager', $name), $shardManagerDefinition); |
||
| 202 | } |
||
| 203 | |||
| 204 | protected function getConnectionOptions($connection) |
||
| 205 | { |
||
| 206 | $options = $connection; |
||
| 207 | |||
| 208 | if (isset($options['platform_service'])) { |
||
| 209 | $options['platform'] = new Reference($options['platform_service']); |
||
| 210 | unset($options['platform_service']); |
||
| 211 | } |
||
| 212 | unset($options['mapping_types']); |
||
| 213 | |||
| 214 | if (isset($options['shard_choser_service'])) { |
||
| 215 | $options['shard_choser'] = new Reference($options['shard_choser_service']); |
||
| 216 | unset($options['shard_choser_service']); |
||
| 217 | } |
||
| 218 | |||
| 219 | foreach ([ |
||
| 220 | 'options' => 'driverOptions', |
||
| 221 | 'driver_class' => 'driverClass', |
||
| 222 | 'wrapper_class' => 'wrapperClass', |
||
| 223 | 'keep_slave' => 'keepSlave', |
||
| 224 | 'shard_choser' => 'shardChoser', |
||
| 225 | 'shard_manager_class' => 'shardManagerClass', |
||
| 226 | 'server_version' => 'serverVersion', |
||
| 227 | 'default_table_options' => 'defaultTableOptions', |
||
| 228 | ] as $old => $new) { |
||
| 229 | if (! isset($options[$old])) { |
||
| 230 | continue; |
||
| 231 | } |
||
| 232 | |||
| 233 | $options[$new] = $options[$old]; |
||
| 234 | unset($options[$old]); |
||
| 235 | } |
||
| 236 | |||
| 237 | if (! empty($options['slaves']) && ! empty($options['shards'])) { |
||
| 238 | throw new InvalidArgumentException('Sharding and master-slave connection cannot be used together'); |
||
| 239 | } |
||
| 240 | |||
| 241 | if (! empty($options['slaves'])) { |
||
| 242 | $nonRewrittenKeys = [ |
||
| 243 | 'driver' => true, |
||
| 244 | 'driverOptions' => true, |
||
| 245 | 'driverClass' => true, |
||
| 246 | 'wrapperClass' => true, |
||
| 247 | 'keepSlave' => true, |
||
| 248 | 'shardChoser' => true, |
||
| 249 | 'platform' => true, |
||
| 250 | 'slaves' => true, |
||
| 251 | 'master' => true, |
||
| 252 | 'shards' => true, |
||
| 253 | 'serverVersion' => true, |
||
| 254 | // included by safety but should have been unset already |
||
| 255 | 'logging' => true, |
||
| 256 | 'profiling' => true, |
||
| 257 | 'mapping_types' => true, |
||
| 258 | 'platform_service' => true, |
||
| 259 | ]; |
||
| 260 | View Code Duplication | foreach ($options as $key => $value) { |
|
| 261 | if (isset($nonRewrittenKeys[$key])) { |
||
| 262 | continue; |
||
| 263 | } |
||
| 264 | $options['master'][$key] = $value; |
||
| 265 | unset($options[$key]); |
||
| 266 | } |
||
| 267 | if (empty($options['wrapperClass'])) { |
||
| 268 | // Change the wrapper class only if the user does not already forced using a custom one. |
||
| 269 | $options['wrapperClass'] = 'Doctrine\\DBAL\\Connections\\MasterSlaveConnection'; |
||
| 270 | } |
||
| 271 | } else { |
||
| 272 | unset($options['slaves']); |
||
| 273 | } |
||
| 274 | |||
| 275 | if (! empty($options['shards'])) { |
||
| 276 | $nonRewrittenKeys = [ |
||
| 277 | 'driver' => true, |
||
| 278 | 'driverOptions' => true, |
||
| 279 | 'driverClass' => true, |
||
| 280 | 'wrapperClass' => true, |
||
| 281 | 'keepSlave' => true, |
||
| 282 | 'shardChoser' => true, |
||
| 283 | 'platform' => true, |
||
| 284 | 'slaves' => true, |
||
| 285 | 'global' => true, |
||
| 286 | 'shards' => true, |
||
| 287 | 'serverVersion' => true, |
||
| 288 | // included by safety but should have been unset already |
||
| 289 | 'logging' => true, |
||
| 290 | 'profiling' => true, |
||
| 291 | 'mapping_types' => true, |
||
| 292 | 'platform_service' => true, |
||
| 293 | ]; |
||
| 294 | View Code Duplication | foreach ($options as $key => $value) { |
|
| 295 | if (isset($nonRewrittenKeys[$key])) { |
||
| 296 | continue; |
||
| 297 | } |
||
| 298 | $options['global'][$key] = $value; |
||
| 299 | unset($options[$key]); |
||
| 300 | } |
||
| 301 | if (empty($options['wrapperClass'])) { |
||
| 302 | // Change the wrapper class only if the user does not already forced using a custom one. |
||
| 303 | $options['wrapperClass'] = 'Doctrine\\DBAL\\Sharding\\PoolingShardConnection'; |
||
| 304 | } |
||
| 305 | if (empty($options['shardManagerClass'])) { |
||
| 306 | // Change the shard manager class only if the user does not already forced using a custom one. |
||
| 307 | $options['shardManagerClass'] = 'Doctrine\\DBAL\\Sharding\\PoolingShardManager'; |
||
| 308 | } |
||
| 309 | } else { |
||
| 310 | unset($options['shards']); |
||
| 311 | } |
||
| 312 | |||
| 313 | return $options; |
||
| 314 | } |
||
| 315 | |||
| 316 | /** |
||
| 317 | * Loads the Doctrine ORM configuration. |
||
| 318 | * |
||
| 319 | * Usage example: |
||
| 320 | * |
||
| 321 | * <doctrine:orm id="mydm" connection="myconn" /> |
||
| 322 | * |
||
| 323 | * @param array $config An array of configuration settings |
||
| 324 | * @param ContainerBuilder $container A ContainerBuilder instance |
||
| 325 | */ |
||
| 326 | protected function ormLoad(array $config, ContainerBuilder $container) |
||
| 327 | { |
||
| 328 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
||
| 329 | $loader->load('orm.xml'); |
||
| 330 | |||
| 331 | if (class_exists(AbstractType::class) && method_exists(DoctrineType::class, 'reset')) { |
||
| 332 | $container->getDefinition('form.type.entity')->addTag('kernel.reset', ['method' => 'reset']); |
||
| 333 | } |
||
| 334 | |||
| 335 | $entityManagers = []; |
||
| 336 | foreach (array_keys($config['entity_managers']) as $name) { |
||
| 337 | $entityManagers[$name] = sprintf('doctrine.orm.%s_entity_manager', $name); |
||
| 338 | } |
||
| 339 | $container->setParameter('doctrine.entity_managers', $entityManagers); |
||
| 340 | |||
| 341 | if (empty($config['default_entity_manager'])) { |
||
| 342 | $tmp = array_keys($entityManagers); |
||
| 343 | $config['default_entity_manager'] = reset($tmp); |
||
| 344 | } |
||
| 345 | $container->setParameter('doctrine.default_entity_manager', $config['default_entity_manager']); |
||
| 346 | |||
| 347 | $options = ['auto_generate_proxy_classes', 'proxy_dir', 'proxy_namespace']; |
||
| 348 | foreach ($options as $key) { |
||
| 349 | $container->setParameter('doctrine.orm.' . $key, $config[$key]); |
||
| 350 | } |
||
| 351 | |||
| 352 | $container->setAlias('doctrine.orm.entity_manager', sprintf('doctrine.orm.%s_entity_manager', $config['default_entity_manager'])); |
||
| 353 | $container->getAlias('doctrine.orm.entity_manager')->setPublic(true); |
||
| 354 | |||
| 355 | $config['entity_managers'] = $this->fixManagersAutoMappings($config['entity_managers'], $container->getParameter('kernel.bundles')); |
||
| 356 | |||
| 357 | $loadPropertyInfoExtractor = interface_exists('Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface') |
||
| 358 | && class_exists('Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor'); |
||
| 359 | |||
| 360 | foreach ($config['entity_managers'] as $name => $entityManager) { |
||
| 361 | $entityManager['name'] = $name; |
||
| 362 | $this->loadOrmEntityManager($entityManager, $container); |
||
| 363 | |||
| 364 | if (! $loadPropertyInfoExtractor) { |
||
| 365 | continue; |
||
| 366 | } |
||
| 367 | |||
| 368 | $this->loadPropertyInfoExtractor($name, $container); |
||
| 369 | } |
||
| 370 | |||
| 371 | if ($config['resolve_target_entities']) { |
||
| 372 | $def = $container->findDefinition('doctrine.orm.listeners.resolve_target_entity'); |
||
| 373 | foreach ($config['resolve_target_entities'] as $name => $implementation) { |
||
| 374 | $def->addMethodCall('addResolveTargetEntity', [ |
||
| 375 | $name, |
||
| 376 | $implementation, |
||
| 377 | [], |
||
| 378 | ]); |
||
| 379 | } |
||
| 380 | |||
| 381 | // BC: ResolveTargetEntityListener implements the subscriber interface since |
||
| 382 | // v2.5.0-beta1 (Commit 437f812) |
||
| 383 | if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { |
||
| 384 | $def->addTag('doctrine.event_listener', ['event' => 'loadClassMetadata']); |
||
| 385 | } else { |
||
| 386 | $def->addTag('doctrine.event_subscriber'); |
||
| 387 | } |
||
| 388 | } |
||
| 389 | |||
| 390 | // if is for Symfony 3.2 and lower compat |
||
| 391 | if (method_exists($container, 'registerForAutoconfiguration')) { |
||
| 392 | $container->registerForAutoconfiguration(ServiceEntityRepositoryInterface::class) |
||
| 393 | ->addTag(ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG); |
||
| 394 | } |
||
| 395 | |||
| 396 | // If the Messenger component is installed and the doctrine transaction middleware is available, wire it: |
||
| 397 | if (interface_exists(MessageBusInterface::class) && class_exists(DoctrineTransactionMiddleware::class)) { |
||
| 398 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
||
| 399 | $loader->load('messenger.xml'); |
||
| 400 | } |
||
| 401 | |||
| 402 | /* |
||
| 403 | * Compatibility for Symfony 3.2 and lower: gives the service a default argument. |
||
| 404 | * When DoctrineBundle requires 3.3 or higher, this can be moved to an anonymous |
||
| 405 | * service in orm.xml. |
||
| 406 | * |
||
| 407 | * This is replaced with a true locator by ServiceRepositoryCompilerPass. |
||
| 408 | * This makes that pass technically optional (good for tests). |
||
| 409 | */ |
||
| 410 | if (! class_exists(ServiceLocator::class)) { |
||
| 411 | return; |
||
| 412 | } |
||
| 413 | |||
| 414 | $container->getDefinition('doctrine.orm.container_repository_factory') |
||
| 415 | ->replaceArgument(0, (new Definition(ServiceLocator::class))->setArgument(0, [])); |
||
| 416 | } |
||
| 417 | |||
| 418 | /** |
||
| 419 | * Loads a configured ORM entity manager. |
||
| 420 | * |
||
| 421 | * @param array $entityManager A configured ORM entity manager. |
||
| 422 | * @param ContainerBuilder $container A ContainerBuilder instance |
||
| 423 | */ |
||
| 424 | protected function loadOrmEntityManager(array $entityManager, ContainerBuilder $container) |
||
| 567 | |||
| 568 | /** |
||
| 569 | * Loads an ORM entity managers bundle mapping information. |
||
| 570 | * |
||
| 571 | * There are two distinct configuration possibilities for mapping information: |
||
| 572 | * |
||
| 573 | * 1. Specify a bundle and optionally details where the entity and mapping information reside. |
||
| 574 | * 2. Specify an arbitrary mapping location. |
||
| 575 | * |
||
| 576 | * @param array $entityManager A configured ORM entity manager |
||
| 577 | * @param Definition $ormConfigDef A Definition instance |
||
| 578 | * @param ContainerBuilder $container A ContainerBuilder instance |
||
| 579 | * |
||
| 580 | * @example |
||
| 581 | * |
||
| 582 | * doctrine.orm: |
||
| 583 | * mappings: |
||
| 584 | * MyBundle1: ~ |
||
| 585 | * MyBundle2: yml |
||
| 586 | * MyBundle3: { type: annotation, dir: Entities/ } |
||
| 587 | * MyBundle4: { type: xml, dir: Resources/config/doctrine/mapping } |
||
| 588 | * MyBundle5: |
||
| 589 | * type: yml |
||
| 590 | * dir: bundle-mappings/ |
||
| 591 | * alias: BundleAlias |
||
| 592 | * arbitrary_key: |
||
| 593 | * type: xml |
||
| 594 | * dir: %kernel.root_dir%/../src/vendor/DoctrineExtensions/lib/DoctrineExtensions/Entities |
||
| 595 | * prefix: DoctrineExtensions\Entities\ |
||
| 596 | * alias: DExt |
||
| 597 | * |
||
| 598 | * In the case of bundles everything is really optional (which leads to autodetection for this bundle) but |
||
| 599 | * in the mappings key everything except alias is a required argument. |
||
| 600 | */ |
||
| 601 | protected function loadOrmEntityManagerMappingInformation(array $entityManager, Definition $ormConfigDef, ContainerBuilder $container) |
||
| 612 | |||
| 613 | /** |
||
| 614 | * Loads an ORM second level cache bundle mapping information. |
||
| 615 | * |
||
| 616 | * @param array $entityManager A configured ORM entity manager |
||
| 617 | * @param Definition $ormConfigDef A Definition instance |
||
| 618 | * @param ContainerBuilder $container A ContainerBuilder instance |
||
| 619 | * |
||
| 620 | * @example |
||
| 621 | * entity_managers: |
||
| 622 | * default: |
||
| 623 | * second_level_cache: |
||
| 624 | * region_cache_driver: apc |
||
| 625 | * log_enabled: true |
||
| 626 | * regions: |
||
| 627 | * my_service_region: |
||
| 628 | * type: service |
||
| 629 | * service : "my_service_region" |
||
| 630 | * |
||
| 631 | * my_query_region: |
||
| 632 | * lifetime: 300 |
||
| 633 | * cache_driver: array |
||
| 634 | * type: filelock |
||
| 635 | * |
||
| 636 | * my_entity_region: |
||
| 637 | * lifetime: 600 |
||
| 638 | * cache_driver: |
||
| 639 | * type: apc |
||
| 640 | */ |
||
| 641 | protected function loadOrmSecondLevelCache(array $entityManager, Definition $ormConfigDef, ContainerBuilder $container) |
||
| 733 | |||
| 734 | /** |
||
| 735 | * {@inheritDoc} |
||
| 736 | */ |
||
| 737 | protected function getObjectManagerElementName($name) |
||
| 741 | |||
| 742 | protected function getMappingObjectDefaultName() |
||
| 746 | |||
| 747 | /** |
||
| 748 | * {@inheritDoc} |
||
| 749 | */ |
||
| 750 | protected function getMappingResourceConfigDirectory() |
||
| 754 | |||
| 755 | /** |
||
| 756 | * {@inheritDoc} |
||
| 757 | */ |
||
| 758 | protected function getMappingResourceExtension() |
||
| 762 | |||
| 763 | /** |
||
| 764 | * {@inheritDoc} |
||
| 765 | */ |
||
| 766 | protected function loadCacheDriver($driverName, $entityManagerName, array $driverMap, ContainerBuilder $container) |
||
| 779 | |||
| 780 | /** |
||
| 781 | * Loads a configured entity managers cache drivers. |
||
| 782 | * |
||
| 783 | * @param array $entityManager A configured ORM entity manager. |
||
| 784 | * @param ContainerBuilder $container A ContainerBuilder instance |
||
| 785 | */ |
||
| 786 | protected function loadOrmCacheDrivers(array $entityManager, ContainerBuilder $container) |
||
| 792 | |||
| 793 | /** |
||
| 794 | * Loads a property info extractor for each defined entity manager. |
||
| 795 | * |
||
| 796 | * @param string $entityManagerName |
||
| 797 | */ |
||
| 798 | private function loadPropertyInfoExtractor($entityManagerName, ContainerBuilder $container) |
||
| 819 | |||
| 820 | /** |
||
| 821 | * @param array $objectManager |
||
| 822 | * @param string $cacheName |
||
| 823 | */ |
||
| 824 | public function loadObjectManagerCacheDriver(array $objectManager, ContainerBuilder $container, $cacheName) |
||
| 828 | |||
| 829 | /** |
||
| 830 | * {@inheritDoc} |
||
| 831 | */ |
||
| 832 | public function getXsdValidationBasePath() |
||
| 836 | |||
| 837 | /** |
||
| 838 | * {@inheritDoc} |
||
| 839 | */ |
||
| 840 | public function getNamespace() |
||
| 844 | |||
| 845 | /** |
||
| 846 | * {@inheritDoc} |
||
| 847 | */ |
||
| 848 | public function getConfiguration(array $config, ContainerBuilder $container) |
||
| 852 | |||
| 853 | /** |
||
| 854 | * @return string |
||
| 855 | */ |
||
| 856 | private function getDefinitionClassname() |
||
| 860 | } |
||
| 861 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: