getSortColumn() public method

Returns the desired sort column.
public getSortColumn ( ) : string
return string
Example #1
0
 /**
  * @dataProvider dataFieldsProvider
  */
 public function testGetFields($request)
 {
     $helper = new ListRestHelper($request, $this->em);
     $this->assertEquals(explode(',', $request->get('fields')), $helper->getFields());
     $this->assertEquals($request->get('sortBy'), $helper->getSortColumn());
     $this->assertEquals($request->get('sortOrder', 'asc'), $helper->getSortOrder());
     $this->assertEquals($request->get('search'), $helper->getSearchPattern());
     $this->assertEquals(explode(',', $request->get('searchFields')), $helper->getSearchFields());
     $this->assertEquals($request->get('limit'), $helper->getLimit());
     $this->assertEquals($request->get('limit') * ($request->get('page') - 1), $helper->getOffset());
 }
Example #2
0
 public function testGetFields()
 {
     $request = new Request(['fields' => 'field1,field2,field3', 'sortBy' => 'id', 'sortOrder' => 'desc', 'search' => 'test', 'searchFields' => 'title', 'limit' => 10, 'page' => 3]);
     $helper = new ListRestHelper($request, $this->em);
     $this->assertEquals(['field1', 'field2', 'field3'], $helper->getFields());
     $this->assertEquals('id', $helper->getSortColumn());
     $this->assertEquals('desc', $helper->getSortOrder());
     $this->assertEquals('test', $helper->getSearchPattern());
     $this->assertEquals(['title'], $helper->getSearchFields());
     $this->assertEquals(10, $helper->getLimit());
     $this->assertEquals(20, $helper->getOffset());
 }
Example #3
0
 /**
  * Returns list of snippets.
  *
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getSnippetsAction(Request $request)
 {
     $this->initEnv($request);
     $listRestHelper = new ListRestHelper($request);
     // if the type parameter is falsy, assign NULL to $type
     $type = $request->query->get('type', null) ?: null;
     $uuidsString = $request->get('ids');
     if ($uuidsString) {
         $uuids = explode(',', $uuidsString);
         $snippets = $this->snippetRepository->getSnippetsByUuids($uuids, $this->languageCode);
         $total = count($snippets);
     } else {
         $snippets = $this->snippetRepository->getSnippets($this->languageCode, $type, $listRestHelper->getOffset(), $listRestHelper->getLimit(), $listRestHelper->getSearchPattern(), $listRestHelper->getSortColumn(), $listRestHelper->getSortOrder());
         $total = $this->snippetRepository->getSnippetsAmount($this->languageCode, $type, $listRestHelper->getSearchPattern(), $listRestHelper->getSortColumn(), $listRestHelper->getSortOrder());
     }
     $data = [];
     foreach ($snippets as $snippet) {
         $snippetData = $snippet->toArray();
         $snippetData['localizedTemplate'] = $snippet->getLocalizedTitle($this->languageCode);
         $data[] = $snippetData;
     }
     $data = new ListRepresentation($this->decorateSnippets($data, $this->languageCode), 'snippets', 'get_snippets', $request->query->all(), $listRestHelper->getPage(), $listRestHelper->getLimit(), $total);
     return $this->viewHandler->handle(View::create($data));
 }
Example #4
0
 /**
  * Returns list of snippets.
  *
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function cgetAction(Request $request)
 {
     $locale = $this->getLocale($request);
     // if the type parameter is falsy, assign NULL to $type
     $type = $request->query->get('type', null) ?: null;
     $uuidsString = $request->get('ids');
     if ($uuidsString) {
         $uuids = explode(',', $uuidsString);
         $snippets = $this->snippetRepository->getSnippetsByUuids($uuids, $locale);
         $total = count($snippets);
     } else {
         $snippets = $this->snippetRepository->getSnippets($locale, $type, $this->listRestHelper->getOffset(), $this->listRestHelper->getLimit(), $this->listRestHelper->getSearchPattern(), $this->listRestHelper->getSortColumn(), $this->listRestHelper->getSortOrder());
         $total = $this->snippetRepository->getSnippetsAmount($locale, $type, $this->listRestHelper->getSearchPattern(), $this->listRestHelper->getSortColumn(), $this->listRestHelper->getSortOrder());
     }
     $data = new ListRepresentation($snippets, 'snippets', 'get_snippets', $request->query->all(), $this->listRestHelper->getPage(), $this->listRestHelper->getLimit(), $total);
     return $this->viewHandler->handle(View::create($data));
 }