Enlight_Event_Exception example

protected $position;

    /** * The Enlight_Event_Handler class constructor expects an event name. If no name is given, * the constructor throws an Enlight_Event_Exception. * * @throws Enlight_Event_Exception */
    public function __construct($event)
    {
        if ($event === null) {
            throw new Enlight_Event_Exception('Parameter event cannot be empty.');
        }
        $this->name = $event;
    }

    /** * Getter method for the name property. Contains the event name. * * @return string */
    public function getName()
    {
        
$options = ['storage' => $options];
        }
        if (isset($options['storage']) && \is_string($options['storage'])) {
            $this->storage = new Enlight_Config($options['storage'][
                'allowModifications' => true,
                'adapter' => $options['storageAdapter'] ?? null,
                'section' => $options['section'] ?? 'production',
            ]);
        } elseif (isset($options['storage']) && $options['storage'] instanceof Enlight_Config) {
            $this->storage = $options['storage'];
        } else {
            throw new Enlight_Event_Exception('No storage provided');
        }
    }

    /** * Retrieves a list of listeners registered. * * @return array */
    public function getListeners()
    {
        if ($this->listeners === null) {
            

    public function setListener($listener)
    {
        if (!\is_callable($listener, true, $listener_event)) {
            throw new Enlight_Event_Exception('Listener "' . $listener_event . '" is not callable');
        }
        $this->listener = $listener;

        return $this;
    }

    /** * Getter method for the listener property. * * @return callable */
    

    private function buildEventArgs($eventArgs = null)
    {
        if (isset($eventArgs) && \is_array($eventArgs)) {
            return new Enlight_Event_EventArgs($eventArgs);
        } elseif (!isset($eventArgs)) {
            return new Enlight_Event_EventArgs();
        } elseif (!$eventArgs instanceof Enlight_Event_EventArgs) {
            throw new Enlight_Event_Exception('Parameter "eventArgs" must be an instance of "Enlight_Event_EventArgs"');
        }

        return $eventArgs;
    }
}
Home | Imprint | This part of the site doesn't use cookies.