Select a link

@Route("/select-nodes-lazy", name="KunstmaanNodeBundle_nodes_lazy")

@param \Symfony\Component\HttpFoundation\Request $request

@return JsonResponse
506837
public function selectNodesLazy(Request $request)
    {
        /* @var EntityManagerInterface $em */
        $em = $this->getDoctrine()->getManager();
        $locale = $request->getLocale();
        $id = $request->query->get('id');
        $depth = $this->getParameter('kunstmaan_node.url_chooser.lazy_increment');

        if (!$id || $id == '#') {
            $domainConfig = $this->get('kunstmaan_admin.domain_configuration');

            if ($domainConfig->isMultiDomainHost()) {
                $switchedHost = $domainConfig->getHostSwitched();
                $rootItems = [$domainConfig->getRootNode($switchedHost['host'])];
            } else {
                $rootItems = $em->getRepository('KunstmaanNodeBundle:Node')->getAllTopNodes();
            }
        } else {
            $rootItems = $em->getRepository('KunstmaanNodeBundle:Node')->find($id)->getChildren();
        }

        $results = $this->nodesToArray($locale, $rootItems, $depth);

        return new JsonResponse($results);
    }
1331275
public function listAction(Request $request)
    {
        $treeId = $request->get('tid');
        $layoutAreaId = $request->get('area_id');
        $language = $request->get('language');
        $sort = $request->get('sort', 'sort');
        $dir = $request->get('dir', 'ASC');

        $treeManager = $this->get('phlexible_tree.tree_manager');
        $teaserManager = $this->get('phlexible_teaser.teaser_manager');
        $elementService = $this->get('phlexible_element.element_service');
        $elementtypeService = $this->get('phlexible_elementtype.elementtype_service');
        $iconResolver = $this->get('phlexible_element.icon_resolver');

        $treeNode = $treeManager->getByNodeId($treeId)->get($treeId);
        $treeNodePath = $treeNode->getTree()->getPath($treeNode);

        if (!$language) {
            $element = $elementService->findElement($treeNode->getTypeId());
            $language = $elementMasterLanguage = $element->getMasterLanguage();
        }

        $filter = $request->get('filter');
        if ($filter) {
            $filter = json_decode($filter, true);
        }

        $layoutarea = $elementtypeService->findElementtype($layoutAreaId);
        $teasers = $teaserManager->findForLayoutAreaAndTreeNodePath($layoutarea, $treeNodePath);

        $parent = [
            'teaser_id' => $treeId, //(int) $teaserData->id,
            'tid' => 0,
            'title' => $treeNode->getId(), //$teaserData->text,
            'element_type_id' => (int) $layoutarea->getId(),
            'element_type' => $layoutarea->getTitle(),
            'icon' => $iconResolver->resolveElementtype($layoutarea),
            'author' => 'author',
            'version' => $layoutarea->getRevision(),
            'create_time' => $layoutarea->getCreatedAt(),
            //            'change_time'     => '2007-01-01 01:01:01',
            'publish_time' => null,
            'language' => $language,
            'sort' => 0,
            'sort_mode' => 'free',
            'sort_dir' => 'asc',
            'version_latest' => (int) $layoutarea->getRevision(),
            'version_online' => (int) $layoutarea->getRevision(),
            'status' => ' o_O ',
            'qtip' => $layoutarea->getTitle().', Version '.$layoutarea->getRevision().'<br>'.
                37 .' Versions<br>',
        ];

        $data = [];

        foreach ($teasers as $teaser) {
            /* @var $teaser Teaser */

            if ('element' === $teaser->getType()) {
                $teaserElement = $elementService->findElement($teaser->getTypeId());
                $teaserElementtype = $elementService->findElementtype($teaserElement);
                $teaserElementVersion = $elementService->findLatestElementVersion($teaserElement);

                if (!empty($filter['status'])) {
                    $status = explode(',', $filter['status']);

                    $show = false;
                    if (in_array('online', $status) && $teaserManager->isPublished($teaser, $language) && !$teaserManager->isAsync($teaser, $language)) {
                        $show = true;
                    } elseif (in_array('async', $status) && $teaserManager->isAsync($teaserElement, $language)) {
                        $show = true;
                    } elseif (in_array('offline', $status) && !$teaserManager->isPublished($teaserElement, $language)) {
                        $show = true;
                    }

                    if (!$show) {
                        continue;
                    }
                }

                $teaserOnline = $teaserManager->findOneOnlineByTeaserAndLanguage($teaser, $language);

                if (!empty($filter['date'])) {
                    $date = $filter['date'];
                    $dateFrom = !empty($filter['date_from']) ? strtotime($filter['date_from']) : '';
                    $dateTo = !empty($filter['date_to']) ? strtotime($filter['date_to']) : '';

                    $show = false;
                    if ($date === 'create') {
                        $createdAt = $teaserElementVersion->getCreatedAt();

                        if ((!$dateFrom || $createdAt > $dateFrom) && (!$dateTo || $createdAt < $dateTo)) {
                            $show = true;
                        }
                    } elseif ($date === 'publish') {
                        $publishedAt = null;
                        if ($teaserOnline) {
                            $publishedAt = $teaserOnline->getPublishedAt();
                        }

                        if ((!$dateFrom || $publishedAt > $dateFrom) && (!$dateTo || $publishedAt < $dateTo)) {
                            $show = true;
                        }
                    } elseif ($date === 'custom') {
                        $customDate = $teaserElementVersion->getCustomDate($language);

                        if ((!$dateFrom || $customDate > $dateFrom) && (!$dateTo || $customDate < $dateTo)) {
                            $show = true;
                        }
                    }

                    if (!$show) {
                        continue;
                    }
                }

                $data[] = [
                    'teaser_id' => $teaser->getId(),
                    '_type' => $teaser->getType(),
                    'eid' => $teaser->getTypeId(),
                    'title' => $teaserElementVersion->getBackendTitle($language),
                    'element_type_id' => (int) $teaserElement->getElementtypeId(),
                    'element_type' => $teaserElementtype->getTitle(),
                    'navigation' => 0,
                    'restricted' => 0,
                    'icon' => $iconResolver->resolveTeaser($teaser, $language),
                    'author' => 'author',
                    'version' => $teaserElementVersion->getVersion(),
                    'create_time' => $teaserElementVersion->getCreatedAt()->format('Y-m-d H:i:s'),
                    'publish_time' => $teaserOnline ? $teaserOnline->getPublishedAt() : '',
                    'custom_date' => $teaserElementVersion->getCustomDate($language),
                    'language' => $language,
                    'sort' => (int) $teaser->getInheritSort($treeId),
                    'version_latest' => (int) $teaserElement->getLatestVersion(),
                    'version_online' => (int) $teaserManager->getPublishedVersion($teaser, $language),
                    'status' => '>o>',
                    'qtip' => $teaserElementVersion->getBackendTitle($language).', Version '.$teaserElementVersion->getElementtypeVersion().'<br>'.
                        'Version '.$teaserElementVersion->getVersion().'<br>',
                ];
            } elseif ('inherited' === $teaser->getType()) {
                $data[] = [
                    'teaser_id' => (int) $teaser->getId(),
                    'eid' => null,
                    '_type' => $teaser->getType(),
                    'title' => 'waaa', //$teaserItem->text,
                    'element_type_id' => 0,
                    'element_type' => '',
                    'navigation' => 0,
                    'restricted' => 0,
                    'icon' => $iconResolver->resolveTeaser($teaser, $language),
                    'author' => 'author',
                    'version' => 0,
                    'create_time' => '',
                    'publish_time' => null,
                    'language' => $language,
                    'sort' => (int) $teaser->getInheritSort($treeId),
                    'version_latest' => 0,
                    'version_online' => 0,
                    'status' => '>o>',
                    'qtip' => 'waaa', //$teaserItem->text,
                ];
            }
        }

        $sorter = array();
        foreach ($data as $index => $teaser) {
            $sortValue = $teaser[$sort];
            if ($sortValue instanceof \DateTimeInterface) {
                $sortValue = $sortValue->format('c');
            }
            if (is_int($sortValue)) {
                $sortType = SORT_NUMERIC;
            } else {
                $sortType = SORT_STRING;
            }
            $sorter[] = $sortValue;
        }
        if ($dir === 'ASC') {
            array_multisort($sorter, SORT_ASC, $sortType, $data);
        } else {
            array_multisort($sorter, SORT_DESC, $sortType, $data);
        }

        //$data['totalChilds'] = $element->getChildCount();

        return new JsonResponse(
            [
                'parent' => $parent,
                'list' => $data,
            ]
        );
    }
