本文整理汇总了PHP中XLite\Model\AEntity::getParent方法的典型用法代码示例。如果您正苦于以下问题:PHP AEntity::getParent方法的具体用法?PHP AEntity::getParent怎么用?PHP AEntity::getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XLite\Model\AEntity
的用法示例。
在下文中一共展示了AEntity::getParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: performDelete
/**
* Delete single entity
*
* @param \XLite\Model\AEntity $entity Entity to detach
*
* @return void
*/
protected function performDelete(\XLite\Model\AEntity $entity)
{
// Update quick flags
if ($entity->getParent()) {
$this->updateQuickFlags($entity->getParent(), $this->prepareQuickFlags(-1, $entity->getEnabled() ? -1 : 0));
}
// Root category cannot be removed. Only its subtree
$onlySubtree = $entity->getCategoryId() == $this->getRootCategoryId();
// Calculate some variables
$right = $entity->getRpos() - ($onlySubtree ? 1 : 0);
$width = $entity->getRpos() - $entity->getLpos() - ($onlySubtree ? 1 : -1);
// Update indexes in the nested set.
// FIXME: must not use execute()
$this->defineUpdateIndexQuery('lpos', $right, -$width)->execute();
$this->defineUpdateIndexQuery('rpos', $right, -$width)->execute();
if ($onlySubtree) {
$this->deleteInBatch($this->getSubtree($entity->getCategoryId()), false);
} else {
parent::performDelete($entity);
}
}
示例2: insertNewEntity
/**
* Insert new entity
*
* @param \XLite\Model\AEntity $entity Entity
*
* @return void
*/
protected function insertNewEntity(\XLite\Model\AEntity $entity)
{
// Resort
$pos = 10;
$entity->setPos($pos);
foreach ($entity->getParent()->getChildren() as $child) {
$pos += 10;
$child->setPos($pos);
}
$this->createCount++;
parent::insertNewEntity($entity);
}