PHP Classes

File: src/Utils/Traits/Event.php

Recommend this page to a friend!
  Classes of Thierry Feuzeu   Jaxon   src/Utils/Traits/Event.php   Download  
File: src/Utils/Traits/Event.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Jaxon
Call PHP classes from JavaScript using AJAX
Author: By
Last change:
Date: 7 years ago
Size: 1,268 bytes
 

Contents

Class file image Download
<?php

/**
 * EventListener.php - Trait for event listener and dispatcher.
 *
 * @package jaxon-core
 * @author Thierry Feuzeu <thierry.feuzeu@gmail.com>
 * @copyright 2016 Thierry Feuzeu <thierry.feuzeu@gmail.com>
 * @license https://opensource.org/licenses/BSD-2-Clause BSD 2-Clause License
 * @link https://github.com/jaxon-php/jaxon-core
 */

namespace Jaxon\Utils\Traits;

use
Jaxon\Utils\Container as JaxonContainer;

trait
Event
{
   
/**
     * Trigger an event.
     *
     * @param string $sEvent The event name
     *
     * @return void
     */
   
public function triggerEvent($sEvent)
    {
       
JaxonContainer::getInstance()->getEventDispatcher()->dispatch($sEvent);
    }

   
/**
     * Return an array of events to listen to.
     *
     * This is the default implementation on the EventListener interface.
     *
     * @return array An empty array
     */
   
public function getEvents()
    {
        return [];
    }

   
/**
     * Return an array of events to listen to.
     *
     * This is the implementation of the Lemon\Event\EventSubscriberInterface interface.
     *
     * @return array The event names to listen to
     */
   
public function getSubscribedEvents()
    {
        return
$this->getEvents();
    }
}