You are here

class MultiversionServiceProvider in Multiversion 8

Same name and namespace in other branches
  1. 8.2 src/MultiversionServiceProvider.php \Drupal\multiversion\MultiversionServiceProvider

Defines a service profiler for the multiversion module.

Hierarchy

Expanded class hierarchy of MultiversionServiceProvider

File

src/MultiversionServiceProvider.php, line 13

Namespace

Drupal\multiversion
View source
class MultiversionServiceProvider extends ServiceProviderBase {
  public function alter(ContainerBuilder $container) {
    $renderer_config = $container
      ->getParameter('renderer.config');
    $renderer_config['required_cache_contexts'][] = 'workspace';
    $container
      ->setParameter('renderer.config', $renderer_config);

    // Switch the menu tree storage to our own that respect Workspace cache
    // contexts.
    $definition = $container
      ->getDefinition('menu.tree_storage');
    $definition
      ->setClass('Drupal\\multiversion\\MenuTreeStorage');

    // Override the comment.statistics class with a new class.
    try {
      $definition = $container
        ->getDefinition('comment.statistics');
      $definition
        ->setClass('Drupal\\multiversion\\CommentStatistics');
    } catch (InvalidArgumentException $e) {

      // Do nothing, comment module is not installed.
    }

    // Override the redirect.repository class with a new class.
    try {
      $definition = $container
        ->getDefinition('redirect.repository');
      $definition
        ->setClass('Drupal\\multiversion\\Redirect\\RedirectRepository')
        ->addArgument(new Reference('workspace.manager'))
        ->addArgument(new Reference('state'));
    } catch (InvalidArgumentException $e) {

      // Do nothing, Redirect module is not installed.
    }

    // Override the access_check.node.revision class with a new class.
    try {
      $definition = $container
        ->getDefinition('access_check.node.revision');
      $definition
        ->setClass('Drupal\\multiversion\\Access\\NodeRevisionAccessCheck');
    } catch (InvalidArgumentException $e) {

      // Do nothing, Node module is not installed.
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MultiversionServiceProvider::alter public function Modifies existing service definitions. Overrides ServiceProviderBase::alter
ServiceProviderBase::register public function Registers services to the container. Overrides ServiceProviderInterface::register 1