Returns the current sorting options for the entity.

@param \Symfony\Component\HttpFoundation\Request $request
@param bool $ignoreSession
@return array
547581
public function getSorting(Request $request, $ignoreSession = false)
    {
        if ($ignoreSession) {
            return $this->getSortingFromRequest($request);
        }

        $sorting = array_replace(
            $this->getSortingFromSession($request->getSession()),
            $this->getSortingFromRequest($request)
        );

        $this->saveSorting($request->getSession(), $sorting);
        return $sorting;
    }
1060023
private function getRequestOptions(Request $request)
    {
        $options = [
            'http_errors' => false,
            'synchronous' => true
        ];

        if ($request->getQuery()) {
            $options['query'] = array_merge($this->getDefaultQuery(), $request->getQuery());
        } else {
            $options['query'] = $this->getDefaultQuery();
        }
        if ($request->getParams())
            $options['json'] = $request->getParams();

        return $options;
    }
1363081
public function listJsonAction(Request $request)
    {
        $totalEntities = $this->countTotal();
                
        $offset = intval($request->get('iDisplayStart'));
        $limit = intval($request->get('iDisplayLength'));
        $sortColumn = intval($request->get('iSortCol_0'));
        $sortDirection = $request->get('sSortDir_0');
        $search = $request->get('sSearch');
        $echo = intval($request->get('sEcho'));
        
        $entities = $this->findAllForDataTables($search, $sortColumn, $sortDirection, null, $request->getLocale());
        
        $totalFilteredEntities = count($entities->getScalarResult());

        // paginate
        $entities->setFirstResult($offset)
            ->setMaxResults($limit);

        $data = $entities->getResult();


        $response = array(
            'iTotalRecords'         => $totalEntities,
            'iTotalDisplayRecords'  => $totalFilteredEntities,
            'sEcho'                 => $echo,
            'aaData'                => $data
        );
        

        return new JsonResponse($response);
    }
1067412
protected function getStateDataFromRequest(Request $request)
    {
        $requestData = array_merge_recursive($request->query->all(), $request->request->all());

        $requestData = $this->requestExtractorCollection->extract($this->configuration->getAsArray(), $requestData, $this->sModuleSpotName);

        return $requestData;
    }
214690
protected List<?> getNewSelections(final Request request) {
		String[] paramValues = request.getParameterValues(getId());
		if (paramValues == null || paramValues.length == 0) {
			return NO_SELECTION;
		}

		List<String> values = Arrays.asList(paramValues);
		List<Object> newSelections = new ArrayList<>(values.size());

		// Figure out which options have been selected.
		List<?> options = getOptions();
		if (options == null || options.isEmpty()) {
			if (!isEditable()) {
				// User could not have made a selection.
				return NO_SELECTION;
			}
			options = Collections.EMPTY_LIST;
		}

		for (Object value : values) {
			boolean found = false;
			int optionIndex = 0;

			for (Object option : options) {
				if (option instanceof OptionGroup) {
					List<?> groupOptions = ((OptionGroup) option).getOptions();
					if (groupOptions != null) {
						for (Object nestedOption : groupOptions) {
							if (value.equals(optionToCode(nestedOption, optionIndex++))) {
								newSelections.add(nestedOption);
								found = true;
								break;
							}
						}
					}
				} else if (value.equals(optionToCode(option, optionIndex++))) {
					newSelections.add(option);
					found = true;
					break;
				}
			}

			if (!found) {
				if (isEditable()) {
					newSelections.add(value);
				} else {
					LOG.warn(
							"Option \"" + value + "\" on the request is not a valid option. Will be ignored.");
				}
			}
		}

		// If no valid options found, then return the current settings
		if (newSelections.isEmpty()) {
			LOG.warn("No options on the request are valid. Will be ignored.");
			return getValue();
		}

		// If must have selection and more than 1 option selected, remove the "null" entry if it was selected.
		if (!isAllowNoSelection() && newSelections.size() > 1) {
			List<Object> filtered = new ArrayList<>();
			Object nullOption = null;
			for (Object option : newSelections) {
				// Check option is null or empty
				boolean isNull = option == null ? true : option.toString().length() == 0;
				if (isNull) {
					// Hold the option as it could be "null" or "empty"
					nullOption = option;
				} else {
					filtered.add(option);
				}
			}
			// In the case where only null options were selected, then add one nullOption
			if (filtered.isEmpty()) {
				filtered.add(nullOption);
			}
			return filtered;
		} else {
			return newSelections;
		}
	}
