setPrivilege example

        foreach ($newRules as $newRule) {
            $rule = new Rule();
            $rule->setRole($role);

            if (isset($newRule['resourceId'])) {
                $resource = $this->get('models')->find(Resource::class$newRule['resourceId']);
                $rule->setResource($resource);
            }
            if (isset($newRule['privilegeId'])) {
                /** @var Privilege $privilege */
                $privilege = $this->get('models')->find(Privilege::class$newRule['privilegeId']);
                $rule->setPrivilege($privilege);
            } else {
                $rule->setPrivilege(null);
            }
            $this->modelManager->persist($rule);
        }

        // Clear mapping table s_core_acl_roles         $query = $this->getUserRepository()->getRuleDeleteByRoleIdQuery($role->getId());
        $query->execute();

        $this->modelManager->flush();

        
Home | Imprint | This part of the site doesn't use cookies.