src/Sulu/Component/Security/Authorization/AccessControl/DoctrineAccessControlProvider.php
public function setPermissions($type, $identifier, $permissions)
    {
        foreach ($permissions as $roleId => $rolePermissions) {
            $accessControl = $this->accessControlRepository->findByTypeAndIdAndRole($type, $identifier, $roleId);

            if ($accessControl) {
                $accessControl->setPermissions($this->maskConverter->convertPermissionsToNumber($rolePermissions));
            } else {
                $role = $this->roleRepository->findRoleById($roleId);

                $accessControl = new AccessControl();
                $accessControl->setPermissions($this->maskConverter->convertPermissionsToNumber($rolePermissions));
                $accessControl->setRole($role);
                $accessControl->setEntityId($identifier);
                $accessControl->setEntityClass($type);
                $this->objectManager->persist($accessControl);
            }
        }

        $this->objectManager->flush();
    }
public function setPermissions($type, $identifier, $permissions)
    {
        foreach ($permissions as $roleId => $rolePermissions) {
            $accessControl = $this->accessControlRepository->findByTypeAndIdAndRole($type, $identifier, $roleId);

            if ($accessControl) {
                $accessControl->setPermissions($this->maskConverter->convertPermissionsToNumber($rolePermissions));
            } else {
                $role = $this->roleRepository->findRoleById($roleId);

                $accessControl = new AccessControl();
                $accessControl->setPermissions($this->maskConverter->convertPermissionsToNumber($rolePermissions));
                $accessControl->setRole($role);
                $accessControl->setEntityId($identifier);
                $accessControl->setEntityClass($type);
                $this->objectManager->persist($accessControl);
            }
        }

        $this->objectManager->flush();
    }
public function setPermissions ( $ type , $ identifier , $ permissions ) { foreach ( $ permissions as $ roleId => $ rolePermissions ) { $ accessControl = $ this -> accessControlRepository -> findByTypeAndIdAndRole ( $ type , $ identifier , $ roleId ) ; if ( $ accessControl ) { $ accessControl -> setPermissions ( $ this -> maskConverter -> convertPermissionsToNumber ( $ rolePermissions ) ) ; } else { $ role = $ this -> roleRepository -> findRoleById ( $ roleId ) ; $ accessControl = new AccessControl ( ) ; $ accessControl -> setPermissions ( $ this -> maskConverter -> convertPermissionsToNumber ( $ rolePermissions ) ) ; $ accessControl -> setRole ( $ role ) ; $ accessControl -> setEntityId ( $ identifier ) ; $ accessControl -> setEntityClass ( $ type ) ; $ this -> objectManager -> persist ( $ accessControl ) ; } } $ this -> objectManager -> flush ( ) ; }
Sets the permissions for the object with the given class and id for the given security identity.

@param string $type The name of the class to protect
@param string $identifier
@param $permissions
Sets the permissions for the object with the given class and id for the given security identity .