You are here

NgLightboxPass.php in NG Lightbox 8

Same filename and directory in other branches
  1. 2.x src/NgLightboxPass.php

Namespace

Drupal\ng_lightbox

File

src/NgLightboxPass.php
View source
<?php

/**
 * @file
 * Contains \Drupal\ng_lightbox\NgLightboxPass
 */
namespace Drupal\ng_lightbox;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
 * The NgLightboxPass class.
 */
class NgLightboxPass implements CompilerPassInterface {

  /**
   * {@inheritdoc}
   */
  public function process(ContainerBuilder $container) {
    $lightbox_renderers = [];
    foreach ($container
      ->findTaggedServiceIds('render.main_content_renderer') as $id => $attributes_list) {
      foreach ($attributes_list as $attributes) {
        if (!empty($attributes['ng_lightbox'])) {
          $format = $attributes['format'];
          $lightbox_renderers[$format] = $attributes['ng_lightbox'];
        }
      }
    }
    $container
      ->setParameter('ng_lightbox_renderers', $lightbox_renderers);
  }

}

Classes

Namesort descending Description
NgLightboxPass The NgLightboxPass class.