/** * @param string $constant * * @return mixed|null */ function get_constant($constant) { if (is_null($value = parent::get_constant($constant))) { $value = $this->owner->get_constant($constant); } return $value; }
/** * @param array $elements * @param array $args */ function __construct($elements = array(), $args = array()) { $this->_elements = $elements; parent::__construct($args); if ($this->_index_by) { $this->_reindex_elements(); } }
/** * @param array $args */ function __construct($args = array()) { /** * For both model and view, create the items. */ foreach (array('model', 'view') as $property_name) { if (!isset($args[$property_name])) { /* * If no model or view class was specified then use the default. */ $args[$property_name] = $this->_get_property_class($property_name); } if (is_object($args[$property_name])) { /* * If it was an object, just assign is. */ $this->{$property_name} = $args[$property_name]; } else { if (is_string($args[$property_name])) { /** * It's a class name thus needs no $args */ $class_name = $args[$property_name]; $property_args = array(); } else { if (is_array($args[$property_name])) { /** * It's an array of args, so use the default class name */ $class_name = $this->_get_property_class($property_name); $property_args = $args[$property_name]; } } if (method_exists($class_name, 'make_new')) { /* * If this class has a make_new() method. * A Class::make_new() method is needed when the class constructor has more than 1 parameter of $args. */ $this->{$property_name} = $class_name::make_new($property_args); } else { if (class_exists($class_name)) { /* * If an array or string, instantiate the class. */ $this->{$property_name} = new $class_name($property_args); } else { $this->{$property_name} = null; } } } if (is_object($this->{$property_name}) && property_exists($this->{$property_name}, 'owner')) { /** * Set a reference back to the item for both $view and $model. */ $this->{$property_name}->owner = $this; } /** * Remove processed args to prevent overwriting them later. */ unset($args[$property_name]); } parent::__construct($args); if (count($this->extra_args)) { /** * If there are any leftover args, see if we can assign them to */ $this->model->set_state($this->extra_args); /** * Any extra args will be left in model. */ $this->extra_args = array(); } }