Example #1
0
 /**
  * The models in October use a static property to store their events, these
  * will need to be targeted and reset ready for a new test cycle.
  * Pivot models are an exception since they are internally managed.
  * @return void
  */
 protected function flushModelEventListeners()
 {
     foreach (get_declared_classes() as $class) {
         if ($class == 'October\\Rain\\Database\\Pivot') {
             continue;
         }
         $reflectClass = new ReflectionClass($class);
         if (!$reflectClass->isInstantiable() || !$reflectClass->isSubclassOf('October\\Rain\\Database\\Model') || $reflectClass->isSubclassOf('October\\Rain\\Database\\Pivot')) {
             continue;
         }
         $class::flushEventListeners();
     }
     ActiveRecord::flushEventListeners();
 }
Example #2
0
 /**
  * The models in October use a static property to store their events, these
  * will need to be targeted and reset ready for a new test cycle.
  * Pivot models are an exception since they are internally managed.
  * @return void
  */
 protected function flushModelEventListeners()
 {
     foreach (get_declared_classes() as $class) {
         if (!is_subclass_of($class, 'October\\Rain\\Database\\Model')) {
             continue;
         }
         if (is_subclass_of($class, 'October\\Rain\\Database\\Pivot')) {
             continue;
         }
         if ($class == 'October\\Rain\\Database\\Pivot') {
             continue;
         }
         $class::flushEventListeners();
     }
     ActiveRecord::flushEventListeners();
 }
 /**
  * Clears event listeners of available plugin models and boots them
  */
 protected final function rebootAllModels()
 {
     foreach (get_declared_classes() as $class) {
         /*
          * Reboot event listeners on all October\Rain\Database\Model subclasses
          * with exception of Pivot model that is a special, internal model for pivot tables
          * and should not be initialised outside of relation context.
          */
         if (is_subclass_of($class, 'October\\Rain\\Database\\Model') && $class !== 'October\\Rain\\Database\\Pivot' && !is_subclass_of($class, 'October\\Rain\\Database\\Pivot')) {
             $class::flushEventListeners();
         }
     }
     \October\Rain\Database\Model::flushEventListeners();
 }