Ejemplo n.º 1
0
 /**
  * @param QueryBuilderHandler $queryBuilder
  * @param                     $event
  * @return mixed
  */
 public function fireEvents($queryBuilder, $event)
 {
     $statements = $queryBuilder->getStatements();
     $tables = isset($statements['tables']) ? $statements['tables'] : array();
     // Events added with :any will be fired in case of any table,
     // we are adding :any as a fake table at the beginning.
     array_unshift($tables, ':any');
     // Fire all events
     foreach ($tables as $table) {
         // Fire before events for :any table
         if ($action = $this->getEvent($event, $table)) {
             // Make an event id, with event type and table
             $eventId = $event . $table;
             // Fire event
             $handlerParams = func_get_args();
             unset($handlerParams[1]);
             // we do not need $event
             // Add to fired list
             $this->firedEvents[] = $eventId;
             $result = call_user_func_array($action, $handlerParams);
             if (!is_null($result)) {
                 return $result;
             }
         }
     }
 }