diff --git a/components/AbstractItemEvent.php b/components/AbstractItemEvent.php new file mode 100644 index 00000000..d5afecf1 --- /dev/null +++ b/components/AbstractItemEvent.php @@ -0,0 +1,11 @@ +$childName]; @@ -109,6 +116,7 @@ public static function removeChildren($parentName, $childrenNames) { $childrenNames = (array) $childrenNames; + static::beforeRemoveChildren($parentName, $childrenNames); foreach ($childrenNames as $childName) { Yii::$app->db->createCommand() @@ -247,4 +255,16 @@ public function afterDelete() AuthHelper::invalidatePermissions(); } + + public function beforeAddChildren($parentName, $childrenNames, $throwException = false) + { + $event = new AbstractItemEvent(compact('parentName', 'childrenNames', 'throwException')); + $event->trigger(get_called_class(), self::EVENT_BEFORE_ADD_CHILDREN, $event); + } + + public function beforeRemoveChildren($parentName, $childrenNames) + { + $event = new AbstractItemEvent(compact('parentName', 'childrenNames', 'throwException')); + $event->trigger(get_called_class(), self::EVENT_BEFORE_REMOVE_CHILDREN, $event); + } } \ No newline at end of file