예제 #1
0
 /**
  * Prepares the user's post data and returns it as an array. Sets the request method to POST.
  * @param UserEntity $loggedUser
  * @param int $userRole The user role (1 - admin ... 4 - guest)
  * @param string $uname The user name to assigned
  * @return array The prepared post data.
  */
 protected function prepareAddUser($loggedUser, $userRole = UserEntity::USER_SUPER_ADMIN, $uname = 'adminito')
 {
     $serviceManager = $this->controller->getServiceLocator();
     $form = new User($loggedUser, $serviceManager->get('entity-manager'));
     $password = $loggedUser->hashPassword('Demo123456');
     return ['uname' => $uname, 'email' => '*****@*****.**', 'password_fields' => ['password' => $password, 'password_repeat' => $password], 'role' => $userRole, 'user_csrf' => $form->get('user_csrf')->getValue()];
 }
예제 #2
0
 protected function renderData($action, \Admin\Form\User $form, $editOwn, User $user)
 {
     $renderer = $this->getServiceLocator()->get('Zend\\View\\Renderer\\RendererInterface');
     $viewModel = new ViewModel(['action' => $action, 'id' => $user->getId(), 'form' => $form, 'editOwn' => $editOwn, 'user' => $user]);
     $viewModel->setTemplate('admin/user/edit');
     return new JsonModel(['title' => $this->translator->translate(ucfirst($action) . ' a user'), 'form' => $renderer->render($viewModel)]);
 }