src/bbn/db.php
private function _trigger(array $cfg): array
  {
    if ( $this->triggers_disabled ){
      $cfg['run'] = 1;
      $cfg['trig'] = 1;
      return $cfg;
    }
    if ( !isset($cfg['trig']) ){
      $cfg['trig'] = 1;
    }
    if ( !isset($cfg['run']) ){
      $cfg['run'] = 1;
    }
    if ( !empty($cfg['tables']) && !empty($this->triggers[$cfg['kind']][$cfg['moment']]) ){

      $table = $this->tfn(\is_array($cfg['tables']) ? current($cfg['tables']) : $cfg['tables']);
      // Specific to a table
      if ( isset($this->triggers[$cfg['kind']][$cfg['moment']][$table]) ){
        foreach ( $this->triggers[$cfg['kind']][$cfg['moment']][$table] as $i => $f ){
          if ( $f && \is_callable($f) ){
            if ( !($tmp = $f($cfg)) ){
              $cfg['run'] = false;
              $cfg['trig'] = false;
            }
            else{
              $cfg = $tmp;
            }
          }
        }
        //echo bbn\x::make_tree($trig);
        //echo x::make_tree($cfg);
      }
    }
    return $cfg;
  }
private function _trigger(array $cfg): array
  {
    if ( $this->triggers_disabled ){
      $cfg['run'] = 1;
      $cfg['trig'] = 1;
      return $cfg;
    }
    if ( !isset($cfg['trig']) ){
      $cfg['trig'] = 1;
    }
    if ( !isset($cfg['run']) ){
      $cfg['run'] = 1;
    }
    if ( !empty($cfg['tables']) && !empty($this->triggers[$cfg['kind']][$cfg['moment']]) ){

      $table = $this->tfn(\is_array($cfg['tables']) ? current($cfg['tables']) : $cfg['tables']);
      // Specific to a table
      if ( isset($this->triggers[$cfg['kind']][$cfg['moment']][$table]) ){
        foreach ( $this->triggers[$cfg['kind']][$cfg['moment']][$table] as $i => $f ){
          if ( $f && \is_callable($f) ){
            if ( !($tmp = $f($cfg)) ){
              $cfg['run'] = false;
              $cfg['trig'] = false;
            }
            else{
              $cfg = $tmp;
            }
          }
        }
        //echo bbn\x::make_tree($trig);
        //echo x::make_tree($cfg);
      }
    }
    return $cfg;
  }
private function _trigger ( array $ cfg ) : array { if ( $ this -> triggers_disabled ) { $ cfg [ 'run' ] = 1 ; $ cfg [ 'trig' ] = 1 ; return $ cfg ; } if ( ! isset ( $ cfg [ 'trig' ] ) ) { $ cfg [ 'trig' ] = 1 ; } if ( ! isset ( $ cfg [ 'run' ] ) ) { $ cfg [ 'run' ] = 1 ; } if ( ! empty ( $ cfg [ 'tables' ] ) && ! empty ( $ this -> triggers [ $ cfg [ 'kind' ] ] [ $ cfg [ 'moment' ] ] ) ) { $ table = $ this -> tfn ( \ is_array ( $ cfg [ 'tables' ] ) ? current ( $ cfg [ 'tables' ] ) : $ cfg [ 'tables' ] ) ; // Specific to a table if ( isset ( $ this -> triggers [ $ cfg [ 'kind' ] ] [ $ cfg [ 'moment' ] ] [ $ table ] ) ) { foreach ( $ this -> triggers [ $ cfg [ 'kind' ] ] [ $ cfg [ 'moment' ] ] [ $ table ] as $ i => $ f ) { if ( $ f && \ is_callable ( $ f ) ) { if ( ! ( $ tmp = $ f ( $ cfg ) ) ) { $ cfg [ 'run' ] = false ; $ cfg [ 'trig' ] = false ; } else { $ cfg = $ tmp ; } } } //echo bbn\x::make_tree($trig); //echo x::make_tree($cfg); } } return $ cfg ; }
Launches a function before or after

@param array $cfg
@return array
Launches a function before or after