@param Request $request
@return Response

@Route("/servicos_unidade", name="novosga_settings_servicos_unidade", methods={"GET"})
164130
public function servicosUnidade(Request $request, ServicoService $servicoService)
    {
        $usuario  = $this->getUser();
        $unidade  = $usuario->getLotacao()->getUnidade();
        $servicos = $servicoService->servicosUnidade($unidade);
        
        $envelope = new Envelope();
        $envelope->setData($servicos);
        
        return $this->json($envelope);
    }
533360
public function transferir(
        Request $request,
        AtendimentoService $atendimentoService,
        ServicoService $servicoService,
        Atendimento $atendimento,
        TranslatorInterface $translator
    ) {
        $envelope = new Envelope();
        
        $usuario = $this->getUser();
        $unidade = $usuario->getLotacao()->getUnidade();

        $this->checkAtendimento($unidade, $atendimento, $translator);

        $data = json_decode($request->getContent(), true);

        $transferirForm = $this->createTransferirForm($request, $servicoService);
        $transferirForm->submit($data);

        if (!$transferirForm->isValid()) {
            throw new Exception($translator->trans('error.invalid_form', [], self::DOMAIN));
        }
        
        $servicoUnidade = $transferirForm->get('servico')->getData();
        $prioridade     = $transferirForm->get('prioridade')->getData();

        $atendimentoService->transferir(
            $atendimento,
            $unidade,
            $servicoUnidade->getServico(),
            $prioridade
        );

        return $this->json($envelope);
    }
1057796
protected function getUserFromRequest(Request $request)
    {
        $username = $request->get('username');

        return $this->userService->findByEmail($username);
    }
187213
public function limparDados(Request $request, AtendimentoService $atendimentoService)
    {
        $usuario = $this->getUser();
        $unidade = $usuario->getLotacao()->getUnidade();
        
        $atendimentoService->limparDados($unidade);
        
        $envelope = new Envelope();
        $envelope->setData(true);

        return $this->json($envelope);
    }
471141
public function patchSettingsAction(Request $request)
    {
        $settings = $request->request->all();

        try {
            $user = $this->tokenStorage->getToken()->getUser();

            foreach ($settings as $settingKey => $settingValue) {
                // get setting
                // TODO: move this logic into own service (UserSettingManager?)
                $setting = $this->userSettingRepository->findOneBy(['user' => $user, 'key' => $settingKey]);

                // or create new one
                if (!$setting) {
                    $setting = new UserSetting();
                    $setting->setKey($settingKey);
                    $setting->setUser($user);
                    $this->objectManager->persist($setting);
                }

                // persist setting
                $setting->setValue(json_encode($settingValue));
            }
            $this->objectManager->flush();

            //create view
            $view = View::create($settings, 200);
        } catch (RestException $exc) {
            $view = View::create($exc->toArray(), 400);
        }

        return $this->viewHandler->handle($view);
    }
1331174
public function run(Request $request) {
		$page = $this->getServiceContainer()->getKernel()->getApplication()->getPage();
		$page->setTitle($this->getServiceContainer()->getTranslator()->trans('change_password'));

		$payload = new Blank();
		if ($request->isMethod('POST')) {
			$post = $request->request;
			$auth = $this->getServiceContainer()->getAuthManager();
			$user = $auth->getUser();
			$payload = new Failed();

			if ($post->has('password') && $auth->verifyUser($user, $post->get('password'))) {
				$pwA = $post->get('new_password');
				$pwB = $post->get('new_password_confirm');

				if ($pwA == $pwB) {
					$user->setPassword($auth->encryptPassword($pwA));
					$user->save();
					$payload = new Success();
				}
			}
		}

		return $this->responder->run($request, $payload);
	}
70978
public function index(Request $request)
    {
        $routePermissions = RoutePermission::browse([
            'order'     => [ Input::get('sort', 'id') => Input::get('direction', 'desc') ],
            'limit'     => ($limit = (int)Input::get('limit', 25)),
            'offset'    => (Input::get('page', 1) - 1) * $limit,
            'filters'   => $request->all()
        ]);

        return response()->json(arrayView('phpsoft.users::routePermission/browse', [
            'routePermissions' => $routePermissions,
        ]), 200);
    }