829281
public function treeAction(Request $request)
    {
        $root = $request->attributes->get('root');

        return $this->render($this->template, [
            'root_node' => $root,
            'routing_defaults' => $this->treeConfiguration['routing_defaults'],
            'repository_name' => $this->treeConfiguration['repository_name'],
            'reorder' => $this->treeConfiguration['reorder'],
            'move' => $this->treeConfiguration['move'],
            'sortable_by' => $this->treeConfiguration['sortable_by'],
        ]);
    }
999527
public function treeAction(Request $request)
    {
        $siterootId = $request->get('siteroot_id');
        $tid = $request->get('node');
        $language = $request->get('language');

        $treeManager = $this->get('phlexible_tree.tree_manager');
        $elementService = $this->get('phlexible_element.element_service');
        $nodeSerializer = $this->get('phlexible_tree.node_serializer');

        // TODO: switch to master language of element
        $defaultLanguage = $this->container->getParameter('phlexible_cms.languages.default');

        $tree = $treeManager->getBySiteRootId($siterootId);
        $rootNode = $tree->getRoot();

        $data = [];
        if ($rootNode) {
            if ($tid === null || $tid < 1) {
                $data = [$nodeSerializer->serializeNode($rootNode, $language, $this->container->get('security.token_storage')->getToken())];
            } else {
                $node = $tree->get($tid);

                // check if children of this node should be shown
                $element = $elementService->findElement($node->getTypeId());
                $elementtype = $elementService->findElementtype($element);

                $nodes = $tree->getChildren($node);
                if (!empty($nodes) && !$elementtype->getHideChildren()) {
                    $data = $nodeSerializer->serializeNodes($nodes, $language, $this->container->get('security.token_storage')->getToken());
                }
            }
        }

        return new JsonResponse($data);
    }
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));
    }
967389
public function treeAction(Request $request = null)
    {
        $this->admin->checkAccess('tree');

        $sites = $this->get('sonata.page.manager.site')->findBy([]);
        $pageManager = $this->get('sonata.page.manager.page');

        $currentSite = null;
        $siteId = (int) $request->get('site');
        foreach ($sites as $site) {
            if ($siteId && $site->getId() === $siteId) {
                $currentSite = $site;
            } elseif (!$siteId && $site->getIsDefault()) {
                $currentSite = $site;
            }
        }
        if (!$currentSite && 1 === \count($sites)) {
            $currentSite = $sites[0];
        }

        if ($currentSite) {
            $pages = $pageManager->loadPages($currentSite);
        } else {
            $pages = [];
        }

        $datagrid = $this->admin->getDatagrid();
        $formView = $datagrid->getForm()->createView();
        $theme = $this->admin->getFilterTheme();
        $this->setFormTheme($formView, $theme);

        return $this->render($this->admin->getTemplate('tree'), [
            'action' => 'tree',
            'sites' => $sites,
            'currentSite' => $currentSite,
            'pages' => $pages,
            'form' => $formView,
            'csrf_token' => $this->getCsrfToken('sonata.batch'),
        ]);
    }
31487
public function treeAction(Request $request)
    {
        $categoryManager = $this->get('sonata.classification.manager.category');
        $currentContext = false;
        if ($context = $request->get('context')) {
            $currentContext = $this->get('sonata.classification.manager.context')->find($context);
        }

        // all root categories.
        $rootCategoriesSplitByContexts = $categoryManager->getRootCategoriesSplitByContexts(false);

        // root categories inside the current context
        $currentCategories = [];

        if (!$currentContext && !empty($rootCategoriesSplitByContexts)) {
            $currentCategories = current($rootCategoriesSplitByContexts);
            $currentContext = current($currentCategories)->getContext();
        } else {
            foreach ($rootCategoriesSplitByContexts as $contextId => $contextCategories) {
                if ($currentContext->getId() !== $contextId) {
                    continue;
                }

                foreach ($contextCategories as $category) {
                    if ($currentContext->getId() !== $category->getContext()->getId()) {
                        continue;
                    }

                    $currentCategories[] = $category;
                }
            }
        }

        $datagrid = $this->admin->getDatagrid();

        if ($this->admin->getPersistentParameter('context')) {
            $datagrid->setValue('context', null, $this->admin->getPersistentParameter('context'));
        }

        $formView = $datagrid->getForm()->createView();

        $this->setFormTheme($formView, $this->admin->getFilterTheme());

        return $this->renderWithExtraParams($this->admin->getTemplate('tree'), [
            'action' => 'tree',
            'current_categories' => $currentCategories,
            'root_categories' => $rootCategoriesSplitByContexts,
            'current_context' => $currentContext,
            'form' => $formView,
            'csrf_token' => $this->getCsrfToken('sonata.batch'),
        ]);
    }