78876
public function index($request)
    {
        $suite = 'check';

        if ($name = $request->param('Suite')) {
            $suite = $name;
        }

        $checker = new EnvironmentChecker($suite, 'Environment status');
        $checker->setRequest($request);
        $checker->init($this->config()->permission);

        return $checker;
    }
663269
public function listJsonAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var \AdminBundle\Services\DataTables\JsonList $jsonList */
        $jsonList = $this->get('json_list');
        $jsonList->setRepository($em->getRepository('CoreBundle:Page'));
        $jsonList->setLocale($request->getLocale());
        $response = $jsonList->get();
        

        return new JsonResponse($response);
    }
1288201
public function chooserIndexAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $session = $request->getSession();
        $folderId = false;

        $type = $request->get('type', 'all');
        $cKEditorFuncNum = $request->get('CKEditorFuncNum');
        $linkChooser = $request->get('linkChooser');

        // Go to the last visited folder
        if ($session->get('last-media-folder')) {
            try {
                $em->getRepository('KunstmaanMediaBundle:Folder')->getFolder($session->get('last-media-folder'));
                $folderId = $session->get('last-media-folder');
            } catch (EntityNotFoundException $e) {
                $folderId = false;
            }
        }

        if (!$folderId) {
            // Redirect to the first top folder
            /* @var Folder $firstFolder */
            $firstFolder = $em->getRepository('KunstmaanMediaBundle:Folder')->getFirstTopFolder();
            $folderId = $firstFolder->getId();
        }

        $params = array(
            'folderId' => $folderId,
            'type' => $type,
            'CKEditorFuncNum' => $cKEditorFuncNum,
            'linkChooser' => $linkChooser,
        );

        return $this->redirect($this->generateUrl('KunstmaanMediaBundle_chooser_show_folder', $params));
    }
437981
public function findUnhydratedEntities(Request $request, $filters = array(), $addPagination = false)
    {
        $options = $this->getOptions($request, $filters, $addPagination, true);
        if (!$addPagination) {
            return array(
                'entities' => $this->getRepository()->getEntities($options, AbstractQuery::HYDRATE_ARRAY),
                'options' => $options
            );
        }

        $entities = $this->getRepository()->getPaginatedEntities($options, AbstractQuery::HYDRATE_ARRAY);
        $options['elements'] = $entities->count();
        $options['pages'] = (int)ceil($options['elements'] / $options['elementsPerPage']);

        return array(
            'entities' => (array)$entities->getIterator(),
            'options' => $options
        );
    }
1271289
public function bindRequest(Request $request)
    {
        $query = $request->query;
        $session = $request->getSession();

        $adminListName = 'listconfig_'.$request->get('_route');

        $this->page = $request->query->getInt('page', 1);
        // Allow alphanumeric, _ & . in order by parameter!
        $this->orderBy = preg_replace('/[^[a-zA-Z0-9\_\.]]/', '', $request->query->get('orderBy', ''));
        $this->orderDirection = $request->query->getAlpha('orderDirection', '');

        // there is a session and the filter param is not set
        if ($session->has($adminListName) && !$query->has('filter')) {
            $adminListSessionData = $request->getSession()->get($adminListName);
            if (!$query->has('page')) {
                $this->page = $adminListSessionData['page'];
            }

            if (!$query->has('orderBy')) {
                $this->orderBy = $adminListSessionData['orderBy'];
            }

            if (!$query->has('orderDirection')) {
                $this->orderDirection = $adminListSessionData['orderDirection'];
            }
        }

        // save current parameters
        $session->set(
            $adminListName,
            array(
                'page' => $this->page,
                'orderBy' => $this->orderBy,
                'orderDirection' => $this->orderDirection,
            )
        );

        $this->getFilterBuilder()->bindRequest($request);
    }
604198
public function getPageParameters(Request $request)
    {
        /** @var $page \Networking\InitCmsBundle\Model\PageInterface */
        $page = $request->get('_content', null);

        if (is_null($page)) {
            throw $this->createNotFoundException('no page object found');
        }

        if ($page instanceof PageSnapshot) {
            return $this->getLiveParameters($request, $page);
        }

        return $this->getDraftParameters($request, $page);
    }