652358
public function run(Request $request) {
		$login = '';
		$error = '';
		$redirect = $request->headers->get('referer');
		$prefs = $this->getServiceContainer()->getPreferenceLoader()->getSystemPreferences();

		// try login
		if ($request->isMethod('POST')) {
			$login = $request->request->get('login');
			$password = $request->request->get('password');
			$redirect = rawurldecode($request->request->get('redirect'));

			$auth = $this->getServiceContainer()->getAuthManager();
			if ($auth->login($login, $password)) {
				$token = $auth->getSession()->getToken();
				$foward = $redirect ?: $prefs->getAccountUrl();
				$response = new RedirectResponse($foward);
				$this->getServiceContainer()->getKernel()->setCookie($response, AuthManager::COOKIE_TOKEN_NAME, $token);
				return $response;
			}

			$error = 'Invalid credentials';
		}

		$translator = $this->getServiceContainer()->getTranslator();
		$module = $this->getModule();
		$form = $module->getWidgetFactory()->createLoginWidget();
		$form = $form->build([
			'error' => $error,
			'destination' => $prefs->getAccountUrl() . '/' . $translator->trans('slug.login'),
			'redirect' => $redirect,
			'login' => $login
		]);

		return $this->responder->run($request, new Blank([
			'form' => $form
		]));
	}
833663
public function search(Request $request): Response
    {
        $configResolver = $this->getConfigResolver();
        $queryType = $this->getQueryTypeRegistry()->getQueryType('NetgenSite:Search');

        $searchText = trim($request->query->get('searchText', ''));

        if (empty($searchText)) {
            return $this->render(
                $configResolver->getParameter('template.search', 'ngsite'),
                [
                    'search_text' => '',
                    'pager' => null,
                ]
            );
        }

        $pager = new Pagerfanta(
            new FindAdapter(
                $queryType->getQuery(['search_text' => $searchText]),
                $this->getSite()->getFindService()
            )
        );

        $pager->setNormalizeOutOfRangePages(true);
        $pager->setMaxPerPage((int) $configResolver->getParameter('search.default_limit', 'ngsite'));

        $currentPage = $request->query->getInt('page', 1);
        $pager->setCurrentPage($currentPage > 0 ? $currentPage : 1);

        return $this->render(
            $configResolver->getParameter('template.search', 'ngsite'),
            [
                'search_text' => $searchText,
                'pager' => $pager,
            ]
        );
    }
785689
public function settings(Request $request)
    {
        $this->authorize('update', Settings::class);

        $settings = Settings::first();

        $settings->update([
            'mail_enabled' => $request->mail_enabled ? true : false,
        ]);

        $settings->touch();

        return redirect()->route('laralum::settings.index', ['p' => 'Notifications'])->with('success', __('laralum_notifications::general.settings_updated'));
    }
547839
public function cgetAction(Request $request)
    {
        try {
            /** @var ListRestHelperInterface $listRestHelper */
            $listRestHelper = $this->get('sulu_core.list_rest_helper');
            $securityChecker = $this->get('sulu_security.security_checker');

            $flat = $this->getBooleanRequestParameter($request, 'flat', false);
            $depth = $request->get('depth', 0);
            $parentId = $request->get('parentId', null);
            $limit = $request->get('limit', null);
            $offset = $this->getOffset($request, $limit);
            $search = $listRestHelper->getSearchPattern();
            $sortBy = $request->get('sortBy');
            $sortOrder = $request->get('sortOrder', 'ASC');
            $includeRoot = $this->getBooleanRequestParameter($request, 'includeRoot', false, false);
            $collectionManager = $this->getCollectionManager();

            if ('root' === $parentId) {
                $includeRoot = false;
                $parentId = null;
            }

            if ($flat) {
                $collections = $collectionManager->get(
                    $this->getRequestParameter($request, 'locale', true),
                    [
                        'depth' => $depth,
                        'parent' => $parentId,
                    ],
                    $limit,
                    $offset,
                    null !== $sortBy ? [$sortBy => $sortOrder] : []
                );
            } else {
                $collections = $collectionManager->getTree(
                    $this->getRequestParameter($request, 'locale', true),
                    $offset,
                    $limit,
                    $search,
                    $depth,
                    null !== $sortBy ? [$sortBy => $sortOrder] : [],
                    $securityChecker->hasPermission('sulu.media.system_collections', 'view')
                );
            }

            if ($includeRoot && !$parentId) {
                $collections = [
                    new RootCollection(
                        $this->get('translator')->trans('sulu_media.all_collections', [], 'admin'),
                        $collections
                    ),
                ];
            }

            $all = $collectionManager->getCount();

            $list = new ListRepresentation(
                $collections,
                self::$entityKey,
                'get_collections',
                $request->query->all(),
                $listRestHelper->getPage(),
                $listRestHelper->getLimit(),
                $all
            );

            $view = $this->view($list, 200);
        } catch (CollectionNotFoundException $cnf) {
            $view = $this->view($cnf->toArray(), 404);
        } catch (MediaException $me) {
            $view = $this->view($me->toArray(), 400);
        }

        return $this->handleView($view);
    }
