Ejemplo n.º 1
0
 /**
  * Execute the registered Adapters and return a processed response.
  *
  * @return array
  */
 public function execute()
 {
     // Fire the CRON Event and retrieve the results.
     $responses = $this->events->fire('cron.execute');
     // Extract the not null items from the responses.
     $result = array_filter($responses, function ($value) {
         return !is_null($value);
     });
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Call the given Route Filter.
  *
  * @param  string  $filter
  * @param  array  $parameters
  * @param  \Routing\Route  $route
  * @param  \Http\Request  $request
  * @return mixed
  */
 public function callRouteFilter($filter, $parameters, $route, $request, $response = null)
 {
     if (!$this->filtering) {
         return null;
     }
     $data = array_merge(array($route, $request, $response), $parameters);
     return $this->events->until('router.filter: ' . $filter, $this->cleanFilterParameters($data));
 }
Ejemplo n.º 3
0
 /**
  * Fires a log event.
  *
  * @param  string  $level
  * @param  string  $message
  * @param  array   $context
  * @return void
  */
 protected function fireLogEvent($level, $message, array $context = array())
 {
     // If the event dispatcher is set, we will pass along the parameters to the
     // log listeners. These are useful for building profilers or other tools
     // that aggregate all of the log messages for a given "request" cycle.
     if (isset($this->dispatcher)) {
         $this->dispatcher->fire('nova.log', compact('level', 'message', 'context'));
     }
 }
Ejemplo n.º 4
0
 /**
  * Send a Swift Message instance.
  *
  * @param  \Swift_Message  $message
  * @return void
  */
 protected function sendSwiftMessage($message)
 {
     if ($this->events) {
         $this->events->fire('mailer.sending', array($message));
     }
     if (!$this->pretending) {
         $this->swift->send($message, $this->failedRecipients);
     } else {
         if (isset($this->logger)) {
             $this->logMessage($message);
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Log the user out of the application.
  *
  * @return void
  */
 public function logout()
 {
     $user = $this->user();
     // If we have an event dispatcher instance, we can fire off the logout event
     // so any further processing can be done. This allows the developer to be
     // listening for anytime a user signs out of this application manually.
     $this->clearUserDataFromStorage();
     if (!is_null($this->user)) {
         $this->refreshRememberToken($user);
     }
     if (isset($this->events)) {
         $this->events->fire('auth.logout', array($user));
     }
     // Once we have fired the logout event we will clear the users out of memory
     // so they are no longer available as the user is no longer considered as
     // being signed into this application and should not be available here.
     $this->user = null;
     $this->loggedOut = true;
 }
 /**
  * Fire an event for this connection.
  *
  * @param  string  $event
  * @return void
  */
 protected function fireConnectionEvent($event)
 {
     if (isset($this->events)) {
         $this->events->fire('connection.' . $this->getName() . '.' . $event, $this);
     }
 }
Ejemplo n.º 7
0
 /**
  * Register a model event with the dispatcher.
  *
  * @param  string  $event
  * @param  \Closure|string  $callback
  * @return void
  */
 protected static function registerModelEvent($event, $callback)
 {
     if (isset(static::$dispatcher)) {
         $name = get_called_class();
         static::$dispatcher->listen("orm.{$event}: {$name}", $callback);
     }
 }
Ejemplo n.º 8
0
<?php

use Events\Dispatcher;
use Foundation\Application;
require __DIR__ . '/../vendor/autoload.php';
class Responder
{
    public function with($string)
    {
        echo $string;
    }
}
$application = new Application();
$dispatcher = new Dispatcher($application);
$dispatcher->add('respond', function (Responder $respond) {
    $respond->with('That actually just happened?');
});
$dispatcher->fire('respond');