コード例 #1
0
 public function executeInscription(HTTPRequest $Request)
 {
     $this->page->addVar('title', 'Inscription');
     $this->run();
     if ($Request->method() == 'POST') {
         $Member = new Member();
         $Member->setLogin($Request->postData('login'));
         $Member->setPassword($Request->postData('password'));
         $Member->setPassword_confirmation($Request->postData('password_confirmation'));
         $Member->setEmail($Request->postData('email'));
         $Member->setLevel(3);
     } else {
         $Member = new Member();
     }
     $FormBuilder = new MemberFormBuilder($Member, $this->managers->getManagerOf('Member'));
     $FormBuilder->build();
     $Form = $FormBuilder->form();
     // On récupère le gestionnaire de formulaire.
     $FormHandler = new \OCFram\FormHandler($Form, $this->managers->getManagerOf('Member'), $Request);
     if ($FormHandler->process()) {
         // Ici ne résident plus que les opérations à effectuer une fois l'entité du formulaire enregistrée
         // (affichage d'un message informatif, redirection, etc.).
         $this->app->user()->setFlash('Le membre a bien été ajouté, merci !');
         $this->app->user()->setAuthenticated(true);
         $this->app->user()->setAttribute('user', $Member);
         $this->app->httpResponse()->redirect('.');
     }
     $Router = new Router();
     $this->page->addVar('form', $Form->createView());
     $this->page->addVar('router', $Router);
 }
コード例 #2
0
 public function executeIndex(HTTPRequest $request)
 {
     $this->run();
     if ($request->method() == 'POST') {
         $member = new Member(['username' => $request->postData('username'), 'password' => $request->postData('password')]);
     } else {
         $member = new Member();
     }
     $formBuilder = new MemberFormBuilder($member);
     $formBuilder->build($this->managers->getManagerOf('Member'));
     $form = $formBuilder->form();
     $formHandler = new FormHandler($form, $this->managers->getManagerOf('Member'), $request);
     if ($formHandler->process()) {
         $this->app->user()->setAuthenticated(true);
         $this->app->httpResponse()->redirect($this->app->router()->getBuiltRoute('News', 'index', []));
     }
     $this->page->addVar('title', 'Connexion');
     $this->page->addVar('Member', $member);
     $this->page->addVar('form', $form->createView());
 }
コード例 #3
0
 public function executeIndex(HTTPRequest $request)
 {
     if ($request->method() == 'POST') {
         $member = new Member(['pseudo' => $request->postData('pseudo'), 'password' => $request->postData('password'), 'email' => $request->postData('email'), 'philosophy' => $request->postData('philosophy'), 'type' => Member::TYPE_AUTHOR]);
     } else {
         $member = new Member();
     }
     $membersManager = $this->managers->getManagerOf('Members');
     $formBuilder = new MemberFormBuilder($member);
     $formBuilder->build($this->managers->getManagerOf('Members'));
     $form = $formBuilder->form();
     $formHandler = new FormHandler($form, $membersManager, $request);
     if ($formHandler->process()) {
         $this->app->user()->setFlash('Merci de votre inscription !');
         $this->app->httpResponse()->redirect('/');
     }
     $this->page->addVar('member', $member);
     $this->page->addVar('form', $form->createView());
     $this->page->addVar('title', 'Ajout d\'un membre');
 }