Webiny\Component\EventManager\EventManager::fire PHP Method

fire() public method

Fire event
public fire ( string $eventName, array | Event $data = null, null $resultType = null, null | integer $limit = null ) : array
$eventName string Event to fire. You can also use wildcards to fire multiple events at once, ex: 'event.*'
$data array | Event Array or Event object
$resultType null If specified, the event results will be filtered using given class/interface name
$limit null | integer Number of results to return
return array Array of results from EventListeners
    public function fire($eventName, $data = null, $resultType = null, $limit = null)
    {
        if ($this->suppressEvents) {
            return null;
        }
        if ($this->str($eventName)->endsWith('*')) {
            return $this->fireWildcardEvents($eventName, $data, $resultType);
        }
        if (!$this->events->keyExists($eventName)) {
            return null;
        }
        $eventListeners = $this->events->key($eventName);
        if (!$this->isInstanceOf($data, '\\Webiny\\Component\\EventManager\\Event')) {
            $data = new Event($data);
        }
        return $this->eventProcessor->process($eventListeners, $data, $resultType, $limit);
    }

Usage Example

Beispiel #1
0
 /**
  * @param Node\Scalar $scalar
  * @return CompiledExpression
  */
 public function compile(Node\Scalar $scalar)
 {
     try {
         $this->eventManager->fire(Event\ScalarBeforeCompile::EVENT_NAME, new Event\ScalarBeforeCompile($scalar, $this->context));
         return $this->factory($scalar);
     } catch (\Exception $e) {
         $this->context->debug('ScalarCompiler is not implemented for ' . get_class($scalar));
     }
 }
All Usage Examples Of Webiny\Component\EventManager\EventManager::fire