Doctrine 1.2.4
Doctrine_Node Class Reference

Inherits IteratorAggregate.

Inherited by Doctrine_Node_AdjacencyList, and Doctrine_Node_MaterializedPath.

Public Member Functions

 __construct (Doctrine_Record $record, $options)
 
 getIterator ($type=null, $options=null)
 
 getRecord ()
 
 setIteratorOptions ($options)
 
 setIteratorType ($type)
 
 setRecord (Doctrine_Record $record)
 
 traverse ($type= 'Pre', $options=array())
 

Static Public Member Functions

static factory (Doctrine_Record $record, $implName, $options=array())
 

Protected Attributes

 $iteratorOptions
 
 $iteratorType
 
 $options
 
 $record
 

Detailed Description

Definition at line 33 of file Node.php.

Constructor & Destructor Documentation

Doctrine_Node::__construct ( Doctrine_Record  $record,
  $options 
)

contructor, creates node with reference to record and any options

Parameters
object$recordinstance of Doctrine_Record
array$optionsoptions

Definition at line 68 of file Node.php.

{
$this->record = $record;
$this->options = $options;
// Make sure that the tree object of the root class is used in the case
// of column aggregation inheritance (single table inheritance).
$class = $record->getTable()->getComponentName();
$thisTable = $record->getTable();
$table = $thisTable;
if ($thisTable->getOption('inheritanceMap')) {
// Move up the hierarchy until we find the "subclasses" option. This option
// MUST be set on the root class of the user's hierarchy that uses STI.
while ( ! $subclasses = $table->getOption('subclasses')) {
$class = get_parent_class($class);
$reflectionClass = new ReflectionClass($class);
if ($reflectionClass->isAbstract()) {
continue;
}
if ($class == 'Doctrine_Record') {
throw new Doctrine_Node_Exception("No subclasses specified. You are "
. "using Single Table Inheritance with NestedSet but you have "
. "not specified the subclasses correctly. Make sure you use "
. "setSubclasses() in the root class of your hierarchy.");
}
$table = $table->getConnection()->getTable($class);
}
}
if ($thisTable !== $table) {
$this->_tree = $table->getTree();
} else {
$this->_tree = $thisTable->getTree();
}
}

Member Function Documentation

static Doctrine_Node::factory ( Doctrine_Record  $record,
  $implName,
  $options = array() 
)
static

Factory method for creating a Node.

This is a factory method that returns node instance based upon chosen implementation.

Parameters
object$recordinstance of Doctrine_Record
string$implNameimplementation (NestedSet, AdjacencyList, MaterializedPath)
array$optionsoptions
Returns
Doctrine_Node
Exceptions
Doctrine_Node_Exceptionif $implName is not a valid class

Definition at line 115 of file Node.php.

{
$class = 'Doctrine_Node_' . $implName;
if ( ! class_exists($class)) {
throw new Doctrine_Node_Exception("The class $class must exist and extend Doctrine_Node");
}
return new $class($record, $options);
}
Doctrine_Node::getIterator (   $type = null,
  $options = null 
)

get iterator

Parameters
string$typetype of iterator (Pre | Post | Level)
array$optionsoptions

Definition at line 163 of file Node.php.

{
if ($type === null) {
$type = (isset($this->iteratorType) ? $this->iteratorType : 'Pre');
}
if ($options === null) {
$options = (isset($this->iteratorOptions) ? $this->iteratorOptions : array());
}
$implName = $this->record->getTable()->getOption('treeImpl');
$iteratorClass = 'Doctrine_Node_' . $implName . '_' . ucfirst(strtolower($type)) . 'OrderIterator';
return new $iteratorClass($this->record, $options);
}
Doctrine_Node::getRecord ( )

getter for record attribute

Returns
Doctrine_Record

Definition at line 141 of file Node.php.

{
return $this->record;
}
Doctrine_Node::setIteratorOptions (   $options)

sets node's iterator options

Parameters
int

Definition at line 194 of file Node.php.

{
$this->iteratorOptions = $options;
}
Doctrine_Node::setIteratorType (   $type)

sets node's iterator type

Parameters
int

Definition at line 184 of file Node.php.

{
$this->iteratorType = $type;
}
Doctrine_Node::setRecord ( Doctrine_Record  $record)

setter for record attribute

Parameters
object$recordinstance of Doctrine_Record

Definition at line 131 of file Node.php.

{
$this->record = $record;
}
Doctrine_Node::traverse (   $type = 'Pre',
  $options = array() 
)

convenience function for getIterator

Parameters
string$typetype of iterator (Pre | Post | Level)
array$optionsoptions

Definition at line 152 of file Node.php.

{
return $this->getIterator($type, $options);
}

Field Documentation

Doctrine_Node::$iteratorOptions
protected
Parameters
array$iteratorOptions

Definition at line 53 of file Node.php.

Doctrine_Node::$iteratorType
protected
Parameters
string$iteratorType(Pre | Post | Level)

Definition at line 48 of file Node.php.

Doctrine_Node::$options
protected
Parameters
array$options

Definition at line 43 of file Node.php.

Doctrine_Node::$record
protected
Parameters
object$recordreference to associated Doctrine_Record instance

Definition at line 38 of file Node.php.


The documentation for this class was generated from the following file: