You are here

protected function NgLightboxServiceProvider::addLightbox in NG Lightbox 2.x

Same name and namespace in other branches
  1. 8 src/NgLightboxServiceProvider.php \Drupal\ng_lightbox\NgLightboxServiceProvider::addLightbox()

Function for addLightBox.

Parameters

\Drupal\Core\DependencyInjection\ContainerBuilder $container: Drupal's dependency injection container builder.

string $id: The ID of the main content render box.

string $title: The title of the box.

1 call to NgLightboxServiceProvider::addLightbox()
NgLightboxServiceProvider::alter in src/NgLightboxServiceProvider.php
Modifies existing service definitions.

File

src/NgLightboxServiceProvider.php, line 38

Class

NgLightboxServiceProvider
The NgLightboxServiceProvider class.

Namespace

Drupal\ng_lightbox

Code

protected function addLightbox(ContainerBuilder $container, $id, $title) {
  $definition = $container
    ->getDefinition($id);
  $tags = $definition
    ->getTags();
  foreach ($tags as $delta => &$tag) {
    if ($delta === 'render.main_content_renderer') {
      foreach ($tag as &$attribute) {
        $attribute['ng_lightbox'] = $title;
      }
    }
  }
  $definition
    ->setTags($tags);
}