[ Index ]

PHP Cross Reference of phpBB-3.3.11-deutsch

title

Body

[close]

/vendor/zendframework/zend-eventmanager/src/ -> LazyEventListener.php (source)

   1  <?php
   2  /**
   3   * Zend Framework (http://framework.zend.com/)
   4   *
   5   * @link      http://github.com/zendframework/zend-eventmanager for the canonical source repository
   6   * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
   7   * @license   https://github.com/zendframework/zend-eventmanager/blob/master/LICENSE.md
   8   */
   9  
  10  namespace Zend\EventManager;
  11  
  12  use Interop\Container\ContainerInterface;
  13  
  14  /**
  15   * Lazy listener instance for use with LazyListenerAggregate.
  16   *
  17   * Used as an internal class for the LazyAggregate to allow lazy creation of
  18   * listeners via a dependency injection container.
  19   *
  20   * Lazy event listener definitions add the following members to what the
  21   * LazyListener accepts:
  22   *
  23   * - event: the event name to attach to.
  24   * - priority: the priority at which to attach the listener, if not the default.
  25   */
  26  class LazyEventListener extends LazyListener
  27  {
  28      /**
  29       * @var string Event name to which to attach.
  30       */
  31      private $event;
  32  
  33      /**
  34       * @var null|int Priority at which to attach.
  35       */
  36      private $priority;
  37  
  38      /**
  39       * @param array $definition
  40       * @param ContainerInterface $container
  41       * @param array $env
  42       */
  43      public function __construct(array $definition, ContainerInterface $container, array $env = [])
  44      {
  45          parent::__construct($definition, $container, $env);
  46  
  47          if ((! isset($definition['event'])
  48              || ! is_string($definition['event'])
  49              || empty($definition['event']))
  50          ) {
  51              throw new Exception\InvalidArgumentException(
  52                  'Lazy listener definition is missing a valid "event" member; cannot create LazyListener'
  53              );
  54          }
  55  
  56          $this->event     = $definition['event'];
  57          $this->priority  = isset($definition['priority']) ? (int) $definition['priority'] : null;
  58      }
  59  
  60      /**
  61       * @return string
  62       */
  63      public function getEvent()
  64      {
  65          return $this->event;
  66      }
  67  
  68      /**
  69       * @return int
  70       */
  71      public function getPriority($default = 1)
  72      {
  73          return (null !== $this->priority) ? $this->priority : $default;
  74      }
  75  }


Generated: Sat Nov 4 14:26:03 2023 Cross-referenced by PHPXref 0.7.1