table refactoring continues
This commit is contained in:
parent
6394c79281
commit
c4b3a18a59
@ -36,28 +36,28 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
|
|||||||
/**
|
/**
|
||||||
* @var array $data temporary data which is then loaded into Doctrine_Record::$data
|
* @var array $data temporary data which is then loaded into Doctrine_Record::$data
|
||||||
*/
|
*/
|
||||||
private $_data = array();
|
protected $_data = array();
|
||||||
/**
|
/**
|
||||||
* @var mixed $identifier
|
* @var mixed $identifier
|
||||||
*/
|
*/
|
||||||
private $_identifier;
|
protected $_identifier;
|
||||||
/**
|
/**
|
||||||
* @see Doctrine_Identifier constants
|
* @see Doctrine_Identifier constants
|
||||||
* @var integer $identifierType the type of identifier this table uses
|
* @var integer $identifierType the type of identifier this table uses
|
||||||
*/
|
*/
|
||||||
private $_identifierType;
|
protected $_identifierType;
|
||||||
/**
|
/**
|
||||||
* @var Doctrine_Connection $conn Doctrine_Connection object that created this table
|
* @var Doctrine_Connection $conn Doctrine_Connection object that created this table
|
||||||
*/
|
*/
|
||||||
private $_conn;
|
protected $_conn;
|
||||||
/**
|
/**
|
||||||
* @var array $identityMap first level cache
|
* @var array $identityMap first level cache
|
||||||
*/
|
*/
|
||||||
private $_identityMap = array();
|
protected $_identityMap = array();
|
||||||
/**
|
/**
|
||||||
* @var Doctrine_Table_Repository $repository record repository
|
* @var Doctrine_Table_Repository $repository record repository
|
||||||
*/
|
*/
|
||||||
private $_repository;
|
protected $_repository;
|
||||||
/**
|
/**
|
||||||
* @var array $columns an array of column definitions,
|
* @var array $columns an array of column definitions,
|
||||||
* keys as column names and values as column definitions
|
* keys as column names and values as column definitions
|
||||||
@ -83,11 +83,11 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
|
|||||||
* @var integer $columnCount cached column count, Doctrine_Record uses this column count in when
|
* @var integer $columnCount cached column count, Doctrine_Record uses this column count in when
|
||||||
* determining its state
|
* determining its state
|
||||||
*/
|
*/
|
||||||
private $columnCount;
|
protected $columnCount;
|
||||||
/**
|
/**
|
||||||
* @var boolean $hasDefaultValues whether or not this table has default values
|
* @var boolean $hasDefaultValues whether or not this table has default values
|
||||||
*/
|
*/
|
||||||
private $hasDefaultValues;
|
protected $hasDefaultValues;
|
||||||
/**
|
/**
|
||||||
* @var array $options an array containing all options
|
* @var array $options an array containing all options
|
||||||
*
|
*
|
||||||
@ -162,16 +162,19 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
|
|||||||
* @var array $_filters an array containing all record filters attached to this table
|
* @var array $_filters an array containing all record filters attached to this table
|
||||||
*/
|
*/
|
||||||
protected $_filters = array();
|
protected $_filters = array();
|
||||||
|
/**
|
||||||
|
* @var array $_invokedMethods method invoker cache
|
||||||
|
*/
|
||||||
protected $_invokedMethods = array();
|
protected $_invokedMethods = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the constructor
|
* the constructor
|
||||||
|
*
|
||||||
* @throws Doctrine_Connection_Exception if there are no opened connections
|
* @throws Doctrine_Connection_Exception if there are no opened connections
|
||||||
* @throws Doctrine_Table_Exception if there is already an instance of this table
|
* @param string $name the name of the component
|
||||||
* @return void
|
* @param Doctrine_Connection $conn the connection associated with this table
|
||||||
*/
|
*/
|
||||||
public function __construct($name, Doctrine_Connection $conn)
|
public function __construct($name, Doctrine_Connection $conn)
|
||||||
{
|
{
|
||||||
@ -182,6 +185,21 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
|
|||||||
$this->_options['name'] = $name;
|
$this->_options['name'] = $name;
|
||||||
$this->_parser = new Doctrine_Relation_Parser($this);
|
$this->_parser = new Doctrine_Relation_Parser($this);
|
||||||
|
|
||||||
|
$record = $this->initDefinition($name);
|
||||||
|
|
||||||
|
$this->initIdentifier();
|
||||||
|
|
||||||
|
$record->setUp();
|
||||||
|
|
||||||
|
// if tree, set up tree
|
||||||
|
if ($this->isTree()) {
|
||||||
|
$this->getTree()->setUp();
|
||||||
|
}
|
||||||
|
$this->_filters[] = new Doctrine_Record_Filter_Standard();
|
||||||
|
$this->_repository = new Doctrine_Table_Repository($this);
|
||||||
|
}
|
||||||
|
public function initDefinition($name)
|
||||||
|
{
|
||||||
if ( ! class_exists($name) || empty($name)) {
|
if ( ! class_exists($name) || empty($name)) {
|
||||||
throw new Doctrine_Exception("Couldn't find class " . $name);
|
throw new Doctrine_Exception("Couldn't find class " . $name);
|
||||||
}
|
}
|
||||||
@ -234,18 +252,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
|
|||||||
$this->_options['tableName'] = Doctrine::tableize($class->getName());
|
$this->_options['tableName'] = Doctrine::tableize($class->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->initIdentifier();
|
return $record;
|
||||||
|
|
||||||
$record->setUp();
|
|
||||||
|
|
||||||
// if tree, set up tree
|
|
||||||
if ($this->isTree()) {
|
|
||||||
$this->getTree()->setUp();
|
|
||||||
}
|
}
|
||||||
$this->_filters[] = new Doctrine_Record_Filter_Standard();
|
|
||||||
$this->_repository = new Doctrine_Table_Repository($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function initIdentifier()
|
public function initIdentifier()
|
||||||
{
|
{
|
||||||
switch (count($this->_identifier)) {
|
switch (count($this->_identifier)) {
|
||||||
@ -828,24 +836,44 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
|
|||||||
{
|
{
|
||||||
return isset($this->_columns[$name]);
|
return isset($this->_columns[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Doctrine_Connection
|
* sets the connection for this class
|
||||||
|
*
|
||||||
|
* @params Doctrine_Connection a connection object
|
||||||
|
* @return Doctrine_Table this object
|
||||||
|
*/
|
||||||
|
public function setConnection(Doctrine_Connection $conn)
|
||||||
|
{
|
||||||
|
$this->_conn = $conn;
|
||||||
|
|
||||||
|
$this->setParent($this->_conn);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the connection associated with this table (if any)
|
||||||
|
*
|
||||||
|
* @return Doctrine_Connection|null the connection object
|
||||||
*/
|
*/
|
||||||
public function getConnection()
|
public function getConnection()
|
||||||
{
|
{
|
||||||
return $this->_conn;
|
return $this->_conn;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* create
|
|
||||||
* creates a new record
|
* creates a new record
|
||||||
*
|
*
|
||||||
* @param $array an array where keys are field names and values representing field values
|
* @param $array an array where keys are field names and
|
||||||
* @return Doctrine_Record
|
* values representing field values
|
||||||
|
* @return Doctrine_Record the created record object
|
||||||
*/
|
*/
|
||||||
public function create(array $array = array()) {
|
public function create(array $array = array())
|
||||||
|
{
|
||||||
$this->_data = $array;
|
$this->_data = $array;
|
||||||
$record = new $this->_options['name']($this, true);
|
$record = new $this->_options['name']($this, true);
|
||||||
$this->_data = array();
|
$this->_data = array();
|
||||||
|
|
||||||
return $record;
|
return $record;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user