1
0
mirror of synced 2025-01-18 06:21:40 +03:00

added possibility for setting user-defined params

This commit is contained in:
zYne 2007-11-01 22:52:40 +00:00
parent cdcaab1d90
commit 01e41f3d27
3 changed files with 58 additions and 25 deletions

View File

@ -176,16 +176,17 @@ final class Doctrine
const ATTR_USE_NATIVE_ENUM = 117;
const ATTR_DEFAULT_SEQUENCE = 133;
const ATTR_FETCHMODE = 118;
const ATTR_NAME_PREFIX = 121;
const ATTR_CREATE_TABLES = 122;
const ATTR_COLL_LIMIT = 123;
const ATTR_FETCHMODE = 118;
const ATTR_NAME_PREFIX = 121;
const ATTR_CREATE_TABLES = 122;
const ATTR_COLL_LIMIT = 123;
const ATTR_CACHE = 150;
const ATTR_CACHE_LIFESPAN = 151;
const ATTR_LOAD_REFERENCES = 153;
const ATTR_RECORD_LISTENER = 154;
const ATTR_THROW_EXCEPTIONS = 155;
const ATTR_CACHE = 150;
const ATTR_CACHE_LIFESPAN = 151;
const ATTR_LOAD_REFERENCES = 153;
const ATTR_RECORD_LISTENER = 154;
const ATTR_THROW_EXCEPTIONS = 155;
const ATTR_DEFAULT_PARAM_NAMESPACE = 156;
/**
* LIMIT CONSTANTS
@ -1040,4 +1041,4 @@ final class Doctrine
return mkdir($path, $mode, true);
}
}
}

View File

@ -50,6 +50,11 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable
* implementation classes
*/
protected $_impl = array();
/**
* @var array $_params an array of user defined parameters
*/
protected $_params = array();
/**
* setAttribute
@ -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

View File

@ -90,21 +90,22 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
if ( ! $init) {
$init = true;
$attributes = array(
Doctrine::ATTR_CACHE => null,
Doctrine::ATTR_LOAD_REFERENCES => true,
Doctrine::ATTR_LISTENER => new Doctrine_EventListener(),
Doctrine::ATTR_RECORD_LISTENER => new Doctrine_Record_Listener(),
Doctrine::ATTR_THROW_EXCEPTIONS => true,
Doctrine::ATTR_VALIDATE => Doctrine::VALIDATE_NONE,
Doctrine::ATTR_QUERY_LIMIT => Doctrine::LIMIT_RECORDS,
Doctrine::ATTR_IDXNAME_FORMAT => "%s_idx",
Doctrine::ATTR_SEQNAME_FORMAT => "%s_seq",
Doctrine::ATTR_TBLNAME_FORMAT => "%s",
Doctrine::ATTR_QUOTE_IDENTIFIER => false,
Doctrine::ATTR_SEQCOL_NAME => 'id',
Doctrine::ATTR_PORTABILITY => Doctrine::PORTABILITY_ALL,
Doctrine::ATTR_EXPORT => Doctrine::EXPORT_ALL,
Doctrine::ATTR_DECIMAL_PLACES => 2,
Doctrine::ATTR_CACHE => null,
Doctrine::ATTR_LOAD_REFERENCES => true,
Doctrine::ATTR_LISTENER => new Doctrine_EventListener(),
Doctrine::ATTR_RECORD_LISTENER => new Doctrine_Record_Listener(),
Doctrine::ATTR_THROW_EXCEPTIONS => true,
Doctrine::ATTR_VALIDATE => Doctrine::VALIDATE_NONE,
Doctrine::ATTR_QUERY_LIMIT => Doctrine::LIMIT_RECORDS,
Doctrine::ATTR_IDXNAME_FORMAT => "%s_idx",
Doctrine::ATTR_SEQNAME_FORMAT => "%s_seq",
Doctrine::ATTR_TBLNAME_FORMAT => "%s",
Doctrine::ATTR_QUOTE_IDENTIFIER => false,
Doctrine::ATTR_SEQCOL_NAME => 'id',
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);