本文整理汇总了PHP中Doctrine_Record::getNode方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Record::getNode方法的具体用法?PHP Doctrine_Record::getNode怎么用?PHP Doctrine_Record::getNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Record
的用法示例。
在下文中一共展示了Doctrine_Record::getNode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createRoot
/**
* Creates root node from given record or from a new record.
*
* Note: When using a tree with multiple root nodes (hasManyRoots), you MUST pass in a
* record to use as the root. This can either be a new/transient record that already has
* the root id column set to some numeric value OR a persistent record. In the latter case
* the records id will be assigned to the root id. You must use numeric columns for the id
* and root id columns.
*
* @param object $record instance of Doctrine_Record
*/
public function createRoot(Doctrine_Record $record = null)
{
if ($this->getAttribute('hasManyRoots')) {
if (!$record || !$record->exists() && $record->getNode()->getRootValue() <= 0 || $record->getTable()->isIdentifierComposite()) {
throw new Doctrine_Tree_Exception("Node must have a root id set or must " . " be persistent and have a single-valued numeric primary key in order to" . " be created as a root node. Automatic assignment of a root id on" . " transient/new records is no longer supported.");
}
if ($record->exists() && $record->getNode()->getRootValue() <= 0) {
// Default: root_id = id
$identifier = $record->getTable()->getIdentifier();
$record->getNode()->setRootValue($record->get($identifier));
}
}
if (!$record) {
$record = $this->table->create();
}
$record->set('lft', '1');
$record->set('rgt', '2');
$record->set('level', 0);
$record->save();
return $record;
}
示例2: isAncestorOf
/**
* determines if node is ancestor of subject node
*
* @return bool
*/
public function isAncestorOf(Doctrine_Record $subj)
{
return $subj->getNode()->getLeftValue() > $this->getLeftValue() && $subj->getNode()->getRightValue() < $this->getRightValue() && $subj->getNode()->getRootValue() == $this->getRootValue();
}
示例3: isDescendantOfOrEqualTo
/**
* determines if node is child of or sibling to subject node
*
* @return bool
*/
public function isDescendantOfOrEqualTo(Doctrine_Record $subj)
{
return $this->getLeftValue() >= $subj->getNode()->getLeftValue() && $this->getRightValue() <= $subj->getNode()->getRightValue() && $this->getRootValue() == $subj->getNode()->getRootValue();
}
示例4: isValidNode
/**
* determines if node is valid
*
* @return bool
*/
public function isValidNode(Doctrine_Record $record = null)
{
if ($record === null) {
return $this->getRightValue() > $this->getLeftValue();
} else {
return $record->getNode()->getRightValue() > $record->getNode()->getLeftValue();
}
}