public function load(ObjectManager $manager)
 {
     $user1 = new User();
     $user1->setName('Ila Best')->setEmail('*****@*****.**');
     $manager->persist($user1);
     $user2 = new User();
     $user2->setName('Honorato Navarro')->setEmail('*****@*****.**');
     $manager->persist($user2);
     $user3 = new User();
     $user3->setName('Reuben Ross')->setEmail('*****@*****.**');
     $manager->persist($user3);
     $user4 = new User();
     $user4->setName('Buckminster Patel')->setEmail('*****@*****.**');
     $manager->persist($user4);
     $user5 = new User();
     $user5->setName('Kaitlin Pearson')->setEmail('*****@*****.**');
     $manager->persist($user5);
     $user6 = new User();
     $user6->setName('Devin Carson')->setEmail('*****@*****.**');
     $manager->persist($user6);
     $user7 = new User();
     $user7->setName('Peter James')->setEmail('*****@*****.**');
     $manager->persist($user7);
     $user8 = new User();
     $user8->setName('Carol Burgess')->setEmail('*****@*****.**');
     $manager->persist($user8);
     $user9 = new User();
     $user9->setName('Walter Mccormick')->setEmail('*****@*****.**');
     $manager->persist($user9);
     $user10 = new User();
     $user10->setName('Stuart Grant')->setEmail('*****@*****.**');
     $manager->persist($user10);
     $manager->flush();
 }
示例#2
0
 public function registerAction()
 {
     $form = new \Application\Form\RegisterForm();
     $request = $this->getRequest();
     $authService = $this->getServiceLocator()->get('Zend\\Authentication\\AuthenticationService');
     $adapter = $authService->getAdapter();
     $data = array();
     $model = new User();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         $model->setEmail($request->getPost()->email);
         $model->setName($request->getPost()->name);
         $model->setRole(User::UserRoleRegisteredUser);
         if (!empty($request->getPost()->password)) {
             $model->setPassword($request->getPost()->password);
         }
         if ($form->isValid()) {
             $this->getObjectManager()->persist($model);
             $this->getObjectManager()->flush();
             //                return $this->redirect()->toUrl('/admin/' . $this->_modelAlias);
         }
     }
     $viewVariables['form'] = $form;
     $viewVariables['model'] = $model;
     //        $this->_view->setVariables($viewVariables);
     return new ViewModel($viewVariables);
 }
示例#3
0
 public function editAction()
 {
     $form = new \Admin\Form\UserForm();
     $id = (int) $this->params()->fromRoute('id', 0);
     if ($id > 0) {
         $model = $this->getObjectManager()->find($this->_modelName, $id);
         $form->setData($model->toArray());
         $form->setAttribute('action', '/admin/' . $this->_modelAlias . '/edit/' . $id);
         $form->get('submit')->setAttribute('value', 'Edit');
         $model->setUpdatedDate(new \DateTime());
         $viewVariables['action'] = 'Edit';
     } else {
         $model = new User();
         $form->setAttribute('action', '/admin/' . $this->_modelAlias . '/add');
         $form->get('submit')->setAttribute('value', 'Add');
         $model->setCreatedDate(new \DateTime());
         $viewVariables['action'] = 'Add';
     }
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         $model->setEmail($request->getPost()->email);
         $model->setName($request->getPost()->name);
         $model->setRole($request->getPost()->role);
         if (!empty($request->getPost()->password)) {
             $model->setPassword($request->getPost()->password);
         }
         if ($form->isValid()) {
             $this->getObjectManager()->persist($model);
             $this->getObjectManager()->flush();
             return $this->redirect()->toUrl('/admin/' . $this->_modelAlias);
         }
     }
     $viewVariables['form'] = $form;
     $viewVariables['model'] = $model;
     $this->_view->setTemplate('admin/' . $this->_modelAlias . '/edit');
     $this->_view->setVariables($viewVariables);
     return $this->_view;
 }
 /**
  * {@inheritDoc}
  */
 public function setName($name)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setName', array($name));
     return parent::setName($name);
 }