975482
public function getOptions(Request $request)
    {
        $options = array();
        foreach ($this->providers as $provider) {
            $options = array_merge($options, $provider->getOptions($request));
        }

        return $options;
    }
689490
public function listAction(Request $request)
    {
        $current_page = $request->get('page', 1);
        $current_page = $current_page > 1 ? $current_page : 1;
        $rep = $this->getRepository();

        // filter list notice
        $filter = $this->createForm('notices_filter')->handleRequest($request);
        if ($filter->isValid()) {
            $query = $rep->getFilteredQuery($filter->getData()['status'], $filter->getData()['type']);
        } else {
            $query = $rep->createQueryBuilder('n');
        }
        $query
            ->orderBy('n.date_created', 'DESC')
            ->setFirstResult(($current_page - 1) * self::NOTICE_PER_PAGE)
            ->setMaxResults(self::NOTICE_PER_PAGE);
        $list = $query->getQuery()->getResult();

        // get count all items
        $count = $query
            ->select('COUNT(n)')
            ->getQuery()
            ->getSingleScalarResult();

        // pagination
        $that = $this;
        $request_query = $request->query->all();
        unset($request_query['page']);
        $pagination = $this->get('anime_db.pagination')
            ->create(ceil($count / self::NOTICE_PER_PAGE), $current_page)
            ->setPageLink(function ($page) use ($that, $request_query) {
                return $that->generateUrl('notice_list', array_merge($request_query, ['page' => $page]));
            })
            ->setFirstPageLink($this->generateUrl('notice_list', $request_query))
            ->getView();

        return $this->render('AnimeDbCatalogBundle:Notice:list.html.twig', [
            'list' => $list,
            'pagination' => $pagination,
            'change_form' => $this->createForm(new ChangeNotice())->createView(),
            'filter' => $filter->createView(),
            'action_remove' => ChangeNotice::ACTION_REMOVE,
        ]);
    }
229206
private function setOrAddSession(Request $request)
    {
        $containerName = $request->getPost('containerName', 'Default');
        $keysession = $request->getPost('keysession', '');
        $sessionValue = $request->getPost('sessionvalue', '');
        $new = (bool) $request->getPost('new', false);

        $notEmptyValidator = new NotEmpty();
        if ($notEmptyValidator->isValid($keysession) && $notEmptyValidator->isValid($sessionValue)) {
            $success = $this->sessionManager
                            ->sessionSetting($containerName, $keysession, $sessionValue, ['set' => true, 'new' => $new]);

            return ['success' => $success, 'errorMessage' => ''];
        }

        return ['success' => false, 'errorMessage' => 'Value is required and can\'t be empty'];
    }
395906
public static function filter(Request $request)
    {
        $bags = MutableBag::from(array_fill_keys(['attributes', 'query', 'files', 'cookies', 'headers', 'server'], null));
        foreach ($bags->keys() as $key) {
            $bags[$key] = static::getValues($request->$key->all());
        }
        if ($request->hasSession()) {
            $bags['session'] = static::getValues($request->getSession()->all());
        }

        return $bags->immutable();
    }
267631
protected function getSortingFromRequest(Request $request)
    {
        return $this->extractValues($this->getValuesFromRequest($request), $this->getSortingPrefix());
    }
742656
public function sortAction(Request $request)
    {
        $tid = $request->get('tid');
        $mode = $request->get('mode');
        $dir = strtolower($request->get('dir'));
        $sortTids = $request->get('sort_ids');
        $sortTids = json_decode($sortTids, true);

        $treeManager = $this->get('phlexible_tree.tree_manager');
        $nodeSorter = $this->get('phlexible_tree.node_sorter');

        $tree = $treeManager->getByNodeId($tid);
        $node = $tree->get($tid);

        $node->setSortMode($mode);
        $node->setSortDir($dir);

        if ($mode !== TreeInterface::SORT_MODE_FREE) {
            $sortTids = $nodeSorter->sort($node);
        }

        if (count($sortTids)) {
            $tree->reorderChildren($node, $sortTids);
        }

        return new ResultResponse(true, 'Tree sort published.');
    }