Commit f44784d9 authored by zYne's avatar zYne

made all manager variables protected and adhere to Zend naming conventions

parent 5d3660f2
...@@ -167,6 +167,7 @@ class Doctrine_Compiler ...@@ -167,6 +167,7 @@ class Doctrine_Compiler
'RawSql', 'RawSql',
'Record', 'Record',
'Record_Exception', 'Record_Exception',
'Record_Filter',
'Record_Iterator', 'Record_Iterator',
'Record_State_Exception', 'Record_State_Exception',
'Relation', 'Relation',
......
...@@ -36,31 +36,31 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -36,31 +36,31 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
/** /**
* @var array $connections an array containing all the opened connections * @var array $connections an array containing all the opened connections
*/ */
private $connections = array(); protected $_connections = array();
/** /**
* @var array $bound an array containing all components that have a bound connection * @var array $bound an array containing all components that have a bound connection
*/ */
private $bound = array(); protected $_bound = array();
/** /**
* @var integer $index the incremented index * @var integer $index the incremented index
*/ */
private $index = 0; protected $_index = 0;
/** /**
* @var integer $currIndex the current connection index * @var integer $currIndex the current connection index
*/ */
private $currIndex = 0; protected $_currIndex = 0;
/** /**
* @var string $root root directory * @var string $root root directory
*/ */
private $root; protected $_root;
/** /**
* @var Doctrine_Null $null Doctrine_Null object, used for extremely fast null value checking * @var Doctrine_Null $null Doctrine_Null object, used for extremely fast null value checking
*/ */
private $null; protected $_null;
/** /**
* @var array $driverMap * @var array $driverMap
*/ */
private $driverMap = array('oracle' => 'oci8', protected $_driverMap = array('oracle' => 'oci8',
'postgres' => 'pgsql', 'postgres' => 'pgsql',
'oci' => 'oci8', 'oci' => 'oci8',
'sqlite2' => 'sqlite', 'sqlite2' => 'sqlite',
...@@ -72,21 +72,21 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -72,21 +72,21 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*/ */
private function __construct() private function __construct()
{ {
$this->root = dirname(__FILE__); $this->_root = dirname(__FILE__);
$this->null = new Doctrine_Null; $this->_null = new Doctrine_Null;
Doctrine_Record::initNullObject($this->null); Doctrine_Record::initNullObject($this->_null);
Doctrine_Collection::initNullObject($this->null); Doctrine_Collection::initNullObject($this->_null);
Doctrine_Record_Iterator::initNullObject($this->null); Doctrine_Record_Iterator::initNullObject($this->_null);
Doctrine_Validator::initNullObject($this->null); Doctrine_Validator::initNullObject($this->_null);
Doctrine_Record_Filter::initNullOjbect($this->null); Doctrine_Record_Filter::initNullOjbect($this->_null);
} }
/** /**
* @return Doctrine_Null * @return Doctrine_Null
*/ */
final public function getNullObject() final public function getNullObject()
{ {
return $this->null; return $this->_null;
} }
/** /**
* setDefaultAttributes * setDefaultAttributes
...@@ -94,7 +94,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -94,7 +94,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
* *
* @return boolean * @return boolean
*/ */
final public function setDefaultAttributes() public function setDefaultAttributes()
{ {
static $init = false; static $init = false;
if ( ! $init) { if ( ! $init) {
...@@ -135,7 +135,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -135,7 +135,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*/ */
final public function getRoot() final public function getRoot()
{ {
return $this->root; return $this->_root;
} }
/** /**
* getInstance * getInstance
...@@ -199,49 +199,49 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -199,49 +199,49 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
if ($name !== null) { if ($name !== null) {
$name = (string) $name; $name = (string) $name;
if (isset($this->connections[$name])) { if (isset($this->_connections[$name])) {
return $this->connections[$name]; return $this->_connections[$name];
} }
} else { } else {
$name = $this->index; $name = $this->_index;
$this->index++; $this->_index++;
} }
switch ($adapter->getAttribute(Doctrine::ATTR_DRIVER_NAME)) { switch ($adapter->getAttribute(Doctrine::ATTR_DRIVER_NAME)) {
case 'mysql': case 'mysql':
$this->connections[$name] = new Doctrine_Connection_Mysql($this, $adapter); $this->_connections[$name] = new Doctrine_Connection_Mysql($this, $adapter);
break; break;
case 'sqlite': case 'sqlite':
$this->connections[$name] = new Doctrine_Connection_Sqlite($this, $adapter); $this->_connections[$name] = new Doctrine_Connection_Sqlite($this, $adapter);
break; break;
case 'pgsql': case 'pgsql':
$this->connections[$name] = new Doctrine_Connection_Pgsql($this, $adapter); $this->_connections[$name] = new Doctrine_Connection_Pgsql($this, $adapter);
break; break;
case 'oci': case 'oci':
case 'oracle': case 'oracle':
$this->connections[$name] = new Doctrine_Connection_Oracle($this, $adapter); $this->_connections[$name] = new Doctrine_Connection_Oracle($this, $adapter);
break; break;
case 'mssql': case 'mssql':
case 'dblib': case 'dblib':
$this->connections[$name] = new Doctrine_Connection_Mssql($this, $adapter); $this->_connections[$name] = new Doctrine_Connection_Mssql($this, $adapter);
break; break;
case 'firebird': case 'firebird':
$this->connections[$name] = new Doctrine_Connection_Firebird($this, $adapter); $this->_connections[$name] = new Doctrine_Connection_Firebird($this, $adapter);
break; break;
case 'informix': case 'informix':
$this->connections[$name] = new Doctrine_Connection_Informix($this, $adapter); $this->_connections[$name] = new Doctrine_Connection_Informix($this, $adapter);
break; break;
case 'mock': case 'mock':
$this->connections[$name] = new Doctrine_Connection_Mock($this, $adapter); $this->_connections[$name] = new Doctrine_Connection_Mock($this, $adapter);
break; break;
default: default:
throw new Doctrine_Manager_Exception('Unknown connection driver '. $adapter->getAttribute(Doctrine::ATTR_DRIVER_NAME)); throw new Doctrine_Manager_Exception('Unknown connection driver '. $adapter->getAttribute(Doctrine::ATTR_DRIVER_NAME));
}; };
if ($setCurrent) { if ($setCurrent) {
$this->currIndex = $name; $this->_currIndex = $name;
} }
return $this->connections[$name]; return $this->_connections[$name];
} }
/** /**
* getConnection * getConnection
...@@ -251,11 +251,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -251,11 +251,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*/ */
public function getConnection($name) public function getConnection($name)
{ {
if ( ! isset($this->connections[$name])) { if ( ! isset($this->_connections[$name])) {
throw new Doctrine_Manager_Exception('Unknown connection: ' . $name); throw new Doctrine_Manager_Exception('Unknown connection: ' . $name);
} }
return $this->connections[$name]; return $this->_connections[$name];
} }
/** /**
* getComponentAlias * getComponentAlias
...@@ -297,7 +297,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -297,7 +297,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*/ */
public function getConnectionName(Doctrine_Connection $conn) public function getConnectionName(Doctrine_Connection $conn)
{ {
return array_search($conn, $this->connections, true); return array_search($conn, $this->_connections, true);
} }
/** /**
* bindComponent * bindComponent
...@@ -311,7 +311,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -311,7 +311,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*/ */
public function bindComponent($componentName, $connectionName) public function bindComponent($componentName, $connectionName)
{ {
$this->bound[$componentName] = $connectionName; $this->_bound[$componentName] = $connectionName;
} }
/** /**
* getConnectionForComponent * getConnectionForComponent
...@@ -321,8 +321,8 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -321,8 +321,8 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*/ */
public function getConnectionForComponent($componentName = null) public function getConnectionForComponent($componentName = null)
{ {
if (isset($this->bound[$componentName])) { if (isset($this->_bound[$componentName])) {
return $this->getConnection($this->bound[$componentName]); return $this->getConnection($this->_bound[$componentName]);
} }
return $this->getCurrentConnection(); return $this->getCurrentConnection();
} }
...@@ -349,12 +349,12 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -349,12 +349,12 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
{ {
$connection->close(); $connection->close();
$key = array_search($connection, $this->connections, true); $key = array_search($connection, $this->_connections, true);
if ($key !== false) { if ($key !== false) {
unset($this->connections[$key]); unset($this->_connections[$key]);
} }
$this->currIndex = key($this->connections); $this->_currIndex = key($this->_connections);
unset($connection); unset($connection);
} }
...@@ -366,7 +366,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -366,7 +366,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*/ */
public function getConnections() public function getConnections()
{ {
return $this->connections; return $this->_connections;
} }
/** /**
* setCurrentConnection * setCurrentConnection
...@@ -379,10 +379,10 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -379,10 +379,10 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
public function setCurrentConnection($key) public function setCurrentConnection($key)
{ {
$key = (string) $key; $key = (string) $key;
if ( ! isset($this->connections[$key])) { if ( ! isset($this->_connections[$key])) {
throw new InvalidKeyException(); throw new InvalidKeyException();
} }
$this->currIndex = $key; $this->_currIndex = $key;
} }
/** /**
* contains * contains
...@@ -393,7 +393,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -393,7 +393,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*/ */
public function contains($key) public function contains($key)
{ {
return isset($this->connections[$key]); return isset($this->_connections[$key]);
} }
/** /**
* count * count
...@@ -403,7 +403,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -403,7 +403,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*/ */
public function count() public function count()
{ {
return count($this->connections); return count($this->_connections);
} }
/** /**
* getIterator * getIterator
...@@ -413,7 +413,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -413,7 +413,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*/ */
public function getIterator() public function getIterator()
{ {
return new ArrayIterator($this->connections); return new ArrayIterator($this->_connections);
} }
/** /**
* getCurrentConnection * getCurrentConnection
...@@ -424,11 +424,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -424,11 +424,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*/ */
public function getCurrentConnection() public function getCurrentConnection()
{ {
$i = $this->currIndex; $i = $this->_currIndex;
if ( ! isset($this->connections[$i])) { if ( ! isset($this->_connections[$i])) {
throw new Doctrine_Connection_Exception(); throw new Doctrine_Connection_Exception();
} }
return $this->connections[$i]; return $this->_connections[$i];
} }
/** /**
* __toString * __toString
...@@ -440,7 +440,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -440,7 +440,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
{ {
$r[] = "<pre>"; $r[] = "<pre>";
$r[] = "Doctrine_Manager"; $r[] = "Doctrine_Manager";
$r[] = "Connections : ".count($this->connections); $r[] = "Connections : ".count($this->_connections);
$r[] = "</pre>"; $r[] = "</pre>";
return implode("\n",$r); return implode("\n",$r);
} }
......
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