Code Duplication    Length = 14-16 lines in 2 locations

Controller/AdminNodeController.php 1 location

@@ 93-108 (lines=16) @@
90
        ], null, $request);
91
    }
92
93
    protected function checkRolesCMS(array $role)
94
    {
95
        $user = $this->getUser();
96
97
        if (!$user) {
98
            throw new NotFoundHttpException(sprintf('unable to find user'));
99
        }
100
101
        $userRole = $user->getRoles()[0];
102
103
        if (!array_key_exists('role', $role) || in_array($userRole, $role['role'])) {
104
            return true;
105
        }
106
107
        return false;
108
    }
109
}
110

Controller/AdminBlockController.php 1 location

@@ 107-120 (lines=14) @@
104
     *
105
     * Check role define in different parameter of block or content_types cms.yml
106
     */
107
    protected function checkRolesCMS(array $role)
108
    {
109
        $user = $this->getUser();
110
111
        if (!$user) {
112
            throw new NotFoundHttpException(sprintf('unable to find user'));
113
        }
114
115
        if (!array_key_exists('role', $role) || in_array($user->getRoles()[0], $role['role'])) {
116
            return true;
117
        }
118
119
        return false;
120
    }
121
122
    /**
123
     * Get content in cms.yml and set in $_cmsParameter.