You are here

class ThemeRegistryAlter in Image Lazyloader 8

Class ThemeRegistryAlter.

Hierarchy

Expanded class hierarchy of ThemeRegistryAlter

1 file declares its use of ThemeRegistryAlter
lazyloader.module in ./lazyloader.module
Lazyloader Module.

File

src/Hooks/ThemeRegistryAlter.php, line 11

Namespace

Drupal\lazyloader\Hooks
View source
class ThemeRegistryAlter {

  /**
   * The module handler.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  private $config;

  /**
   * Creates a new ThemeRegistryAlter instance.
   *
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
   *   The module handler.
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config
   *   The config factory.
   */
  public function __construct(ModuleHandlerInterface $moduleHandler, ConfigFactoryInterface $config) {
    $this->moduleHandler = $moduleHandler;
    $this->config = $config;
  }

  /**
   * Alters the theme registry.
   *
   * @param array $theme_registry
   *   The theme registry.
   */
  public function themeRegistryAlter(array &$theme_registry) {
    if ($this->config
      ->get('lazyloader.configuration')
      ->get('enabled')) {
      $theme_registry['image']['path'] = $this->moduleHandler
        ->getModule('lazyloader')
        ->getPath() . '/templates';
      $theme_registry['image']['template'] = 'image';
      $theme_registry['responsive_image']['preprocess functions'][] = 'lazyloader_preprocess_responsive_image';
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ThemeRegistryAlter::$config private property The config factory.
ThemeRegistryAlter::$moduleHandler protected property The module handler.
ThemeRegistryAlter::themeRegistryAlter public function Alters the theme registry.
ThemeRegistryAlter::__construct public function Creates a new ThemeRegistryAlter instance.