680548
public function selectNodesLazySearch(Request $request)
    {
        @trigger_error(sprintf('The "%s" controller action is deprecated in KunstmaanNodeBundle 5.1 and will be removed in KunstmaanNodeBundle 6.0.', __METHOD__), E_USER_DEPRECATED);

        /* @var EntityManagerInterface $em */
        $em = $this->getDoctrine()->getManager();
        $locale = $request->getLocale();
        $search = $request->query->get('str');

        $results = [];
        if ($search) {
            $nts = $em->getRepository('KunstmaanNodeBundle:NodeTranslation')->getNodeTranslationsLikeTitle($search, $locale);
            /** @var NodeTranslation $nt */
            foreach ($nts as $nt) {
                $node = $nt->getNode();
                $results[] = $node->getId();
                while ($node->getParent()) {
                    $node = $node->getParent();
                    $results[] = $node->getId();
                }
            }
            $results = array_unique($results);
            sort($results);
        }

        return new JsonResponse($results);
    }
332669
public function sendResetLinkEmail(Request $request)
    {
        $this->validate($request, ['email' => 'required|email']);

        $response = Password::broker()->sendResetLink(
            $request->only('email')
        );

        if (Password::RESET_LINK_SENT) {
            return new JsonResponse(['status' => trans($response) ], 200);
        }

        return new JsonResponse(['email' => trans($response) ], 422);

    }
978101
public function searchAction(Request $request)
    {
        $queryString = $request->query->get('q');
        $index = $request->query->get('index', null);
        $locale = $request->query->get('locale', null);

        $page = $this->listRestHelper->getPage();
        $limit = $this->listRestHelper->getLimit();
        $startTime = microtime(true);

        $indexes = $index ? [$index] : $this->getAllowedIndexes();

        $query = $this->searchManager->createSearch($queryString);

        if ($locale) {
            $query->locale($locale);
        }

        $query->indexes($indexes);
        $query->setLimit($limit);

        $time = microtime(true) - $startTime;

        $adapter = new ArrayAdapter(iterator_to_array($query->execute()));
        $pager = new Pagerfanta($adapter);
        $pager->setMaxPerPage($limit);
        $pager->setCurrentPage($page);

        $representation = new SearchResultRepresentation(
            new CollectionRepresentation($pager->getCurrentPageResults(), 'result'),
            'sulu_search_search',
            [
                'locale' => $locale,
                'query' => $query,
                'index' => $index,
            ],
            (int) $page,
            (int) $limit,
            $pager->getNbPages(),
            'page',
            'limit',
            false,
            $adapter->getNbResults(),
            $this->getIndexTotals($adapter->getArray()),
            number_format($time, 8)
        );

        $view = View::create($representation);
        $context = new Context();
        $context->enableMaxDepth();
        $view->setContext($context);

        return $this->viewHandler->handle($view);
    }
