Commit ab76c18f authored by zYne's avatar zYne

--no commit message

--no commit message
parent 013bdebe
...@@ -38,9 +38,15 @@ abstract class Doctrine_Configurable extends Doctrine_Object ...@@ -38,9 +38,15 @@ abstract class Doctrine_Configurable extends Doctrine_Object
*/ */
protected $attributes = array(); protected $attributes = array();
/** /**
* @var $parent the parents of this component * @var Doctrine_Configurable $parent the parent of this component
*/ */
protected $parent; protected $parent;
/**
* @var array $_impl an array containing concrete implementations for class templates
* keys as template names and values as names of the concrete
* implementation classes
*/
protected $_impl = array();
/** /**
* setAttribute * setAttribute
* sets a given attribute * sets a given attribute
...@@ -145,11 +151,43 @@ abstract class Doctrine_Configurable extends Doctrine_Object ...@@ -145,11 +151,43 @@ abstract class Doctrine_Configurable extends Doctrine_Object
break; break;
default: default:
throw new Doctrine_Exception("Unknown attribute."); throw new Doctrine_Exception("Unknown attribute.");
}; }
$this->attributes[$attribute] = $value; $this->attributes[$attribute] = $value;
} }
/**
* setImpl
* binds given class to given template name
*
* this method is the base of Doctrine dependency injection
*
* @param string $template name of the class template
* @param string $class name of the class to be bound
* @return Doctrine_Configurable this object
*/
public function setImpl($template, $class)
{
$this->_impl[$template] = $class;
return $this;
}
/**
* getImpl
* returns the implementation for given class
*
* @return string name of the concrete implementation
*/
public function getImpl($template)
{
if ( ! isset($this->_impl[$attribute])) {
if (isset($this->parent)) {
return $this->parent->getImpl($attribute);
}
return null;
}
return $this->_impl[$attribute];
}
/** /**
* getCacheDriver * getCacheDriver
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment