public function processDefaultAction(FormActionEvent $event)
 {
     // Don't update anything if we just want to cancel the draft.
     if ($event->getClickedButton() === 'removeDraft') {
         return;
     }
     /** @var \EzSystems\RepositoryForms\Data\Role\RoleData $roleData */
     $roleData = $event->getData();
     $roleDraft = $roleData->roleDraft;
     $this->roleService->updateRoleDraft($roleDraft, $roleData);
 }
Esempio n. 2
0
 /**
  * Updates a role draft.
  *
  * @param mixed $roleId Original role ID, or ID of the role draft itself
  *
  * @return \eZ\Publish\API\Repository\Values\User\RoleDraft
  */
 public function updateRoleDraft($roleId, Request $request)
 {
     $createStruct = $this->inputDispatcher->parse(new Message(array('Content-Type' => $request->headers->get('Content-Type')), $request->getContent()));
     try {
         // First try to load the draft for given role.
         $roleDraft = $this->roleService->loadRoleDraftByRoleId($roleId);
     } catch (NotFoundException $e) {
         // We might want a newly created role, so try to load it by its ID.
         // loadRoleDraft() might throw a NotFoundException (wrong $roleId). If so, let it bubble up.
         $roleDraft = $this->roleService->loadRoleDraft($roleId);
     }
     return $this->roleService->updateRoleDraft($roleDraft, $this->mapToUpdateStruct($createStruct));
 }
 public function processSaveRole(FormActionEvent $event)
 {
     $roleDraft = $this->getRoleDraft($event);
     $this->roleService->updateRoleDraft($roleDraft, $this->getRoleData($event));
     $this->roleService->publishRoleDraft($roleDraft);
 }
Esempio n. 4
0
 /**
  * Updates the properties of a role draft.
  *
  * @since 6.0
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update a role
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the identifier of the role already exists
  *
  * @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft
  * @param \eZ\Publish\API\Repository\Values\User\RoleUpdateStruct $roleUpdateStruct
  *
  * @return \eZ\Publish\API\Repository\Values\User\RoleDraft
  */
 public function updateRoleDraft(RoleDraft $roleDraft, RoleUpdateStruct $roleUpdateStruct)
 {
     $returnValue = $this->service->updateRoleDraft($roleDraft, $roleUpdateStruct);
     $this->signalDispatcher->emit(new UpdateRoleDraftSignal(array('roleId' => $roleDraft->id)));
     return $returnValue;
 }
Esempio n. 5
0
 /**
  * Updates a role draft.
  *
  * @param $roleId
  *
  * @return \eZ\Publish\API\Repository\Values\User\RoleDraft
  */
 public function updateRoleDraft($roleId, Request $request)
 {
     $createStruct = $this->inputDispatcher->parse(new Message(array('Content-Type' => $request->headers->get('Content-Type')), $request->getContent()));
     return $this->roleService->updateRoleDraft($this->roleService->loadRoleDraft($roleId), $this->mapToUpdateStruct($createStruct));
 }