850893
public function listAction(Request $request)
    {
        $start = $request->get('start', 0);
        $limit = $request->get('limit', 25);
        $sort = $request->get('sort');
        $dir = $request->get('dir');
        $tid = $request->get('tid');
        $language = $request->get('language');
        $filterValues = $request->get('filter');
        if ($filterValues) {
            $filterValues = json_decode($filterValues, true);
        } else {
            $filterValues = [];
        }

        $treeManager = $this->get('phlexible_tree.tree_manager');
        $elementService = $this->get('phlexible_element.element_service');
        $iconResolver = $this->get('phlexible_element.icon_resolver');
        $tokenStorage = $this->get('security.token_storage');
        $nodePermissionResolver = $this->get('phlexible_tree.node_permission_resolver');

        $tree = $treeManager->getByNodeID($tid);
        $node = $tree->get($tid);
        $eid = $node->getTypeId();
        $element = $elementService->findElement($eid);
        $elementMasterLanguage = $element->getMasterLanguage();
        $elementVersion = $elementService->findLatestElementVersion($element);
        $elementtype = $elementService->findElementtype($element);
        //$elementData = $element->getData(0, 'en');
        $token = $tokenStorage->getToken();

        if (!$language) {
            $language = $elementMasterLanguage;
        }

        $userRights = $nodePermissionResolver->resolve($node, $language, $token);

        if ($userRights === null) {
            throw $this->createAccessDeniedException();
        }

        $parent = [
            'tid' => (int) $tid,
            'teaser_id' => (int) 0,
            'eid' => (int) $eid,
            'title' => $elementVersion->getBackendTitle($language, $elementMasterLanguage),
            'element_type_id' => $elementtype->getId(),
            'element_type' => $elementtype->getTitle(),
            'icon' => $iconResolver->resolveTreeNode($node, $language),
            'author' => 'author',
            'version' => $elementVersion->getVersion(),
            'create_time' => $elementVersion->getCreatedAt()->format('Y-m-d H:i:s'),
            'publish_time' => $node->getTree()->getPublishedAt($node, $language) ? $node->getTree()->getPublishedAt($node, $language)->format('Y-m-d H:i:s') : null,
            'custom_date' => $elementVersion->getCustomDate($language) ? $elementVersion->getCustomDate($language)->format('Y-m-d H:i:s') : null,
            'language' => $language,
            'sort' => 0,
            'sort_mode' => $node->getSortMode(),
            'sort_dir' => $node->getSortDir(),
            'version_latest' => 1, //(int) $node->getLatestVersion(),
            'version_online' => 2, //(int) $node->getOnlineVersion($language),
            'status' => ' o_O ',
            'rights' => $userRights,
            'qtip' => $elementtype->getTitle().', Version '.$elementtype->getRevision().'<br>'.
                'Version '.$elementVersion->getVersion().'<br>'.
                37 .' Versions<br>',
        ];

        $filter = new TreeFilter(
            $this->get('doctrine.dbal.default_connection'),
            $request->getSession(),
            $this->get('event_dispatcher'),
            $node->getId(),
            $language
        );

        $filter
            ->setFilterValues($filterValues)
            ->setSortMode($sort)
            ->setSortDir($dir);

        $childIds = $filter->getIds($limit, $start);
        $cnt = $filter->getCount();

        $data = [];
        foreach ($childIds as $childId => $latestVersion) {
            $childNode = $tree->get($childId);

            $userRights = $nodePermissionResolver->resolve($childNode, $language, $token);
            if ($userRights === null) {
                continue;
            }

            $childElement = $elementService->findElement($childNode->getTypeId());
            $childElementVersion = $elementService->findLatestElementVersion($childElement);
            $childTitle = $childElementVersion->getBackendTitle($language, $childElement->getMasterLanguage());
            $childElementtype = $elementService->findElementtype($childElement);

            $data[] = [
                'tid' => (int) $childNode->getId(),
                'eid' => (int) $childElement->getEid(),
                '_type' => 'element',
                'title' => $childTitle,
                'element_type_id' => $childElementtype->getId(),
                'element_type' => $childElementtype->getTitle(),
                'navigation' => 0, //$childNode->inNavigation($childElementVersion->getVersion()),
                'restricted' => 0, //$childNode->isRestricted($childElementVersion->getVersion()),
                'icon' => $iconResolver->resolveTreeNode($childNode, $language),
                'author' => 'author',
                'version' => $childElementVersion->getVersion(),
                'create_time' => $childNode->getCreatedAt()->format('Y-m-d H:i:s'),
                // 'change_time'     => $child['modify_time'],
                'publish_time' => $childNode->getTree()->getPublishedAt($childNode, $language) ? $node->getTree()->getPublishedAt($childNode, $language)->format('Y-m-d H:i:s') : null,
                'custom_date' => $childElementVersion->getCustomDate($language) ? $childElementVersion->getCustomDate($language)->format('Y-m-d H:i:s') : null,
                'language' => $language,
                'sort' => (int) $childNode->getSort(),
                'version_latest' => 1, //(int) $childNode->getLatestVersion(),
                'version_online' => 2, //(int) $childNode->getOnlineVersion($language),
                'status' => '>o>',
                'rights' => $userRights,
                'qtip' => $childElementtype->getTitle().', '.
                    'ET Version '.$childElementtype->getRevision().'<br>'.
                    'Version '.$childElementVersion->getVersion().'<br>',
            ];
        }

        //$data['totalChilds'] = $element->getChildCount();

        return new JsonResponse([
            'parent' => $parent,
            'list' => $data,
            'total' => $cnt,
        ]);
    }
