当前位置: 首页>>代码示例>>PHP>>正文


PHP ActiveRecord::isChildOf方法代码示例

本文整理汇总了PHP中yii\db\ActiveRecord::isChildOf方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::isChildOf方法的具体用法?PHP ActiveRecord::isChildOf怎么用?PHP ActiveRecord::isChildOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\db\ActiveRecord的用法示例。


在下文中一共展示了ActiveRecord::isChildOf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: beforeUpdate

 /**
  * @throws Exception
  */
 public function beforeUpdate()
 {
     if ($this->node !== null && !$this->node->getIsNewRecord()) {
         $this->node->refresh();
     }
     switch ($this->operation) {
         case self::OPERATION_MAKE_ROOT:
             if ($this->treeAttribute === null) {
                 throw new Exception('Can not move a node as the root when "treeAttribute" is not set.');
             }
             if ($this->isRoot()) {
                 throw new Exception('Can not move the root node as the root.');
             }
             break;
         case self::OPERATION_INSERT_BEFORE:
         case self::OPERATION_INSERT_AFTER:
             if ($this->node->isRoot()) {
                 throw new Exception('Can not move a node before/after root.');
             }
         case self::OPERATION_PREPEND_TO:
         case self::OPERATION_APPEND_TO:
             if ($this->node->getIsNewRecord()) {
                 throw new Exception('Can not move a node when the target node is new record.');
             }
             if ($this->owner->equals($this->node)) {
                 throw new Exception('Can not move a node when the target node is same.');
             }
             if ($this->node->isChildOf($this->owner)) {
                 throw new Exception('Can not move a node when the target node is child.');
             }
     }
 }
开发者ID:nuclearman,项目名称:yii2-nested-sets-1,代码行数:35,代码来源:NestedSetsBehavior.php

示例2: checkNode

 /**
  * @param bool $forInsertNear
  * @throws Exception
  */
 protected function checkNode($forInsertNear = false)
 {
     if ($forInsertNear && $this->node->isRoot()) {
         throw new Exception('Can not move a node before/after root.');
     }
     if ($this->node->getIsNewRecord()) {
         throw new Exception('Can not move a node when the target node is new record.');
     }
     if ($this->owner->equals($this->node)) {
         throw new Exception('Can not move a node when the target node is same.');
     }
     if ($this->checkLoop && $this->node->isChildOf($this->owner)) {
         throw new Exception('Can not move a node when the target node is child.');
     }
 }
开发者ID:karsel,项目名称:yii2-adjacency-list,代码行数:19,代码来源:AdjacencyListBehavior.php

示例3: beforeUpdate

 /**
  * @throws Exception
  */
 public function beforeUpdate()
 {
     if ($this->node !== null && !$this->node->getIsNewRecord()) {
         $this->node->refresh();
     }
     switch ($this->operation) {
         case self::OPERATION_MAKE_ROOT:
             if ($this->treeAttribute === false) {
                 throw new Exception('Can not move a node as the root when "treeAttribute" is false.');
             }
             if ($this->owner->isRoot()) {
                 throw new Exception('Can not move the root node as the root.');
             }
             if (!$this->treeAttributeById) {
                 if ($this->owner->getOldAttribute($this->treeAttribute) === $this->owner->getAttribute($this->treeAttribute)) {
                     throw new Exception('Can not move a node as the root when its tree attribute "' . $this->treeAttribute . '" is not changed.');
                 }
                 if ($this->owner->find()->andWhere([$this->treeAttribute => $this->owner->getAttribute($this->treeAttribute), $this->leftAttribute => 1])->one()) {
                     throw new Exception('Can not move a node as the root when another root with this "' . $this->treeAttribute . '" already exists.');
                 }
             }
             break;
         case self::OPERATION_INSERT_BEFORE:
         case self::OPERATION_INSERT_AFTER:
             if ($this->node->isRoot()) {
                 throw new Exception('Can not move a node when the target node is root.');
             }
         case self::OPERATION_PREPEND_TO:
         case self::OPERATION_APPEND_TO:
             if ($this->node->getIsNewRecord()) {
                 throw new Exception('Can not move a node when the target node is new record.');
             }
             if ($this->owner->equals($this->node)) {
                 throw new Exception('Can not move a node when the target node is same.');
             }
             if ($this->node->isChildOf($this->owner)) {
                 throw new Exception('Can not move a node when the target node is child.');
             }
     }
 }
开发者ID:Oreolek,项目名称:yii2-nested-sets,代码行数:43,代码来源:NestedSetsBehavior.php


注:本文中的yii\db\ActiveRecord::isChildOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。