CI_Driver::decorate PHP Méthode

decorate() public méthode

Decorates the child with the parent driver lib's methods and properties
public decorate ( $parent ) : void
Résultat void
    public function decorate($parent)
    {
        $this->_parent = $parent;
        // Lock down attributes to what is defined in the class
        // and speed up references in magic methods
        $class_name = get_class($parent);
        if (!isset(self::$_reflections[$class_name])) {
            $r = new ReflectionObject($parent);
            foreach ($r->getMethods() as $method) {
                if ($method->isPublic()) {
                    $this->_methods[] = $method->getName();
                }
            }
            foreach ($r->getProperties() as $prop) {
                if ($prop->isPublic()) {
                    $this->_properties[] = $prop->getName();
                }
            }
            self::$_reflections[$class_name] = array($this->_methods, $this->_properties);
        } else {
            list($this->_methods, $this->_properties) = self::$_reflections[$class_name];
        }
    }

Usage Example

 /**
  * Decorate
  *
  * Decorates the child with the parent driver lib's methods and properties
  *
  * @param	object	Parent library object
  * @return	void
  */
 public function decorate($parent)
 {
     // Call base class decorate first
     parent::decorate($parent);
     // Call initialize method now that driver has access to $this->_parent
     $this->initialize();
 }