/** * Add the filter to the correct hash. * * @return void * @author Justin Palmer **/ private function add($type, $filter, array $actions) { //If no actions were specified we will add all of the actions of this //controller to the actions array. if (empty($actions)) { $r = new Reflections($this->controller); $actions = $r->getPublicChildMethods(); } //Get the hash that has the correct type in it. $Set = $this->filters->get($type); //Is the filter passed in already in the hash? if ($Set->isKey($filter)) { $array = $Set->get($filter); $array = array_merge($array, $actions); $Set->set($filter, $array); } else { $Set->set($filter, $actions); } $this->filters->set($type, $Set); }
public static function reflectorOf(callable $callable) : \ReflectionFunctionAbstract { if (is_array($callable) && count($callable) > 1) { $className = $callable[0]; $methodName = $callable[1]; return Reflections::reflectionClassOf($className)->getMethod($methodName); } elseif (is_string($callable)) { } elseif (is_object($callable)) { } return Reflections::reflectionFunctionOf($callable); }
public function __construct($class_name) { $this->class = Reflections::instance()->add($class_name)->get($class_name); $this->reestablish_connection(false); $this->set_table_name(); $this->get_meta_data(); $this->set_primary_key(); $this->set_sequence_name(); $this->set_delegates(); $this->set_setters_and_getters(); $this->callback = new CallBack($class_name); $this->callback->register('before_save', function (Model $model) { $model->set_timestamps(); }, array('prepend' => true)); $this->callback->register('after_save', function (Model $model) { $model->reset_dirty(); }, array('prepend' => true)); }
public function __construct($className) { $this->class = Reflections::instance()->add($className)->get($className); $this->reestablishConnection(false); $this->setTableName(); $this->getMetaData(); $this->setPrimaryKey(); $this->setSequenceName(); $this->setDelegates(); $this->setSettersAndGetters(); $this->callback = new CallBack($className); $this->callback->register('beforeSave', function (Model $model) { $model->setTimestamps(); }, array('prepend' => true)); $this->callback->register('afterSave', function (Model $model) { $model->resetDirty(); }, array('prepend' => true)); }
public function __construct($class_name) { $this->class = Reflections::instance()->add($class_name)->get($class_name); // if connection name property is null the connection manager will use the default connection $connection = $this->class->getStaticPropertyValue('connection', null); $this->conn = ConnectionManager::get_connection($connection); $this->set_table_name(); $this->get_meta_data(); $this->set_primary_key(); $this->set_sequence_name(); $this->set_delegates(); $this->set_setters_and_getters(); $this->callback = new CallBack($class_name); $this->callback->register('before_save', function (Model $model) { $model->set_timestamps(); }, array('prepend' => true)); $this->callback->register('after_save', function (Model $model) { $model->reset_dirty(); }, array('prepend' => true)); }
protected function set_class_name($class_name) { $reflection = Reflections::instance()->add($class_name)->get($class_name); if (!$reflection->isSubClassOf('ActiveRecord\\Model')) { throw new RelationshipException("'{$class_name}' must extend from ActiveRecord\\Model"); } $this->class_name = $class_name; }
protected function set_class_name($class_name) { if (!has_absolute_namespace($class_name) && isset($this->options['namespace'])) { $class_name = $this->options['namespace'] . '\\' . $class_name; } $reflection = Reflections::instance()->add($class_name)->get($class_name); if (!$reflection->isSubClassOf('ActiveRecord\\Model')) { throw new RelationshipException("'{$class_name}' must extend from ActiveRecord\\Model"); } $this->class_name = $class_name; }
protected function set_class_name($class_name) { try { $reflection = Reflections::instance()->add($class_name)->get($class_name); } catch (\ReflectionException $e) { if (isset($this->options['namespace'])) { $class_name = $this->options['namespace'] . '\\' . $class_name; $reflection = Reflections::instance()->add($class_name)->get($class_name); } else { throw $e; } } if (!$reflection->isSubClassOf('ActiveRecord\\Model')) { throw new RelationshipException("'{$class_name}' must extend from ActiveRecord\\Model"); } $this->class_name = $class_name; }