You are here

class MapEvent in Sophron 8

Defines the MapEvent.

Hierarchy

  • class \Drupal\sophron\Event\MapEvent extends \Symfony\Component\EventDispatcher\Event

Expanded class hierarchy of MapEvent

2 files declare their use of MapEvent
MimeMapManager.php in src/MimeMapManager.php
SophronEventSubscriber.php in src/EventSubscriber/SophronEventSubscriber.php

File

src/Event/MapEvent.php, line 10

Namespace

Drupal\sophron\Event
View source
class MapEvent extends Event {

  /**
   * Fires when a MimeMap map is initialized in Sophron.
   *
   * @Event
   *
   * @var string
   */
  const INIT = 'sophron.map.initialize';

  /**
   * The MimeMap class being processed.
   *
   * @var string
   */
  protected $mapClass;

  /**
   * An array of errors collected by the event.
   *
   * @var array
   */
  protected $errors = [];

  /**
   * Constructs the object.
   *
   * @param string $map_class
   *   The MimeMap class being processed.
   */
  public function __construct($map_class) {
    $this->mapClass = $map_class;
  }

  /**
   * Returns the MimeMap class being processed.
   *
   * @return string
   *   The MimeMap class being processed.
   */
  public function getMapClass() {
    return $this->mapClass;
  }

  /**
   * Adds an error.
   *
   * @param string $method
   *   An identifier of the method where the error occurred.
   * @param array $args
   *   An array of arguments passed to the method.
   * @param string $type
   *   An identifier of the type of the error.
   * @param string $message
   *   A messagge detailing the error.
   */
  public function addError($method, array $args, $type, $message) {
    $this->errors[] = [
      'method' => $method,
      'args' => $args,
      'type' => $type,
      'message' => $message,
    ];
    return $this;
  }

  /**
   * Returns the errors collected during the processing of the event.
   *
   * @return array
   *   The array of errors collected.
   */
  public function getErrors() {
    return $this->errors;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MapEvent::$errors protected property An array of errors collected by the event.
MapEvent::$mapClass protected property The MimeMap class being processed.
MapEvent::addError public function Adds an error.
MapEvent::getErrors public function Returns the errors collected during the processing of the event.
MapEvent::getMapClass public function Returns the MimeMap class being processed.
MapEvent::INIT constant Fires when a MimeMap map is initialized in Sophron.
MapEvent::__construct public function Constructs the object.