Code Duplication    Length = 27-27 lines in 2 locations

src/actions/nestedset/NodeMoveAction.php 1 location

@@ 41-67 (lines=27) @@
38
    /**
39
     * @inheritdoc
40
     */
41
    public function init()
42
    {
43
        if (true === empty($this->className) || false === is_subclass_of($this->className, ActiveRecord::class)) {
44
            throw new InvalidConfigException('"className" param must be set and must be child of ActiveRecord');
45
        }
46
        /** @var ActiveRecord $class */
47
        $class = $this->className;
48
        $this->tableName = $class::tableName();
49
        $scheme = Yii::$app->getDb()->getTableSchema($this->tableName);
50
        $columns = $scheme->columns;
51
        if (false !== $this->rootAttribute && false === isset($columns[$this->rootAttribute])) {
52
            throw new InvalidConfigException("Column '{$this->rootAttribute}' not found in the '{$this->tableName}' table");
53
        }
54
        if (false === isset(
55
                $columns[$this->leftAttribute],
56
                $columns[$this->rightAttribute],
57
                $columns[$this->depthAttribute]
58
            )
59
        ) {
60
            throw new InvalidConfigException(
61
                "Some of the '{$this->leftAttribute}', '{$this->rightAttribute}', '{$this->depthAttribute}', "
62
                . "not found in the '{$this->tableName}' columns list"
63
            );
64
        }
65
        TreeWidget::registerTranslations();
66
        parent::init();
67
    }
68
69
    /**
70
     * @inheritdoc

src/actions/nestedset/FullTreeDataAction.php 1 location

@@ 37-63 (lines=27) @@
34
    /**
35
     * @inheritdoc
36
     */
37
    public function init()
38
    {
39
        if (true === empty($this->className) || false === is_subclass_of($this->className, ActiveRecord::class)) {
40
            throw new InvalidConfigException('"className" param must be set and must be child of ActiveRecord');
41
        }
42
        /** @var ActiveRecord $class */
43
        $class = $this->className;
44
        $this->tableName = $class::tableName();
45
        $scheme = Yii::$app->getDb()->getTableSchema($this->tableName);
46
        $columns = $scheme->columns;
47
        if (false !== $this->rootAttribute && false === isset($columns[$this->rootAttribute])) {
48
            throw new InvalidConfigException("Column '{$this->rootAttribute}' not found in the '{$this->tableName}' table");
49
        }
50
        if (false === isset(
51
                $columns[$this->leftAttribute],
52
                $columns[$this->rightAttribute],
53
                $columns[$this->modelLabelAttribute]
54
            )
55
        ) {
56
            throw new InvalidConfigException(
57
                "Some of the '{$this->leftAttribute}', '{$this->rightAttribute}', '{$this->modelLabelAttribute}', "
58
                . "not found in the '{$this->tableName}' columns list"
59
            );
60
        }
61
        TreeWidget::registerTranslations();
62
        parent::init();
63
    }
64
65
    /**
66
     * @inheritdoc