Commit 2d24e9ad authored by lsmith's avatar lsmith

- lazy load the _tableFactory and record listener in order to reduce the...

- lazy load the _tableFactory and record listener in order to reduce the dependencies for a to be created DBAL package
parent 3a5bd47f
...@@ -50,7 +50,7 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable ...@@ -50,7 +50,7 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable
* implementation classes * implementation classes
*/ */
protected $_impl = array(); protected $_impl = array();
/** /**
* @var array $_params an array of user defined parameters * @var array $_params an array of user defined parameters
*/ */
...@@ -175,36 +175,36 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable ...@@ -175,36 +175,36 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable
if ($namespace == null) { if ($namespace == null) {
$namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE); $namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE);
} }
if ( ! isset($this->_params[$namespace])) { if ( ! isset($this->_params[$namespace])) {
return null; return null;
} }
return $this->_params[$namespace]; return $this->_params[$namespace];
} }
public function getParamNamespaces() public function getParamNamespaces()
{ {
return array_keys($this->_params); return array_keys($this->_params);
} }
public function setParam($name, $value, $namespace = null) public function setParam($name, $value, $namespace = null)
{ {
if ($namespace == null) { if ($namespace == null) {
$namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE); $namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE);
} }
$this->_params[$namespace][$name] = $value; $this->_params[$namespace][$name] = $value;
return $this; return $this;
} }
public function getParam($name, $value, $namespace) public function getParam($name, $value, $namespace)
{ {
if ($namespace == null) { if ($namespace == null) {
$namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE); $namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE);
} }
if ( ! isset($this->_params[$name])) { if ( ! isset($this->_params[$name])) {
if (isset($this->parent)) { if (isset($this->parent)) {
return $this->parent->getParam($name); return $this->parent->getParam($name);
...@@ -213,7 +213,7 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable ...@@ -213,7 +213,7 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable
} }
return $this->_params[$name]; return $this->_params[$name];
} }
/** /**
* setImpl * setImpl
* binds given class to given template name * binds given class to given template name
...@@ -247,8 +247,8 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable ...@@ -247,8 +247,8 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable
} }
return $this->_impl[$template]; return $this->_impl[$template];
} }
public function hasImpl($template) public function hasImpl($template)
{ {
if ( ! isset($this->_impl[$template])) { if ( ! isset($this->_impl[$template])) {
...@@ -298,7 +298,7 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable ...@@ -298,7 +298,7 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable
if (isset($this->parent)) { if (isset($this->parent)) {
return $this->parent->getRecordListener(); return $this->parent->getRecordListener();
} }
return null; $this->attributes[Doctrine::ATTR_RECORD_LISTENER] = new Doctrine_Record_Listener();
} }
return $this->attributes[Doctrine::ATTR_RECORD_LISTENER]; return $this->attributes[Doctrine::ATTR_RECORD_LISTENER];
} }
...@@ -390,7 +390,7 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable ...@@ -390,7 +390,7 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable
if (isset($this->attributes[$attribute])) { if (isset($this->attributes[$attribute])) {
return $this->attributes[$attribute]; return $this->attributes[$attribute];
} }
if (isset($this->parent)) { if (isset($this->parent)) {
return $this->parent->getAttribute($attribute); return $this->parent->getAttribute($attribute);
} }
......
This diff is collapsed.
...@@ -63,7 +63,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -63,7 +63,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
* @var Doctrine_Query_Registry the query registry * @var Doctrine_Query_Registry the query registry
*/ */
protected $_queryRegistry; protected $_queryRegistry;
protected static $driverMap = array('oci' => 'oracle'); protected static $driverMap = array('oci' => 'oracle');
/** /**
...@@ -95,7 +95,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -95,7 +95,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
Doctrine::ATTR_QUERY_CACHE => null, Doctrine::ATTR_QUERY_CACHE => null,
Doctrine::ATTR_LOAD_REFERENCES => true, Doctrine::ATTR_LOAD_REFERENCES => true,
Doctrine::ATTR_LISTENER => new Doctrine_EventListener(), Doctrine::ATTR_LISTENER => new Doctrine_EventListener(),
Doctrine::ATTR_RECORD_LISTENER => new Doctrine_Record_Listener(), Doctrine::ATTR_RECORD_LISTENER => null,
Doctrine::ATTR_THROW_EXCEPTIONS => true, Doctrine::ATTR_THROW_EXCEPTIONS => true,
Doctrine::ATTR_VALIDATE => Doctrine::VALIDATE_NONE, Doctrine::ATTR_VALIDATE => Doctrine::VALIDATE_NONE,
Doctrine::ATTR_QUERY_LIMIT => Doctrine::LIMIT_RECORDS, Doctrine::ATTR_QUERY_LIMIT => Doctrine::LIMIT_RECORDS,
...@@ -109,7 +109,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -109,7 +109,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
Doctrine::ATTR_DECIMAL_PLACES => 2, Doctrine::ATTR_DECIMAL_PLACES => 2,
Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE => 'doctrine', Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE => 'doctrine',
Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES => true, Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES => true,
); );
foreach ($attributes as $attribute => $value) { foreach ($attributes as $attribute => $value) {
$old = $this->getAttribute($attribute); $old = $this->getAttribute($attribute);
if ($old === null) { if ($old === null) {
...@@ -170,16 +170,16 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -170,16 +170,16 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
public function setQueryRegistry(Doctrine_Query_Registry $registry) public function setQueryRegistry(Doctrine_Query_Registry $registry)
{ {
$this->_queryRegistry = $registry; $this->_queryRegistry = $registry;
return $this; return $this;
} }
/** /**
* fetch * fetch
* fetches data using the provided queryKey and * fetches data using the provided queryKey and
* the associated query in the query registry * the associated query in the query registry
* *
* if no query for given queryKey is being found a * if no query for given queryKey is being found a
* Doctrine_Query_Registry exception is being thrown * Doctrine_Query_Registry exception is being thrown
* *
* @param string $queryKey the query key * @param string $queryKey the query key
...@@ -196,10 +196,10 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -196,10 +196,10 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
/** /**
* fetchOne * fetchOne
* fetches data using the provided queryKey and * fetches data using the provided queryKey and
* the associated query in the query registry * the associated query in the query registry
* *
* if no query for given queryKey is being found a * if no query for given queryKey is being found a
* Doctrine_Query_Registry exception is being thrown * Doctrine_Query_Registry exception is being thrown
* *
* @param string $queryKey the query key * @param string $queryKey the query key
...@@ -269,7 +269,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -269,7 +269,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
$parts['scheme'] = $e[0]; $parts['scheme'] = $e[0];
$parts['user'] = (isset($adapter[1])) ? $adapter[1] : null; $parts['user'] = (isset($adapter[1])) ? $adapter[1] : null;
$parts['pass'] = (isset($adapter[2])) ? $adapter[2] : null; $parts['pass'] = (isset($adapter[2])) ? $adapter[2] : null;
$driverName = $e[0]; $driverName = $e[0];
$adapter = $parts; $adapter = $parts;
} else { } else {
...@@ -305,11 +305,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -305,11 +305,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
'firebird' => 'Doctrine_Connection_Firebird', 'firebird' => 'Doctrine_Connection_Firebird',
'informix' => 'Doctrine_Connection_Informix', 'informix' => 'Doctrine_Connection_Informix',
'mock' => 'Doctrine_Connection_Mock'); 'mock' => 'Doctrine_Connection_Mock');
if ( ! isset($drivers[$driverName])) { if ( ! isset($drivers[$driverName])) {
throw new Doctrine_Manager_Exception('Unknown driver ' . $driverName); throw new Doctrine_Manager_Exception('Unknown driver ' . $driverName);
} }
$className = $drivers[$driverName]; $className = $drivers[$driverName];
$conn = new $className($this, $adapter); $conn = new $className($this, $adapter);
$conn->setName($name); $conn->setName($name);
...@@ -321,17 +321,17 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -321,17 +321,17 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
} }
return $this->_connections[$name]; return $this->_connections[$name];
} }
/** /**
* parsePdoDsn * parsePdoDsn
* *
* @param array $dsn An array of dsn information * @param array $dsn An array of dsn information
* @return array The array parsed * @return array The array parsed
*/ */
public function parsePdoDsn($dsn) public function parsePdoDsn($dsn)
{ {
$parts = array(); $parts = array();
$names = array('dsn', 'scheme', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment'); $names = array('dsn', 'scheme', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment');
foreach ($names as $name) { foreach ($names as $name) {
...@@ -339,11 +339,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -339,11 +339,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
$parts[$name] = null; $parts[$name] = null;
} }
} }
$e = explode(':', $dsn); $e = explode(':', $dsn);
$parts['scheme'] = $e[0]; $parts['scheme'] = $e[0];
$parts['dsn'] = $dsn; $parts['dsn'] = $dsn;
$e = explode(';', $e[1]); $e = explode(';', $e[1]);
foreach ($e as $string) { foreach ($e as $string) {
if ($string) { if ($string) {
...@@ -370,7 +370,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -370,7 +370,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
// fix sqlite dsn so that it will parse correctly // fix sqlite dsn so that it will parse correctly
$dsn = str_replace("////", "/", $dsn); $dsn = str_replace("////", "/", $dsn);
$dsn = str_replace("///c:/", "//c:/", $dsn); $dsn = str_replace("///c:/", "//c:/", $dsn);
// silence any warnings // silence any warnings
$parts = @parse_url($dsn); $parts = @parse_url($dsn);
...@@ -404,7 +404,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -404,7 +404,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
} }
break; break;
case 'mssql': case 'mssql':
case 'dblib': case 'dblib':
if ( ! isset($parts['path']) || $parts['path'] == '/') { if ( ! isset($parts['path']) || $parts['path'] == '/') {
...@@ -416,7 +416,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -416,7 +416,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
if ( ! isset($parts['host'])) { if ( ! isset($parts['host'])) {
throw new Doctrine_Manager_Exception('No hostname set in data source name'); throw new Doctrine_Manager_Exception('No hostname set in data source name');
} }
if (isset(self::$driverMap[$parts['scheme']])) { if (isset(self::$driverMap[$parts['scheme']])) {
$parts['scheme'] = self::$driverMap[$parts['scheme']]; $parts['scheme'] = self::$driverMap[$parts['scheme']];
} }
...@@ -424,7 +424,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -424,7 +424,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
$parts['dsn'] = $parts['scheme'] . ':host=' $parts['dsn'] = $parts['scheme'] . ':host='
. $parts['host'] . (isset($parts['port']) ? ':' . $parts['port']:null) . ';dbname=' . $parts['host'] . (isset($parts['port']) ? ':' . $parts['port']:null) . ';dbname='
. $parts['database']; . $parts['database'];
break; break;
case 'mysql': case 'mysql':
...@@ -445,7 +445,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -445,7 +445,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
if ( ! isset($parts['host'])) { if ( ! isset($parts['host'])) {
throw new Doctrine_Manager_Exception('No hostname set in data source name'); throw new Doctrine_Manager_Exception('No hostname set in data source name');
} }
if (isset(self::$driverMap[$parts['scheme']])) { if (isset(self::$driverMap[$parts['scheme']])) {
$parts['scheme'] = self::$driverMap[$parts['scheme']]; $parts['scheme'] = self::$driverMap[$parts['scheme']];
} }
...@@ -453,7 +453,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -453,7 +453,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
$parts['dsn'] = $parts['scheme'] . ':host=' $parts['dsn'] = $parts['scheme'] . ':host='
. $parts['host'] . (isset($parts['port']) ? ';port=' . $parts['port']:null) . ';dbname=' . $parts['host'] . (isset($parts['port']) ? ';port=' . $parts['port']:null) . ';dbname='
. $parts['database']; . $parts['database'];
break; break;
default: default:
throw new Doctrine_Manager_Exception('Unknown driver '.$parts['scheme']); throw new Doctrine_Manager_Exception('Unknown driver '.$parts['scheme']);
...@@ -550,7 +550,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -550,7 +550,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
} }
return $this->getCurrentConnection(); return $this->getCurrentConnection();
} }
/** /**
* hasConnectionForComponent * hasConnectionForComponent
* *
...@@ -575,7 +575,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -575,7 +575,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
{ {
return $this->getConnectionForComponent($componentName)->getTable($componentName); return $this->getConnectionForComponent($componentName)->getTable($componentName);
} }
/** /**
* getMapper * getMapper
* Returns the mapper object for the given component name. * Returns the mapper object for the given component name.
...@@ -770,4 +770,4 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -770,4 +770,4 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
$r[] = "</pre>"; $r[] = "</pre>";
return implode("\n",$r); return implode("\n",$r);
} }
} }
\ No newline at end of file
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