version 1
@param Request $request
@return float
@throws \Makotokw\Twient\Exception
181639
private function getVersion($request)
    {
        $version = $request->getParameter("oauth_version");
        if (!$version) {
            $version = 1.0;
        }
        if ($version && $version != $this->version) {
            throw new Exception("OAuth version '$version' not supported");
        }
        return $version;
    }
730013
protected function getTimestampFromRequest(Request $request): int
    {
        if (!$request->hasHeader(self::HEADER_AUTHENTICATE_TIMESTAMP)) {
            throw new UnauthorizedException('Timestamp is required.');
        }

        $timestamp = current($request->getHeader(self::HEADER_AUTHENTICATE_TIMESTAMP));

        if (!is_numeric($timestamp)) {
            throw new UnauthorizedException('Timestamp must be an integer.');
        }

        return (int)$timestamp;
    }
360871
public function indexAction(Request $request)
    {
        $response = $this->getCacheTimeKeeper()->getResponse();
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        // update for Windows XP does not work
        $can_update = strpos(php_uname('v'), 'Windows XP') === false;

        $plugin = $request->request->get('plugin');
        $action = $this->getAction($plugin);

        // delete or install package
        switch ($action) {
            case 'delete':
                $this->get('anime_db.manipulator.composer')->removePackage($plugin['delete']);
                $plugin = $this->getPlugin('plugin/'.$plugin['delete'].'/');
                break;
            case 'install':
                $this->get('anime_db.manipulator.composer')
                    ->addPackage($plugin['install']['package'], $plugin['install']['version']);
                $plugin = $this->getPlugin('plugin/'.$plugin['install']['package'].'/');
                break;
        }

        return $this->render('AnimeDbCatalogBundle:Update:index.html.twig', [
            'can_update' => $can_update,
            'doc' => !$can_update ? $this->get('anime_db.api.client')->getSiteUrl(self::GUIDE_LINK) : '',
            'referer' => $request->headers->get('referer'),
            'plugin' => $action ? $plugin : [],
            'action' => $action,
        ], $response);
    }
1136992
private function getRequestedPage(Request $request)
    {
        $pageNumber = $request->query->getInt('page', 1);
        if (!$pageNumber || $pageNumber < 1) {
            $pageNumber = 1;
        }

        return $pageNumber;
    }
1069097
protected function createRateLimitExceededException(Request $request)
    {
        $config = $this->exceptionConfig;
        $class = $config['custom_exception'] ?? RateLimitExceededException::class;
        $username = null;

        if (null !== $token = $this->tokenStorage->getToken()) {
            if (is_object($token->getUser())) {
                $username = $token->getUsername();
            }
        }

        return new $class($config['status_code'], $config['message'], $request->getClientIp(), $username);
    }
269793
public static function updateRequest($request) {
        $routeModel = Dir::apiModel(static::$model);
        $heroe = $routeModel::find($request->id);

        foreach($heroe->getTuples() as $tuple)
            if(!empty($request->$tuple))
                $heroe->$tuple = $request->$tuple;

        $heroe->update();
        return $heroe;
    }
1327469
public function postAction(Request $request)
    {
        try {
            $data = $request->request->all();
            $data['type'] = OrderType::MANUAL;

            $order = $this->getManager()->save(
                $data,
                $this->getLocaleManager()->retrieveLocale($this->getUser(), $request->get('locale')),
                $this->getUser()->getId()
            );

            $view = $this->view($order, 200);
        } catch (OrderDependencyNotFoundException $exc) {
            $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
            $view = $this->view($exception->toArray(), 400);
        } catch (MissingOrderAttributeException $exc) {
            $exception = new MissingArgumentException($this->getOrderEntityName(), $exc->getAttribute());
            $view = $this->view($exception->toArray(), 400);
        }

        return $this->handleView($view);
    }
636257
public function index(Request $request)
    {
        $dryRun = $this->isDryRun();
        $commitCall = $dryRun ? 'rollBack' : 'commit';

        try {
            DB::beginTransaction();
            $context = new OperationContextAdapter($request);
            $host = new ServiceHost($context, $request);
            $host->setServiceUri('/odata.svc/');

            $query = App::make('odataquery');
            $meta = App::make('metadata');

            $service = new DataService($query, $meta, $host);
            $cereal = new IronicSerialiser($service, null);
            $service = new DataService($query, $meta, $host, $cereal);
            $pageSize = $this->getAppPageSize();
            if (null !== $pageSize) {
                $service->maxPageSize = intval($pageSize);
            }
            $service->handleRequest();

            $odataResponse = $context->outgoingResponse();

            $content = $odataResponse->getStream();

            $headers = $odataResponse->getHeaders();
            $responseCode = $headers[\POData\Common\ODataConstants::HTTPRESPONSE_HEADER_STATUS_CODE];
            $responseCode = isset($responseCode) ? intval($responseCode) : 200;
            $response = new Response($content, $responseCode);

            foreach ($headers as $headerName => $headerValue) {
                if (null !== $headerValue) {
                    $response->headers->set($headerName, $headerValue);
                }
            }
            DB::$commitCall();
        } catch (\Exception $e) {
            DB::rollBack();
            throw $e;
        }
        return $response;
    }
