@param Request $request
@return Response

@Route("/servico_info", name="novosga_triage_servico_info", methods={"GET"})
341446
public function servicoInfo(Request $request, TranslatorInterface $translator)
    {
        $em       = $this->getDoctrine()->getManager();
        $id       = (int) $request->get('id');
        $usuario  = $this->getUser();
        $unidade  = $usuario->getLotacao()->getUnidade();
        $servico  = $em->find(Servico::class, $id);
        $envelope = new Envelope();
        
        if (!$servico) {
            throw new Exception($translator->trans('error.invalid_service', [], self::DOMAIN));
        }
        
        $data = [
            'nome' => $servico->getNome(),
            'descricao' => $servico->getDescricao()
        ];

        // ultima senha
        $atendimento = $em->getRepository(Atendimento::class)->getUltimo($unidade, $servico);
        
        if ($atendimento) {
            $data['senha']   = $atendimento->getSenha()->__toString();
            $data['senhaId'] = $atendimento->getId();
        } else {
            $data['senha']   = '-';
            $data['senhaId'] = '';
        }
        
        // subservicos
        $data['subservicos'] = [];
        $subservicos = $em->getRepository(Servico::class)->getSubservicos($servico);

        foreach ($subservicos as $s) {
            $data['subservicos'][] = $s->getNome();
        }

        $envelope->setData($data);

        return $this->json($envelope);
    }
164768
public function handle(Request $request)
	{
		$response = $this->next($request);

		$class = $this->app->get('arguments')->get('class');
		$task  = $this->app->get('arguments')->get('task');

		$command   = new $class($this->app->get('output'), $this->app->get('arguments'));
		$shortName = strtolower(with(new \ReflectionClass($command))->getShortName());

		// Fire default before event
		Event::fire($shortName . '.' . 'before' . ucfirst($task));

		$command->{$task}();

		// Fire default after event
		Event::fire($shortName . '.' . 'after' . ucfirst($task));

		$this->app->get('output')->render();

		return $response;
	}
