/** * @return ModelAndView **/ public function run(Prototyped $subject, Form $form, HttpRequest $request) { if ($object = $form->getValue('id')) { FormUtils::object2form($object, $form); } return ModelAndView::create(); }
public function handleRequest(HttpRequest $request) { if (1 === 1) { return ModelAndView::create()->setView('main'); } else { throw new WrongStateException('everything is b0rked'); } }
/** * @return ModelAndView **/ public function handleRequest(HttpRequest $request) { $result = ModelAndView::create(); if ($this->model) { $result->setModel($this->model); } return $result; }
public function handleRequest(HttpRequest $request) { if (!Session::isStarted()) { Session::start(); } if (!Session::get(Administrator::LABEL) instanceof Administrator && !$this->controller instanceof login) { Session::destroy(); return ModelAndView::create()->setView('login'); } return $this->controller->handleRequest($request); }
/** * @return ModelAndView **/ public function run(Prototyped $subject, Form $form, HttpRequest $request) { if ($object = $form->getValue('id')) { if ($object instanceof Identifiable) { $object->dao()->drop($object); return ModelAndView::create()->setView(BaseEditor::COMMAND_SUCCEEDED); } else { // already deleted $form->markMissing('id'); } } return ModelAndView::create(); }
/** * @return ModelAndView **/ public function handleRequest(HttpRequest $request) { $this->map->import($request); $form = $this->getForm(); if (!($command = $form->getValue('action'))) { $command = $form->get('action')->getDefault(); } if ($command) { $mav = $this->{$this->commandMap[$command]}($this->subject, $form, $request); } else { $mav = ModelAndView::create(); } return $this->postHandleRequest($mav, $request); }
/** * @return ModelAndView **/ public function handleRequest(HttpRequest $request) { if ($action = $this->chooseAction($request)) { $method = $this->methodMap[$action]; $mav = $this->{$method}($request); if ($mav->viewIsRedirect()) { return $mav; } $mav->getModel()->set('action', $action); return $mav; } else { return ModelAndView::create(); } Assert::isUnreachable(); }
public function handleRequest(HttpRequest $request) { $form = Form::create()->add(Primitive::string('username')->setMax(64)->required())->add(Primitive::string('password')->addImportFilter(Filter::hash())->required())->import($request->getPost()); if (!$form->getErrors()) { try { $admin = Administrator::dao()->logIn($form->getValue('username'), $form->getValue('password')); } catch (ObjectNotFoundException $e) { // failed to log in return ModelAndView::create()->setView('error'); } if (!Session::isStarted()) { Session::start(); } Session::assign(Administrator::LABEL, $admin); return ModelAndView::create()->setView(new RedirectToView('main')); } return ModelAndView::create()->setView('login'); }
public function __construct() { $this->mav = ModelAndView::create()->setModel(Model::create()); $this->defaultRequestType = RequestType::post(); }
public static function errorMav($message = null) { $uri = (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null) . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null); return ModelAndView::create()->setView('error')->setModel(Model::create()->set('errorMessage', ($message ? $message . ': ' : null) . $uri)); }
/** * @return ModelAndView **/ public function run(Prototyped $subject, Form $form, HttpRequest $request) { return ModelAndView::create()->setView(EditorController::COMMAND_FAILED); }
/** * @return ModelAndView **/ public function doAdd(HttpRequest $request) { $this->map->import($request); $form = $this->getForm(); $form->markGood('id'); $object = clone $this->subject; if (!$form->getErrors()) { $object = $this->addObject($request, $form, $object); $editorResult = $form->getErrors() ? self::COMMAND_FAILED : self::COMMAND_SUCCEEDED; return ModelAndView::create()->setModel(Model::create()->set('id', $object->getId())->set('subject', $object)->set('form', $form)->set('editorResult', $editorResult)); } else { return ModelAndView::create()->setModel(Model::create()->set('form', $form)->set('subject', $object)->set('editorResult', self::COMMAND_FAILED)); } Assert::isUnreachable(); }
private function makeCheckIdRequest(OpenIdCredentials $credentials, HttpUrl $returnTo, $trustRoot = null, $association = null) { Assert::isTrue($returnTo->isValid()); $view = RedirectView::create($credentials->getServer()->toString()); $model = Model::create()->set('openid.ns', self::NAMESPACE_2_0)->set('openid.identity', $credentials->getRealId()->toString())->set('openid.return_to', $returnTo->toString())->set('openid.claimed_id', $credentials->getRealId()->toString()); foreach ($this->extensions as $extension) { $extension->addParamsToModel($model); } if ($association) { Assert::isTrue($association instanceof OpenIdConsumerAssociation && $association->getServer()->toString() == $credentials->getServer()->toString()); $model->set('openid.assoc_handle', $association->getHandle()); } if ($trustRoot) { Assert::isTrue($trustRoot instanceof HttpUrl && $trustRoot->isValid()); $model->set('openid.trust_root', $trustRoot->toString())->set('openid.realm', $trustRoot->toString()); } return ModelAndView::create()->setModel($model)->setView($view); }
/** * @return ModelAndView **/ public function run(Prototyped $subject, Form $form, HttpRequest $request) { $subject = $subject->dao()->{$this->daoMethod()}($subject); return ModelAndView::create()->setView(EditorController::COMMAND_SUCCEEDED)->setModel(Model::create()->set('id', $subject->getId())); }