Commit 01e41f3d authored by zYne's avatar zYne

added possibility for setting user-defined params

parent cdcaab1d
......@@ -186,6 +186,7 @@ final class Doctrine
const ATTR_LOAD_REFERENCES = 153;
const ATTR_RECORD_LISTENER = 154;
const ATTR_THROW_EXCEPTIONS = 155;
const ATTR_DEFAULT_PARAM_NAMESPACE = 156;
/**
* LIMIT CONSTANTS
......
......@@ -51,6 +51,11 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable
*/
protected $_impl = array();
/**
* @var array $_params an array of user defined parameters
*/
protected $_params = array();
/**
* setAttribute
* sets a given attribute
......@@ -116,6 +121,7 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable
case Doctrine::ATTR_LOAD_REFERENCES:
case Doctrine::ATTR_RECORD_LISTENER:
case Doctrine::ATTR_THROW_EXCEPTIONS:
case Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE:
break;
case Doctrine::ATTR_SEQCOL_NAME:
......@@ -143,6 +149,31 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable
}
public function setParam($name, $value, $namespace = null)
{
if ($namespace = null) {
$namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE);
}
$this->_params[$namespace][$name] = $value;
return $this;
}
public function getParam($name, $value, $namespace)
{
if ($namespace = null) {
$namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE);
}
if ( ! isset($this->_params[$name])) {
if (isset($this->parent)) {
return $this->parent->getParam($name);
}
return null;
}
return $this->_params[$name];
}
/**
* setImpl
* binds given class to given template name
......
......@@ -105,6 +105,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
Doctrine::ATTR_PORTABILITY => Doctrine::PORTABILITY_ALL,
Doctrine::ATTR_EXPORT => Doctrine::EXPORT_ALL,
Doctrine::ATTR_DECIMAL_PLACES => 2,
Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE => 'doctrine',
);
foreach ($attributes as $attribute => $value) {
$old = $this->getAttribute($attribute);
......
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