144952
public function updateAction(Request $request): Response
    {
        $form = $this->formFactory->updateLocation();
        $form->handleRequest($request);

        $location = $form->getData()->getLocation();

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (LocationUpdateData $data) {
                $location = $data->getLocation();

                $locationUpdateStruct = new LocationUpdateStruct(['sortField' => $data->getSortField(), 'sortOrder' => $data->getSortOrder()]);
                $this->locationService->updateLocation($location, $locationUpdateStruct);

                $this->notificationHandler->success(
                    $this->translator->trans(
                        /** @Desc("Location '%name%' updated.") */
                        'location.update.success',
                        ['%name%' => $location->getContentInfo()->name],
                        'location'
                    )
                );

                return new RedirectResponse($this->generateUrl('_ezpublishLocation', [
                        'locationId' => $location->getContentInfo()->mainLocationId,
                        '_fragment' => DetailsTab::URI_FRAGMENT,
                    ]));
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->redirect($this->generateUrl('_ezpublishLocation', [
            'locationId' => $location->getContentInfo()->mainLocationId,
            '_fragment' => DetailsTab::URI_FRAGMENT,
        ]));
    }
488416
public function search(Request $request)
    {
        $images = $this->imageRepository->search($request->term);

        if($request->ajax()) return response()->json([
            'images' => view('laramanager::browser.images', compact('images'))->render()
        ]);

        return view('laramanager::images.index', compact('images'));
    }
242182
public function indexAction(Request $request)
    {
        $paginator = $this->get('opifer.content.content_manager')
            ->getPaginatedByRequest($request);

        $contents = $paginator->getCurrentPageResults();

        $contents = $this->get('jms_serializer')->serialize(iterator_to_array($contents), 'json', SerializationContext::create()->setGroups(['list'])->enableMaxDepthChecks());

        $data = [
            'results'       => json_decode($contents, true),
            'total_results' => $paginator->getNbResults()
        ];

        return new JsonResponse($data);
    }
784053
public function index(
        Request $request,
        ServicoService $servicoService,
        SecurityService $securityService,
        UsuarioService $usuarioService,
        TranslatorInterface $translator
    ) {
        $em = $this->getDoctrine()->getManager();
        
        $usuario = $this->getUser();
        $unidade = $usuario->getLotacao()->getUnidade();
        
        // locais disponiveis
        $locais = $em
            ->getRepository(Local::class)
            ->findBy([], ['nome' => 'ASC']);

        // usuarios da unidade
        $usuarios = $em
            ->getRepository(Usuario::class)
            ->findByUnidade($unidade);
        
        $servicosUnidade = $servicoService->servicosUnidade($unidade);
        
        $usuariosArray = array_map(function (Usuario $usuario) use (
            $em,
            $unidade,
            $servicosUnidade,
            $usuarioService
        ) {
            $servicosUsuario = $em
                ->getRepository(ServicoUsuario::class)
                ->getAll($usuario, $unidade);
            
            $data  = $usuario->jsonSerialize();
            $data['servicos'] = [];
                    
            foreach ($servicosUnidade as $servicoUnidade) {
                foreach ($servicosUsuario as $servicoUsuario) {
                    $idA = $servicoUsuario->getServico()->getId();
                    $idB = $servicoUnidade->getServico()->getId();
                    
                    if ($idA === $idB) {
                        $data['servicos'][] = [
                            'id'    => $servicoUnidade->getServico()->getId(),
                            'sigla' => $servicoUnidade->getSigla(),
                            'nome'  => $servicoUnidade->getServico()->getNome(),
                            'peso'  => $servicoUsuario->getPeso(),
                        ];
                    }
                }
            }
            
            $tipoMeta                = $usuarioService->meta($usuario, UsuarioService::ATTR_ATENDIMENTO_TIPO);
            $data['tipoAtendimento'] = $tipoMeta ? $tipoMeta->getValue() : FilaService::TIPO_TODOS;
            
            $numeroMeta      = $usuarioService->meta($usuario, UsuarioService::ATTR_ATENDIMENTO_LOCAL);
            $data['numero']  = $numeroMeta ? (int) $numeroMeta->getValue() : null;
            
            return $data;
        }, $usuarios);
        
        $tiposAtendimento = $this->getTiposAtendimento($translator);
        
        $form          = $this->createForm(ServicoUnidadeType::class);
        $inlineForm    = $this->createForm(ServicoUnidadeType::class);
        $impressaoForm = $this->createForm(ImpressaoType::class, $unidade->getImpressao());

        return $this->render('@NovosgaSettings/default/index.html.twig', [
            'usuario'          => $usuario,
            'unidade'          => $unidade,
            'locais'           => $locais,
            'usuarios'         => $usuariosArray,
            'tiposAtendimento' => $tiposAtendimento,
            'form'             => $form->createView(),
            'inlineForm'       => $inlineForm->createView(),
            'impressaoForm'    => $impressaoForm->createView(),
            'wsSecret'         => $securityService->getWebsocketSecret(),
        ]);
    }
755969
private function getParametersFromRequest(Request $request)
    {
        $parameters = $request->query->all();
        if ($routeParameters = $request->attributes->get('_route_params')) {
            $parameters = array_merge($routeParameters, $parameters);
        }

        return $parameters;
    }
778712
public function listAction(Request $request)
    {
        $type = $request->get('type', Elementtype::TYPE_FULL);

        $elementtypeService = $this->get('phlexible_elementtype.elementtype_service');

        $elementtypes = [];
        foreach ($elementtypeService->findAllElementtypes() as $elementtype) {
            if ($type !== $elementtype->getType()) {
                continue;
            }

            if ($elementtype->getDeleted()) {
                continue;
            }

            $elementtypes[$elementtype->getTitle().$elementtype->getId()] = [
                'id' => $elementtype->getId(),
                'title' => $elementtype->getTitle(),
                'icon' => $elementtype->getIcon(),
                'version' => $elementtype->getRevision(),
                'type' => $elementtype->getType(),
            ];
        }

        ksort($elementtypes);
        $elementtypes = array_values($elementtypes);

        $checker = $this->get('phlexible_element.checker');
        $changes = $checker->check();
        $hasChanges = false;
        foreach ($changes as $change) {
            if ($change->getNeedImport()) {
                $hasChanges = true;
                break;
            }
        }

        return new JsonResponse([
            'elementtypes' => $elementtypes,
            'total' => count($elementtypes),
            'changes' => $hasChanges,
        ]);
    }
364037
protected function getCallbackFromRequest(Request $request)
    {
        $response = new JsonResponse('');
        $response->setCallback($request->query->get(self::PARAMETER_CALLBACK));

        return $response->getCallback();
    }
342103
public function indexAction(Request $request)
    {
        $manager = $this->get('compo_faq.manager.faq');

        $page = $request->get('page', 1);

        $pager = $manager->getPager([], $page);
        $totalPages = $pager->getPageCount();

        $seoPage = $this->get('sonata.seo.page');
        $seoPage->setContext('faq_list');
        $seoPage->addVar('page', $page);
        $seoPage->addVar('total_pages', $pager->getPageCount());

        if (1 !== $page) {
            $seoPage->setLinkCanonical($manager->getFaqIndexPermalink(['page' => $page], 0));
            $metas = $seoPage->getMetas();
            $metas['name']['robots'] = 'noindex, follow';
            $seoPage->setMetas($metas);
        } else {
            $seoPage->setLinkCanonical($manager->getFaqIndexPermalink([], 0));
        }

        if ($totalPages > 1 && $page < $totalPages) {
            $seoPage->setLinkNext($manager->getFaqIndexPermalink(['page' => $page + 1], 0));
        }

        if ($totalPages > 1 && $page > 1) {
            $seoPage->setLinkPrev($manager->getFaqIndexPermalink(['page' => $page - 1], 0));
        }

        $seoPage->build();

        return $this->render(
            'CompoFaqBundle:Faq:index.html.twig',
            [
                'pager' => $pager,
            ]
        );
    }
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));
    }
