コード例 #1
0
 public function testCGetActionWithUnexistingAlias()
 {
     $query = ['alias' => 'not_existent_alias'];
     $request = new Request($query);
     $contentNavigationAliasNotFoundException = new ContentNavigationAliasNotFoundException($query['alias'], []);
     $this->contentNavigationCollector->getNavigationItems(Argument::cetera())->willThrow($contentNavigationAliasNotFoundException);
     $exception = new RestException($contentNavigationAliasNotFoundException->getMessage(), 0, $contentNavigationAliasNotFoundException);
     $this->viewHandler->handle(View::create($exception->toArray(), 404))->shouldBeCalled();
     $this->contentNavigationController->cgetAction($request);
 }
コード例 #2
0
 /**
  * Returns all the content navigation items for a given alias.
  *
  * @param Request $request
  *
  * @return Response
  */
 public function cgetAction(Request $request)
 {
     try {
         $alias = $request->get('alias');
         if (!$alias) {
             throw new RestException('The alias attribute is required to load the content navigation');
         }
         $options = $request->query->all();
         $contentNavigationItems = $this->contentNavigationRegistry->getNavigationItems($alias, $options);
         $view = View::create($contentNavigationItems);
     } catch (ContentNavigationAliasNotFoundException $exc) {
         $restException = new RestException($exc->getMessage(), 0, $exc);
         $view = View::create($restException->toArray(), 404);
     } catch (RestException $exc) {
         $view = View::create($exc->toArray(), 400);
     }
     return $this->viewHandler->handle($view);
 }
コード例 #3
0
 public function testGetNavigationItemsWithNotExistentAlias()
 {
     $this->setExpectedException(ContentNavigationAliasNotFoundException::class);
     $this->contentNavigationCollector->getNavigationItems('not_existent_alias');
 }