3
* $Id: Tree.php 3975 2008-03-13 02:16:21Z jwage $
5
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17
* This software consists of voluntary contributions made by many individuals
18
* and is licensed under the LGPL. For more information, see
19
* <http://www.phpdoctrine.org>.
27
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
28
* @link www.phpdoctrine.org
30
* @version $Revision: 3975 $
31
* @author Joe Simms <joe.simms@websites4.com>
36
* @param object $table reference to associated Doctrine_Table instance
41
* @param array $options
43
protected $options = array();
45
protected $_baseComponent;
48
* constructor, creates tree with reference to table and any options
50
* @param object $table instance of Doctrine_Table
51
* @param array $options options
53
public function __construct(Doctrine_Table $table, $options)
55
$this->table = $table;
56
$this->options = $options;
57
$this->_baseComponent = $table->getComponentName();
58
$class = $this->_baseComponent;
59
if ($table->getOption('inheritanceMap')) {
60
$subclasses = $table->getOption('subclasses');
61
while (in_array($class, $subclasses)) {
62
$class = get_parent_class($class);
64
$this->_baseComponent = $class;
66
//echo $this->_baseComponent;
70
* Used to define table attributes required for the given implementation
72
* @throws Doctrine_Tree_Exception if table attributes have not been defined
74
public function setTableDefinition()
76
throw new Doctrine_Tree_Exception('Table attributes have not been defined for this Tree implementation.');
80
* this method is used for setting up relations and attributes and should be used by specific implementations
83
public function setUp()
88
* factory method to return tree instance based upon chosen implementation
90
* @param object $table instance of Doctrine_Table
91
* @param string $impName implementation (NestedSet, AdjacencyList, MaterializedPath)
92
* @param array $options options
93
* @return object $options instance of Doctrine_Node
94
* @throws Doctrine_Exception if class does not extend Doctrine_Tree
96
public static function factory(Doctrine_Table $table, $implName, $options = array())
98
$class = 'Doctrine_Tree_' . $implName;
99
if ( ! class_exists($class)) {
100
throw new Doctrine_Exception('The chosen class must extend Doctrine_Tree');
102
return new $class($table, $options);
106
* gets tree attribute value
109
public function getAttribute($name)
111
return isset($this->options[$name]) ? $this->options[$name] : null;
115
* sets tree attribute value
119
public function setAttribute($name, $value)
121
$this->options[$name] = $value;
125
* Returns the base tree component.
127
public function getBaseComponent()
129
return $this->_baseComponent;
b'\\ No newline at end of file'