411363
public function searchInAllAction(Request $request)
    {
        /* @var $chain ChainSearch */
        $chain = $this->get('anime_db.plugin.search_fill');
        $response = $this->getResponseFromChain($chain);

        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        /* @var $form Form */
        $form = $this->createForm(new SearchFrom());
        $form->handleRequest($request);

        return $this->render('AnimeDbCatalogBundle:Fill:search_in_all.html.twig', [
            'plugins' => $chain->getPlugins(),
            'form' => $form->createView(),
        ], $response);
    }
989759
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;

        $idsString = $request->get('ids');

        if ($idsString) {
            $ids = explode(',', $idsString);
            $snippets = $this->snippetRepository->getSnippetsByUuids($ids, $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));
    }
319265
public function route($request = NULL)
    {
        $matchedResource = NULL;
        if (!$request) {
            $request = new Request();
        }
        foreach ($this->resources as $className => $resourceMetadata) {
            foreach ($resourceMetadata->getUri() as $index => $uri) {
                $uriRegex = '|^'.$uri.'$|';
                if (
                    ($matchedResource == NULL || $matchedResource[0]->getPriority() < $resourceMetadata->getPriority())
                &&
                    preg_match($uriRegex, $request->getUri(), $params)
                ) {
                    array_shift($params);
                    $uriParams = $resourceMetadata->getUriParams($index);
                    if ($uriParams) { // has params within URI
                        foreach ($uriParams as $key => $name) {
                            $params[$name] = $params[$key];
                        }
                    }
                    $matchedResource = array($resourceMetadata, $params);
                }
            }
        }
        if ($matchedResource) {
            $request->setParams($matchedResource[1]);

            return $matchedResource[0];
        } else {
            throw new NotFoundException(sprintf('Resource matching URI "%s" not found', $request->uri));
        }
    }
