Sulu\Bundle\SecurityBundle\Entity\AccessControl::setEntityId PHP Method

setEntityId() public method

public setEntityId ( $entityId )
    public function setEntityId($entityId)
    {
        $this->entityId = $entityId;
    }

Usage Example

 /**
  * 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
  */
 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();
 }
All Usage Examples Of Sulu\Bundle\SecurityBundle\Entity\AccessControl::setEntityId