1095575
public function indexAction(Request $request)
    {

        // For Mailchimp ping GET
        if ($request->isMethod('GET')) {
            return new JsonResponse([
                'success' => true,
                'ping' => 'pong',
            ]);
        }

        // Handle POST request of Mailchimp
        $type = $request->request->get('type');
        $data = $request->request->get('data');
        /* Response example:
            data[merges][FNAME]: Tztz
            data[merges][EMAIL]: tztz@gmail.com
            data[email_type]: html
            data[reason]: manual
            data[email]: tztz@gmail.com
            data[id]: 5c1b5a7c1e
            data[merges][LNAME]: TZST
            data[list_id]: ba039c6198
            data[web_id]: 3375995
        */
        $hooksecret = $request->query->get('hooksecret');

        if (empty($type) || empty($data) || empty($hooksecret) || !array_key_exists('list_id', $data)) {
            throw new AccessDeniedHttpException('incorrect data format!');
        }

        $listId = $data['list_id'];

        $listProviderKey = $this->getParameter('welp_mailchimp.list_provider');
        try {
            $listProvider = $this->get($listProviderKey); 
        } catch (ServiceNotFoundException $e) {
            throw new \InvalidArgumentException(sprintf('List Provider "%s" should be defined as a service.', $listProviderKey), $e->getCode(), $e);
        }

        if (!$listProvider instanceof ListProviderInterface) {
            throw new \InvalidArgumentException(sprintf('List Provider "%s" should implement Welp\MailchimpBundle\Provider\ListProviderInterface.', $listProviderKey));
        }

        $list = $listProvider->getList($listId);

        // Check the webhook_secret
        $authorized = false;
        if($list != null && $list->getWebhookSecret() == $hooksecret) {
            $authorized = true;                           
        }

        if (!$authorized) {
            throw new AccessDeniedHttpException('Webhook secret mismatch!');
        }

        // Trigger the right event
        switch ($type) {
            case 'subscribe':
                $dispatcher = $this->get('event_dispatcher');
                $dispatcher->dispatch(WebhookEvent::EVENT_SUBSCRIBE, new WebhookEvent($data));
                break;
            case 'unsubscribe':
                $dispatcher = $this->get('event_dispatcher');
                $dispatcher->dispatch(WebhookEvent::EVENT_UNSUBSCRIBE, new WebhookEvent($data));
                break;
            case 'profile':
                $dispatcher = $this->get('event_dispatcher');
                $dispatcher->dispatch(WebhookEvent::EVENT_PROFILE, new WebhookEvent($data));
                break;
            case 'cleaned':
                $dispatcher = $this->get('event_dispatcher');
                $dispatcher->dispatch(WebhookEvent::EVENT_CLEANED, new WebhookEvent($data));
                break;
            case 'upemail':
                $dispatcher = $this->get('event_dispatcher');
                $dispatcher->dispatch(WebhookEvent::EVENT_UPEMAIL, new WebhookEvent($data));
                break;
            case 'campaign':
                $dispatcher = $this->get('event_dispatcher');
                $dispatcher->dispatch(WebhookEvent::EVENT_CAMPAIGN, new WebhookEvent($data));
                break;
            default:
                throw new AccessDeniedHttpException('type mismatch!');
                break;
        }

        return new JsonResponse([
            'type' => $type,
            'data' => $data,
        ]);
    }
