/** * @return ModelAndView **/ public function run(Prototyped $subject, Form $form, HttpRequest $request) { if ($object = $form->getValue('id')) { FormUtils::object2form($object, $form); } return ModelAndView::create(); }
protected function handleMav(ModelAndView $mav) { $view = $mav->getView() ?: self::DEFAULT_TEMPLATE; $model = $mav->getModel(); if (!$view instanceof RedirectView) { $model->set('area', $this->controllerName); } if (is_string($view)) { if ($view == $this->controllerName) { $view = self::DEFAULT_TEMPLATE; } $viewResolver = $this->getViewResolver(); foreach ($this->getTemplatePathList() as $templatePath) { $viewResolver->addPrefix($templatePath); } $view = $viewResolver->resolveViewName($view); } $view->render($model); }
/** * @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 postHandleRequest(ModelAndView $mav, HttpRequest $request) { $form = $this->getForm(); if ($mav->getView() == self::COMMAND_SUCCEEDED) { $mav->setView(new RedirectToView(get_class($this))); $mav->getModel()->drop('id'); } else { $mav->setView(get_class($this)); if ($command = $form->getValue('action')) { $mav->getModel()->set('action', $command); } else { $form->dropAllErrors(); } $mav->getModel()->set('form', $form); } return $mav; }
/** * @return ModelAndView **/ public function handleRequest(HttpRequest $request) { if ($action = $this->chooseAction($request)) { $method = $this->methodMap[$action]; /** @var ModelAndView $mav */ $mav = $this->{$method}($request); if ($mav->viewIsRedirect()) { return $mav; } $mav->getModel()->set('chosenAction', $action); return $mav; } else { return ModelAndView::create(); } }
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())); }
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 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)); } }
/** * @return ModelAndView **/ public function run(Prototyped $subject, Form $form, HttpRequest $request) { return ModelAndView::create()->setView(EditorController::COMMAND_FAILED); }
public function __construct() { $this->mav = ModelAndView::create()->setModel(Model::create()); $this->defaultRequestType = RequestType::post(); }