You are here

public function ServiceContainerSymfonyServiceProvider::getContainerDefinition in Service Container 7

Same name and namespace in other branches
  1. 7.2 modules/providers/service_container_symfony/src/ServiceContainer/ServiceProvider/ServiceContainerSymfonyServiceProvider.php \Drupal\service_container_symfony\ServiceContainer\ServiceProvider\ServiceContainerSymfonyServiceProvider::getContainerDefinition()

Gets a service container definition.

Return value

array Returns an associative array with the following keys:

  • parameters: Simple key-value store of container parameters
  • services: Services like defined in services.yml

factory methods, arguments and tags are supported for services.

@see core.services.yml in Drupal 8

Overrides ServiceProviderInterface::getContainerDefinition

File

modules/providers/service_container_symfony/src/ServiceContainer/ServiceProvider/ServiceContainerSymfonyServiceProvider.php, line 27
Contains \Drupal\service_container_symfony\ServiceContainer\ServiceProvider\ServiceContainerSymfonyServiceProvider

Class

ServiceContainerSymfonyServiceProvider
Provides render cache service definitions.

Namespace

Drupal\service_container_symfony\ServiceContainer\ServiceProvider

Code

public function getContainerDefinition() {
  FileCacheFactory::setConfiguration(array(
    'default' => array(
      'class' => '\\Drupal\\Component\\FileCache\\NullFileCache',
    ),
  ));
  $container_builder = new ContainerBuilder();
  $yaml_loader = new YamlFileLoader($container_builder);
  foreach (module_list() as $module) {
    $filename = drupal_get_filename('module', $module);
    $services = dirname($filename) . '/' . $module . '.services.yml';
    if (file_exists($services)) {
      $yaml_loader
        ->load($services);
    }
  }

  // Disabled for now.
  // $container_builder->compile();
  $dumper = new PhpArrayDumper($container_builder);
  return $dumper
    ->getArray();
}