Code Duplication    Length = 27-27 lines in 2 locations

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

src/actions/nestedset/NodeMoveAction.php 1 location

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