Exemplo n.º 1
0
 /**
  * @param Model $model
  **/
 public function addParamsToModel(Model $model)
 {
     if ($this->version == '1.1') {
         $model->set('openid.ns.sreg', self::NAMESPACE_1_1);
     }
     $model->set('openid.sreg.optional', implode(',', $this->params));
 }
Exemplo n.º 2
0
 /**
  * @return SimplePhpView
  **/
 public function render(Model $model = null)
 {
     Assert::isTrue($model === null || $model instanceof Model);
     if ($model) {
         extract($model->getList());
     }
     $partViewer = new PartViewer($this->partViewResolver, $model);
     $this->preRender();
     include $this->templatePath;
     $this->postRender();
     return $this;
 }
Exemplo n.º 3
0
 /**
  * @return Model
  **/
 public function merge(Model $model, $overwrite = false)
 {
     if (!$model->isEmpty()) {
         $vars = $model->getList();
         foreach ($vars as $name => $value) {
             if (!$overwrite && $this->has($name)) {
                 continue;
             }
             $this->set($name, $value);
         }
     }
     return $this;
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 /**
  * @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()));
 }
Exemplo n.º 6
0
 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));
 }
Exemplo n.º 7
0
 /**
  * @param Model $model
  *
  * @return string
  */
 public function toString(Model $model = null)
 {
     Assert::isTrue($model === null || $model instanceof Model);
     if ($this->options) {
         return json_encode($model ? $model->getList() : [], $this->options);
     } else {
         return json_encode($model ? $model->getList() : []);
     }
 }
Exemplo n.º 8
0
 /**
  * @param Model $model
  * @return string
  * @throws WrongArgumentException
  */
 public function toString(Model $model = null)
 {
     if ($model == null) {
         throw new WrongArgumentException('$model is required');
     }
     if (!$model->has('data')) {
         throw new WrongArgumentException('"data" in model is not defined');
     }
     $csv = '';
     if ($model->has('fields')) {
         $csv .= self::rowToCsv($model->get('fields'), $this->excelStrings) . self::EOL;
     }
     foreach ($model->get('data') as $row) {
         $csv .= self::rowToCsv($row, $this->excelStrings) . self::EOL;
     }
     if ($this->encoding && strtoupper($this->encoding) != 'UTF-8') {
         $csv = iconv('UTF-8', $this->encoding . '//TRANSLIT', $csv);
     }
     return $csv;
 }
 /**
  * @param Model $model
  **/
 public function addParamsToModel(Model $model)
 {
     $model->set('openid.ns.ax', self::NAMESPACE_1_0)->set('openid.ax.mode', 'fetch_request')->set('openid.ax.required', implode(',', $this->params))->set('openid.ax.type.country', 'http://axschema.org/contact/country/home')->set('openid.ax.type.email', 'http://axschema.org/contact/email')->set('openid.ax.type.firstname', 'http://axschema.org/namePerson/first')->set('openid.ax.type.lastname', 'http://axschema.org/namePerson/last')->set('openid.ax.type.language', 'http://axschema.org/pref/language');
 }
Exemplo n.º 10
0
 /**
  * @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));
     }
 }
Exemplo n.º 11
0
 public function __construct()
 {
     $this->mav = ModelAndView::create()->setModel(Model::create());
     $this->defaultRequestType = RequestType::post();
 }