You are here

ExamplePreprocessEventFactory.php in Hook Event Dispatcher 8.2

File

examples/preprocess_example_module/src/Factory/ExamplePreprocessEventFactory.php
View source
<?php

namespace Drupal\preprocess_example_module\Factory;

use Drupal\preprocess_event_dispatcher\Event\AbstractPreprocessEvent;
use Drupal\preprocess_event_dispatcher\Factory\PreprocessEventFactoryInterface;
use Drupal\preprocess_example_module\Event\ExamplePreprocessEvent;
use Drupal\preprocess_example_module\Event\Variables\ExampleEventVariables;

/**
 * Class ExamplePreprocessEventFactory.
 */
class ExamplePreprocessEventFactory implements PreprocessEventFactoryInterface {

  /**
   * Create the PreprocessEvent with the Variables object embedded.
   *
   * @param array $variables
   *   Variables.
   *
   * @return \Drupal\preprocess_event_dispatcher\Event\AbstractPreprocessEvent
   *   Created event.
   */
  public function createEvent(array &$variables) : AbstractPreprocessEvent {
    return new ExamplePreprocessEvent(new ExampleEventVariables($variables));
  }

  /**
   * {@inheritdoc}
   */
  public function getEventHook() : string {
    return ExamplePreprocessEvent::getHook();
  }

}

Classes

Namesort descending Description
ExamplePreprocessEventFactory Class ExamplePreprocessEventFactory.