예제 #1
0
 /**
  * @param int $editedUserID The ID of the user being edited
  * @param UserEntity $currentUser
  * @param int $newRole The new role of the edited user
  * @return mixed|null|\Zend\Stdlib\ResponseInterface
  */
 protected function dispatchEdit($editedUserID, $currentUser, $newRole = 1)
 {
     if (!is_int($newRole)) {
         throw new \InvalidArgumentException();
     }
     $this->getRequest()->setMethod(Request::METHOD_PUT);
     $this->routeMatch->setParam('id', $editedUserID);
     $form = new User($currentUser, $this->controller->getServiceLocator()->get('entity-manager'));
     $this->getRequest()->setContent('uname=admin3&email=ventsi2@mail.com&role=' . $newRole . '&user_csrf=' . $form->get('user_csrf')->getValue());
     $jsonModel = null;
     try {
         $jsonModel = $this->controller->dispatch($this->getRequest());
     } catch (\Exception $e) {
         var_dump($e->getMessage());
     }
     return $jsonModel;
 }