merge() public method

The merged into database (self) takes precedence of the merged in database in FIFO.
public merge ( $array ) : void
return void
Ejemplo n.º 1
0
 /**
  * Emits a signal.
  *
  * @param  object  $signal  \XPSPL\SIG
  *
  * @return  object  Event
  */
 public function emit(SIG $signal)
 {
     if (XPSPL_DEBUG) {
         logger(XPSPL_LOG)->debug(sprintf('%s emitted', $signal));
     }
     // Store the history of the signal
     if (false !== $this->_history) {
         $this->_history[] = [$signal, microtime()];
     }
     // Set child status
     if (count($this->_signal) > 1) {
         $signal->set_parent($this->current_signal());
     }
     // Check if signal is installed
     $memory = $this->find_signal_database($signal);
     if (null === $memory) {
         $memory = new \XPSPL\database\Processes();
     } else {
         if (XPSPL_DEBUG) {
             logger(XPSPL_LOG)->debug('Signal with no installed processes emitted');
         }
     }
     // Evaluate complex signals
     $evaluated = $this->evaluate_signals($signal);
     if (null !== $evaluated) {
         foreach ($evaluated as $_db) {
             $memory->merge($_db);
         }
     }
     // Execute if we have processes
     if ($memory->count() > 0) {
         // Set as currently executing signal
         $this->_signal[] = $signal;
         // Execute
         $this->_execute($signal, $memory);
         // Remove once finished
         array_pop($this->_signal);
     }
     return $signal;
 }