358673
public function redirecionar(
        Request $request,
        AtendimentoService $atendimentoService,
        TranslatorInterface $translator
    ) {
        $envelope = new Envelope();
        $data     = json_decode($request->getContent());

        $usuario     = $this->getUser();
        $unidade     = $usuario->getLotacao()->getUnidade();
        $servico     = (int) $data->servico;
        $novoUsuario = null;
        $atual       = $atendimentoService->atendimentoAndamento($usuario->getId(), $unidade);

        if (!$atual) {
            throw new Exception(
                $translator->trans('error.attendance.not_in_process', [], self::DOMAIN)
            );
        }
        
        if (isset($data->usuario)) {
            $novoUsuario = $this
                ->getDoctrine()
                ->getManager()
                ->getRepository(Usuario::class)
                ->find($data->usuario);
        }

        $redirecionado = $atendimentoService->redirecionar($atual, $unidade, $servico, $novoUsuario);
        if (!$redirecionado->getId()) {
            throw new Exception(
                $translator->trans(
                    'error.attendance.redirect',
                    [
                        '%atendimento%' => $atual->getId(),
                        '%servico%'     => $servico,
                    ],
                    self::DOMAIN
                )
            );
        }

        return $this->json($envelope);
    }
882230
public function httpPost(Request $request) : Response
    {
        $response = new Response();
        $response->headers->set('Content-Type', 'application/json');

        $response->setContent(
            $this->sdkEndpoint->index(
                $request->getContent()
            )
        );

        return $response;
    }
265971
public function render(?Request $request = null): Response {
        $request = self::validateRequest($request);

        $translator = $this->translatorProvider->getPreferredTranslator(
            $request->getLanguages(),
            $this->config['default_language']
        );

        $response = new Response();

        $response->setContent($this->templateRenderer->render(
            $this->config['template_name'],
            array_merge($translator->getTranslations(), [
                'lang' => $translator->getLanguage(),
                'charset' => $this->config['charset']
            ])
        )."\n<!-- Powered by progminer/maintenance-screen (https://packagist.org/packages/progminer/maintenance-screen) -->\n");
        $response->headers->set('Content-Language', $translator->translate('lang'));

        return $response;
    }
1096981
public function index(Request $request)
    {
        $keyword = $request->get('search');
        $perPage = 25;

        if (!empty($keyword)) {
            $settings = Setting::where('key', 'LIKE', "%$keyword%")
                ->orWhere('value', 'LIKE', "%$keyword%")
                ->orderBy('key')->paginate($perPage);
        } else {
            $settings = Setting::orderBy('key')->paginate($perPage);
        }

        return view('admin.settings.index', compact('settings'));
    }
155726
public function settingsAction(Request $request)
    {
        /** @var Theme $theme */
        $theme = $this->getDoctrine()
            ->getRepository('CampaignChainCoreBundle:Theme')
            ->find(1);

        $form = $this->createForm(ThemeType::class, $theme);

        $form->handleRequest($request);

        if ($form->isValid()) {
            /** @var FileUploadService $fileUploadService */
            $fileUploadService = $this->get('campaignchain.core.service.file_upload');

            $path = Theme::STORAGE_PATH.'/logo.png';
            /** @var UploadedFile $upload */
            $upload = $theme->getLogo();
            if($upload) {
                $uploadContent = file_get_contents($upload->getRealPath());
                $fileUploadService->deleteFile($path);
                $fileUploadService->storeImage($path, $uploadContent);
            }
            $theme->setLogo($path);

            $path = Theme::STORAGE_PATH.'/favicon.ico';
            /** @var UploadedFile $upload */
            $upload = $theme->getFavicon();
            if($upload) {
                $uploadContent = file_get_contents($upload->getRealPath());
                $fileUploadService->deleteFile($path);
                $fileUploadService->storeImage($path, $uploadContent);
            }
            $theme->setFavicon($path);

            $this->getDoctrine()->getManager()->flush();

            $this->addFlash(
                'success',
                'The theme settings were successfully changed!'
            );
        }

        return $this->render('CampaignChainCoreBundle:Base:new.html.twig', array(
            'form' => $form->createView(),
            'page_title' => 'Theme Settings',
        ));
    }
1162215
public function optionsAction(Request $request)
    {
        $response = $this->response;
        $response->setStatusCode(Response::HTTP_NO_CONTENT);
        $request->attributes->set('corsMethods', 'GET, OPTIONS');

        return $response;
    }