/**
  * Constructor.
  */
 public function __construct(Role $role, AbstractRoleSubject $subject)
 {
     $this->role = $role;
     $details = array('role' => array('name' => $role->getTranslationKey()));
     if ($role->getWorkspace()) {
         $details['workspace'] = array('name' => $role->getWorkspace()->getName(), 'id' => $role->getWorkspace()->getId());
     }
     if ($subject instanceof User) {
         $details['receiverUser'] = array('firstName' => $subject->getFirstName(), 'lastName' => $subject->getLastName());
         $this->receiver = $subject;
     } else {
         $details['receiverGroup'] = array('name' => $subject->getName());
         $this->receiverGroup = $subject;
     }
     $this->details = $details;
     parent::__construct($this->getActionKey(), $details, $this->receiver, $this->receiverGroup, null, $role, $role->getWorkspace());
 }
 /**
  * Constructor.
  */
 public function __construct(Role $role, AbstractRoleSubject $subject)
 {
     $receiver = null;
     $receiverGroup = null;
     $details = array('role' => array('name' => $role->getTranslationKey()));
     if ($role->getWorkspace()) {
         $details['workspace'] = array('name' => $role->getWorkspace()->getName());
     }
     if ($subject instanceof User) {
         $details['receiverUser'] = array('firstName' => $subject->getFirstName(), 'lastName' => $subject->getLastName());
         $action = self::ACTION_USER;
         $receiver = $subject;
     } else {
         $details['receiverGroup'] = array('name' => $subject->getName());
         $action = self::ACTION_GROUP;
         $receiverGroup = $subject;
     }
     parent::__construct($action, $details, $receiver, $receiverGroup, null, $role, $role->getWorkspace());
 }
示例#3
0
 /**
  * @EXT\Route(
  *     "role/{role}/edit/name/{name}",
  *     name="platform_role_name_edit",
  *     options={"expose"=true}
  * )
  * @EXT\Method("POST")
  *
  * @param Role $role
  * @return JsonResponse
  */
 public function editRoleNameAction(Role $role, $name)
 {
     if (ctype_space($name)) {
         return new JsonResponse(array('name' => $role->getName(), 'limit' => $role->getMaxUsers(), 'translationKey' => $role->getTranslationKey()), 500);
     }
     $role->setTranslationKey($name);
     $this->roleManager->edit($role);
     return new JsonResponse(array('name' => $role->getName(), 'limit' => $role->getMaxUsers(), 'translationKey' => $role->getTranslationKey()));
 }