コード例 #1
0
 /**
  * @covers \NewFrontiers\Framework\Core\Request::getArray
  * @covers \NewFrontiers\Framework\Core\Request::present
  */
 public function testConstructor()
 {
     $test = ['key' => 'value'];
     $request = new Request($test);
     $this->assertCount(1, $request->getArray());
     $this->assertTrue($request->present('key'));
     $this->assertEquals('value', $request->key);
 }
コード例 #2
0
 /**
  * Setzt die Informationen der geöffneten Seite den Request und Response
  * Objekten.
  *
  * @param Request $request
  * @param Page $page
  */
 public function setCurrentPage(&$request, $page)
 {
     Profiler::startSection('Routing.setCurrentPage');
     Application::getInstance()->setCurrentPage($page);
     $response = Application::getCurrentResponse();
     $request->module = $page->pa_module;
     $request->action = $page->pa_action;
     $request->innerTemplate = $page->pa_innertemplate;
     $request->parseParameter($page->pa_parameter);
     $this->generateBreadcrumbsForPage($page);
     Profiler::endSection('Routing.setCurrentPage');
 }
コード例 #3
0
 /**
  * @param Request $filter
  * @return ApiResource[]
  */
 public function filter($filter)
 {
     $maxResults = -1;
     if ($filter->present('$top')) {
         $name = '$top';
         $maxResults = $filter->{$name};
     }
     $skip = 0;
     if ($filter->present('$skip')) {
         $name = '$skip';
         $skip = $filter->{$name};
     }
     $entities = $this->entityRepository->filter($filter, $maxResults, $skip);
     $result = [];
     foreach ($entities as $entity) {
         $result[] = $this->getResourceFromEntity($entity);
     }
     return $result;
 }
コード例 #4
0
 protected function addRequest(Control $outerPanel, Request $request, &$i)
 {
     $i++;
     $innerPanel = new CaptionedPanelControl($outerPanel, 'nfsReq' . $i);
     $innerPanel->setCaption($request->module . '::' . $request->action);
     $innerPanel->add($this->getListView('nfsReqView' . $i, $this->arrayToDataArray($request->getFullArray())));
     foreach ($request->getSubRequests() as $current) {
         $this->addRequest($outerPanel, $current, $i);
     }
 }
コード例 #5
0
 /**
  * Bearbeitet einen Request. Ist diese Instanz zuständig, so wir der Request
  * ausgeführt. Wenn nicht, dann wird false zuurückgegen.
  *
  * @param Request $request
  * @param Response $response
  * @return bool
  */
 public function handleResourceRequest(Request $request, Response $response)
 {
     if ($this->isResourceRequest($request->action)) {
         // TODO: Für die Berechtigungsprüfung braucht man die Action noch.
         // TODO: Ggf. als Resource erfassen um das loszuwerden?
         Logging::debug('Handling Request via ' . (string) $this);
         if ($request->present('id')) {
             $this->resource = $this->loadOrCreateResource($request->id);
         } else {
             $this->resource = $this->loadOrCreateResource();
         }
         $callable = $this->possibleActions[$request->action];
         $callable($request, $response);
         if ($response->getContent() instanceof View) {
             $response->getContent()->setResource($this->resource);
         }
         return true;
     }
     return false;
 }
コード例 #6
0
 /**
  * Füllt das Request-Objekt auf Basis des Pathinfo.
  * @param Request $request
  * @param string $pathinfo
  */
 public function fillRequestByPathinfo(&$request, $pathinfo)
 {
     // Route: {module}/{action}/{key}/{value}/{key}/{value}/{addendum}...
     $queryString = explode('/', $pathinfo);
     $request->setParts($queryString);
     for ($i = 0; $i < count($queryString); $i++) {
         if ($i === 0) {
             $request->module = ucfirst($queryString[$i]);
         } elseif ($i === 1) {
             $request->action = $queryString[$i];
         } else {
             $key = $queryString[$i];
             $i++;
             if (isset($queryString[$i])) {
                 $request->{$key} = $queryString[$i];
             } else {
                 $request->addendum = $key;
             }
         }
     }
 }