918145
public function execute(Request $request): Response
    {
        $method = $request->getMethod();
        list($resp, $grpcStatus) = $request->getClient()->$method(
            $request->getMessage(),
            $request->getMetadata(),
            $request->getOptions()
        )->wait();

        $headers = new HeaderCollection();

        if (is_null($grpcStatus)) { // in the very bad case even this fails to return
            $status = new Error\Status(\Grpc\STATUS_UNKNOWN, '', $headers);
        } else {
            $metadata = $grpcStatus->metadata;
            foreach ($metadata as $k => $v) {
                if (is_array($v)) {
                    foreach ($v as $v2) {
                        $headers->add($k, $v2);
                    }
                } else {
                    $headers->add($k, $v);
                }
            }
            $status = new Error\Status(intval($grpcStatus->code), strval($grpcStatus->details), $headers);
        }

        if (is_null($resp)) {
            $request->fail($status);
        }

        return $request->succeed($resp, $status);
    }
347723
public function allAction(Request $request)
    {
        $model = $this->getModel();

        $content = $this->restUtils->serialize($model->findAll($request));

        $response = $this->getResponse()
            ->setStatusCode(Response::HTTP_OK)
            ->setContent($content);

        return $response;
    }
1357385
private function getRoute(Request $request)
    {
        $route = $request->attributes->get('_route');

        return empty($route) ? self::UNDEFINED_ROUTE : $route;
    }