131738
public function searchAction(Request $request)
    {
        $response = $this->getCacheTimeKeeper()
            ->getResponse(['AnimeDbCatalogBundle:Item', 'AnimeDbCatalogBundle:Storage']);
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        /* @var $form Form */
        $form = $this->createForm('animedb_catalog_search', new SearchEntity())->handleRequest($request);
        $pagination = null;
        $result = ['list' => [], 'total' => 0];

        if ($form->isValid()) {
            /* @var $controls ListControls */
            $controls = $this->get('anime_db.item.list_controls');

            // current page for paging
            $current_page = $request->get('page', 1);
            $current_page = $current_page > 1 ? $current_page : 1;

            // get items limit
            $limit = $controls->getLimit($request->query->all());

            // do search
            $result = $this->get('anime_db.item.search')->search(
                $form->getData(),
                $limit,
                ($current_page - 1) * $limit,
                $controls->getSortColumn($request->query->all()),
                $controls->getSortDirection($request->query->all())
            );

            if ($limit) {
                // build pagination
                $that = $this;
                $query = $request->query->all();
                unset($query['page']);
                $pagination = $this->get('anime_db.pagination')
                    ->create(ceil($result['total'] / $limit), $current_page)
                    ->setPageLink(function ($page) use ($that, $query) {
                        return $that->generateUrl('home_search', array_merge($query, ['page' => $page]));
                    })
                    ->setFirstPageLink($this->generateUrl('home_search', $query))
                    ->getView();
            }
        }

        return $this->render('AnimeDbCatalogBundle:Home:search.html.twig', [
            'form' => $form->createView(),
            'items' => $result['list'],
            'total' => $result['total'],
            'pagination' => $pagination,
            'searched' => (bool) $request->query->count(),
        ], $response);
    }
1327216
protected static function activeNodes(Request $request, array $nodes = [], $level = 0) {

        $result = false;

        foreach ($nodes as $n) {

            if (false === ($n instanceof AbstractNavigationNode)) {
                continue;
            }

            if (true === self::nodeMatch($n, $request)) {
                $current = true;
            } else {
                $current = self::activeNodes($request, $n->getNodes(), $level + 1);
            }

            if (false === $current) {
                continue;
            }

            $n->setActive(true);

            $result = true;
        }

        return $result;
    }
1015061
public function cgetAction(Request $request)
    {
        $view = null;
        if ('true' == $request->get('flat')) {
            /** @var RestHelperInterface $restHelper */
            $restHelper = $this->get('sulu_core.doctrine_rest_helper');

            /** @var DoctrineListBuilderFactory $factory */
            $factory = $this->get('sulu_core.doctrine_list_builder_factory');

            $listBuilder = $factory->create($this->container->getParameter('sulu.model.user.class'));

            $restHelper->initializeListBuilder($listBuilder, $this->getFieldDescriptors());

            $list = new ListRepresentation(
                $listBuilder->execute(),
                static::$entityKey,
                'get_users',
                $request->query->all(),
                $listBuilder->getCurrentPage(),
                $listBuilder->getLimit(),
                $listBuilder->count()
            );
        } else {
            $contactId = $request->get('contactId');

            if (null != $contactId) {
                $user = $this->getDoctrine()->getRepository(
                    $this->container->getParameter('sulu.model.user.class')
                )->findUserByContact($contactId);

                $view = $this->view($user ?? new \stdClass(), 200);
            } else {
                $entities = $this->getUserManager()->findAll();
                $list = new CollectionRepresentation($entities, static::$entityKey);
            }
        }

        if (!$view) {
            $view = $this->view($list, 200);
        }

        $this->addSerializationGroups($view);

        return $this->handleView($view);
    }