Code Duplication    Length = 27-27 lines in 2 locations

src/actions/nestedset/FullTreeDataAction.php 1 location

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

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