/**
  * Returns the Responder
  * @return string
  */
 protected function htmlBody($data)
 {
     // Aura.view setup
     $view_factory = new ViewFactory();
     $view = $view_factory->newInstance();
     // layout
     $layout_registry = $view->getLayoutRegistry();
     $layout_registry->set('layout', $this->layout);
     // views
     $view_registry = $view->getViewRegistry();
     // get slug for partial view
     $slug = $this->request->getAttribute('page');
     $partial_view = $this->staticpages . $slug . '.php';
     // check if the partial file really exists,
     // if not throw an 404 error instead or aura view template not found
     if (!file_exists($partial_view)) {
         //            $this->response = $this->response->withStatus(404);
         //            $this->response = $this->response->withHeader('Content-Type', 'text/html');
         //            $this->response->getBody()->write('404');
         $this->error($payload);
     }
     // set the registy
     $view_registry->set('_content', $partial_view);
     /*
      * assign data to the view
      */
     // set data
     $dataset = ['data' => $data, 'partial' => 'partial', 'debug' => $this->payload->getStatus()];
     // assign data to view
     $view->setData($dataset);
     /*
      * check for ajax request and set views accordingly
      */
     if ($this->is_pjax()) {
         // pjax request, set the view only
         $view->setView('_content');
     } else {
         // regular http request, set view and layout
         $view->setLayout('layout');
         $view->setView('_content');
     }
     $output = $view->__invoke();
     // retun response
     // $this->response = $this->response->withStatus(202);
     $this->response = $this->response->withHeader('Content-Type', 'text/html');
     $this->response->getBody()->write($output);
 }
Beispiel #2
0
 /**
  * Unknown
  *
  * @return mixed
  *
  * @access protected
  */
 protected function unknown()
 {
     $this->response = $this->response->withStatus(500);
     $this->response->getBody()->write('Unknown authentication payload status: ' . $this->payload->getStatus());
 }
 /**
  *
  * Builds a Response when the payload status is not recognized.
  *
  */
 protected function unknown()
 {
     $this->response = $this->response->withStatus(500);
     $this->jsonBody(['error' => 'Unknown domain payload status', 'status' => $this->payload->getStatus()]);
 }
 /**
  * Returns the Responder
  * @return string
  */
 protected function htmlBody($data)
 {
     //
     // $slug = 'error';
     if (isset($data)) {
         // $slug = $this->request->getAttribute('page');
         $slugFromPayload = $this->payload->getOutput();
         //             $slug = $slugFromPayload['slug'];
         if (isset($slugFromPayload['slug'])) {
             $slug = $slugFromPayload['slug'];
         } else {
             $slug = 'index';
         }
         // $this->request = $this->request->withAttribute('page', 'error.php');
         //setup views
         //            $this->loadTemplate();
         //            $template = $this->twig->loadTemplate($view);
         //            $body = $template->render($data);
         //            $this->response = $this->response->withHeader('Content-Type', 'text/html');
         //            $this->response->getBody()->write($body);
     }
     // set thir probaly fro config file
     // Aura.view setup
     $view_factory = new ViewFactory();
     // a
     $view = $view_factory->newInstance();
     //
     // layout
     $layout_registry = $view->getLayoutRegistry();
     $layout_registry->set('layout', $this->layout);
     // views
     $view_registry = $view->getViewRegistry();
     $slug = $this->request->getAttribute('page');
     $partial_view = $this->staticpages . $slug . '.php';
     // check if the partial file exists, if not set status 404
     if (!file_exists($partial_view)) {
         $this->response = $this->response->withStatus(404);
         $partial_view = $this->staticpages . 'error' . '.php';
     }
     // set the registy
     $view_registry->set('_content', $partial_view);
     // demo data
     $dataset = ['data' => $data, 'partial' => 'partial', 'debug' => $this->payload->getStatus()];
     // assign data to the view
     $view->setData($dataset);
     /*
      * check for ajax request and set views accordingly
      */
     if ($this->is_pjax()) {
         // pjax request, set the view only
         // $this->renderView();
         $view->setView('_content');
     } else {
         // regular http request, set view and layout
         $view->setLayout('layout');
         $view->setView('_content');
     }
     $output = $view->__invoke();
     // retun response
     $this->response = $this->response->withHeader('Content-Type', 'text/html');
     $this->response->getBody()->write($output);
 }