287972
public function cgetAction(Request $request)
    {
        $locale = $this->getRequestParameter($request, 'locale', true);

        $restHelper = $this->get('sulu_core.list_rest_helper');

        /** @var Manager $manager */
        $manager = $this->get('es.manager.default');
        $repository = $manager->getRepository($this->get('sulu_article.view_document.factory')->getClass('article'));
        $search = $repository->createSearch();

        $limit = (int) $restHelper->getLimit();
        $page = (int) $restHelper->getPage();

        if (null !== $locale) {
            $search->addQuery(new TermQuery('locale', $locale));
        }

        if (count($ids = array_filter(explode(',', $request->get('ids', ''))))) {
            $search->addQuery(new IdsQuery($this->getViewDocumentIds($ids, $locale)));
            $limit = count($ids);
        }

        if (!empty($searchPattern = $restHelper->getSearchPattern())
            && 0 < count($searchFields = $restHelper->getSearchFields())
        ) {
            $boolQuery = new BoolQuery();
            foreach ($searchFields as $searchField) {
                $boolQuery->add(new MatchPhrasePrefixQuery($searchField, $searchPattern), BoolQuery::SHOULD);
            }
            $search->addQuery($boolQuery);
        }

        if (null !== ($type = $request->get('type'))) {
            $search->addQuery(new TermQuery('type', $type));
        }

        if ($contactId = $request->get('contactId')) {
            $boolQuery = new BoolQuery();
            $boolQuery->add(new MatchQuery('changer_contact_id', $contactId), BoolQuery::SHOULD);
            $boolQuery->add(new MatchQuery('creator_contact_id', $contactId), BoolQuery::SHOULD);
            $boolQuery->add(new MatchQuery('author_id', $contactId), BoolQuery::SHOULD);
            $search->addQuery($boolQuery);
        }

        if ($categoryId = $request->get('categoryId')) {
            $search->addQuery(new TermQuery('excerpt.categories.id', $categoryId), BoolQuery::MUST);
        }

        if ($tagId = $request->get('tagId')) {
            $search->addQuery(new TermQuery('excerpt.tags.id', $tagId), BoolQuery::MUST);
        }

        if ($pageId = $request->get('pageId')) {
            $search->addQuery(new TermQuery('parent_page_uuid', $pageId), BoolQuery::MUST);
        }

        if ($workflowStage = $request->get('workflowStage')) {
            $search->addQuery(new TermQuery('published_state', 'published' === $workflowStage), BoolQuery::MUST);
        }

        if ($this->getBooleanRequestParameter($request, 'exclude-shadows', false, false)) {
            $search->addQuery(new TermQuery('localization_state.state', 'shadow'), BoolQuery::MUST_NOT);
        }

        if ($this->getBooleanRequestParameter($request, 'exclude-ghosts', false, false)) {
            $search->addQuery(new TermQuery('localization_state.state', 'ghost'), BoolQuery::MUST_NOT);
        }

        $authoredFrom = $request->get('authoredFrom');
        $authoredTo = $request->get('authoredTo');
        if ($authoredFrom || $authoredTo) {
            $search->addQuery($this->getRangeQuery('authored', $authoredFrom, $authoredTo), BoolQuery::MUST);
        }

        if (null === $search->getQueries()) {
            $search->addQuery(new MatchAllQuery());
        }

        if (null !== $restHelper->getSortColumn() &&
            $sortField = $this->getSortFieldName($restHelper->getSortColumn())
        ) {
            $search->addSort(
                new FieldSort($sortField, $restHelper->getSortOrder())
            );
        }

        $fieldDescriptors = $this->getFieldDescriptors();

        if ($limit) {
            $search->setSize($limit);
            $search->setFrom(($page - 1) * $limit);

            $fields = array_merge(
                $restHelper->getFields() ?: [],
                ['id', 'localizationState', 'publishedState', 'published']
            );
            $fieldDescriptors = array_filter(
                $fieldDescriptors,
                function (FieldDescriptorInterface $fieldDescriptor) use ($fields) {
                    return in_array($fieldDescriptor->getName(), $fields);
                }
            );
        } else {
            $search->setSize(1000);
            $search->setScroll('1m');
        }

        $searchResult = $repository->findRaw($search);
        $result = [];
        foreach ($searchResult as $document) {
            $documentData = $this->normalize($document['_source'], $fieldDescriptors);
            if (false !== ($index = array_search($documentData['id'], $ids))) {
                $result[$index] = $documentData;
            } else {
                $result[] = $documentData;
            }
        }

        if (count($ids)) {
            ksort($result);
            $result = array_values($result);
        }

        $count = $searchResult->count();

        return $this->handleView(
            $this->view(
                new ListRepresentation(
                    $result,
                    'articles',
                    'get_articles',
                    $request->query->all(),
                    $page,
                    $limit,
                    $count
                )
            )
        );
    }
595788
public function listAction(Request $request)
    {
        list($transUnits, $count) = $this->get('lexik_translation.data_grid.request_handler')->getPage($request);

        return $this->get('lexik_translation.data_grid.formatter')->createListResponse($transUnits, $count);
    }