1277197
public function installInfo(Request $request)
    {
        $package = $request->query->get('package');
        if ($package === null) {
            $message = 'Extension browser request query was missing or invalid, check your web server configuration.';

            return $this->getJsonException(new \Exception($message));
        }
        if ($package === '') {
            $message = sprintf(
                'No extension was selected. Try entering a name and press the "%s" button.',
                Trans::__('page.extend.button.browse-versions')
            );

            return $this->getJsonException(new \Exception($message));
        }
        $versions = ['dev' => [], 'beta' => [], 'RC' => [], 'stable' => []];

        try {
            $info = $this->app['extend.info']->info($package, Bolt\Version::forComposer());
        } catch (\Exception $e) {
            return $this->getJsonException($e);
        }

        if (isset($info->version) && is_array($info->version)) {
            foreach ($info->version as $version) {
                $versions[$version->stability][] = $version;
            }
        }

        return $this->json($versions);
    }
325561
public function packageInfo(Request $request)
    {
        $packageName = $request->get('package');
        $reqVersion = $request->get('version');

        try {
            $response = $this->manager()->showPackage('installed', $packageName, $reqVersion);
        } catch (\Exception $e) {
            return $this->getJsonException($e);
        }

        if (isset($response[$packageName]['package'])) {
            /** @var PackageInterface $package */
            $package = $response[$packageName]['package'];

            return $this->json([
                'name'    => $packageName,
                'version' => $package->getPrettyVersion(),
                'type'    => $package->getType(),
            ]);
        }

        return $this->getJsonException(new PackageManagerException(Trans::__('page.extend.message.package-install-info-fail', ['%PACKAGE%' => $packageName, '%VERSION%' => $reqVersion])));
    }
41895
public function install(Request $request)
    {
        $package = $request->get('package');
        $version = $request->get('version');
        try {
            $response = $this->manager()->requirePackage(
                [
                    'name'    => $package,
                    'version' => $version,
                ]
            );
        } catch (\Exception $e) {
            return $this->getJsonException($e);
        }

        if ($response === 0) {
            $this->app['extensions.stats']->recordInstall($package, $version);
            $this->app['logger.system']->info("Installed $package $version", ['event' => 'extensions']);

            return new Response($this->manager()->getOutput());
        }

        return $this->getJsonException(new PackageManagerException($this->manager()->getOutput(), $response));
    }
233056
public function moveAction(Request $request)
    {
        $section = $this->getSection($request->query->get('id'), true);

        $terms = $section->getTerms();

        // [OP 2014-09-07] Verify that the target section is part of the same terms!
        $dest = $this->getQuery()
            ->filterByTermsId($terms->getId())
            ->findPk($request->query->get('dest_id'));

        if (!$request->isXmlHttpRequest() || !$dest) {
            throw $this->createNotFoundException('Section not found');
        }

        $data = array();

        try {
            switch ($request->query->get('as')) {
                case 'child':
                    $section->moveToFirstChildOf($dest);
                    break;
                case 'sibling':
                    $dest->isRoot() ?
                        $section->moveToFirstChildOf($dest)
                        : $section->moveToNextSiblingOf($dest);
                    break;
                default:
                    $section->moveToLastChildOf($dest);
                    break;
            }

            $data['success'] = true;
            $this->get('session')->getFlashBag()->add(
                'notice',
                $this->get('translator')->trans('section.move.success', array(), 'CPTermsBundle', $request->getLocale())
            );

        } catch (RuntimeException $e) {
            $data['success'] = false;
            $this->get('session')->getFlashBag()->add(
                'notice',
                $this->get('translator')->trans('section.move.error', array(), 'CPTermsBundle', $request->getLocale())
            );

        }

        return new Response(json_encode($data), 200, array('Content-Type' => 'application/json'));
    }
1202005
public function execute(Request $request)
    {
        $command = $request->get('command');

        try {
            $result = $this->manager()->execute($command);
        } catch (\Exception $exception) {
            return $this->renderException($exception);
        }

        if (is_string($result) && Str::startsWith($result, ['ERR ', 'WRONGTYPE '])) {
            return $this->renderException(new \Exception($result));
        }

        return $this->getDumpedHtml($result);
    }
307094
protected function getTotalChunksFromRequest(Request $request)
    {
        if (!$request->get(static::KEY_CHUNK_SIZE)) {
            return 0;
        }

        return intval(
            ceil($request->get(static::KEY_TOTAL_SIZE) / $request->get(static::KEY_CHUNK_SIZE))
        );
    }
554921
public function execute($request)
	{
		$method = strtolower($request->getRequestMethod());
		if(!in_array($method,array('get','put','post','delete','head')))
		{
			throw new Exception("Unknown HTTP verb");
		}

		$this->setRouter($request->getRouter());

		return $this->$method($request);
	}
26656
public function determineLocale(Request $request)
    {
        return $request->session()->get($this->sessionKey, $this->fallback);
    }
276609
public function moveDownAction(Request $request)
    {
        $container = $this->findContainerByRequest($request);

        try {
            $sibling = $this->getEditor()->getContainerManager()->moveDown($container);
        } catch (EditorExceptionInterface $e) {
            return $this->handleException($e);
        }

        $content = $container->getContent();

        $this->validate($content);
        $this->persist($content);

        $data = [
            'containers' => [
                $this->getViewBuilder()->buildContainer($container),
                $this->getViewBuilder()->buildContainer($sibling),
            ],
        ];

        return $this->buildResponse($data, self::SERIALIZE_LAYOUT);
    }