postTypeFinder

Tries to get the posttype from the url.
Returns an empty string when its not found.

@param \Cake\Network\Request $request The current request-object.
@return string
974827
public function postTypeFinder($request)
    {
        if (key_exists('type', $request->query)) {
            return $request->query['type'];
        }
        if (key_exists(0, $request->params['pass'])) {
            return $request->params['pass'][0];
        }
        return '';
    }
701086
protected function determineTargetUrl(Request $request)
    {
        if ($this->options['always_use_default_target_path']) {
            return $this->options['default_target_path'];
        }

        if ($targetUrl = ParameterBagUtils::getRequestParameterValue($request, $this->options['target_path_parameter'])) {
            return $targetUrl;
        }

        if (null !== $this->providerKey && $targetUrl = $this->getTargetPath($request->getSession(), $this->providerKey)) {
            $this->removeTargetPath($request->getSession(), $this->providerKey);

            return $targetUrl;
        }

        if ($this->options['use_referer'] && $targetUrl = $request->headers->get('Referer')) {
            if (false !== $pos = strpos($targetUrl, '?')) {
                $targetUrl = substr($targetUrl, 0, $pos);
            }
            if ($targetUrl && $targetUrl !== $this->httpUtils->generateUri($request, $this->options['login_path'])) {
                return $targetUrl;
            }
        }

        return $this->options['default_target_path'];
    }
982784
public function getPayload($request = null)
    {
        if (!$request) {
            return $this->_payload;
        }

        $payload = null;

        $token = $this->getToken($request);
        if ($token) {
            $payload = $this->_decode($token);
        }

        return $this->_payload = $payload;
    }
1357436
protected function getRouteFromRequest(Request $request)
    {
        $attributes = $request->attributes->get('_route_params');

        if (isset($attributes[RouteObjectInterface::ROUTE_OBJECT])
            && ($attributes[RouteObjectInterface::ROUTE_OBJECT] instanceof RouteInterface)
        ) {
            return $attributes[RouteObjectInterface::ROUTE_OBJECT];
        }

        return null;
    }
1232006
public function typenodeAction(Request $request)
    {
        $types = $this->get("ydle.nodetype.manager")->findAllByName();
        $sensorType = new NodeType();

        // Manage edition mode
        $this->currentType = $request->get('type');
        if ($this->currentType) {
            $sensorType = $this->get("ydle.nodetype.manager")->find($request->get('type'));
        }
        $form = $this->createForm("nodetypes_form", $sensorType);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($sensorType);
            $em->flush();
            $message = 'Type de capteur ajoutée avec succès';
            if ($sensorType->getId()) {
                $message = 'Type de capteur modifié avec succès';
            }
            $this->get('session')->getFlashBag()->add('notice', $message);

            return $this->redirect($this->generateUrl('configTypeSensor'));
        }

        return $this->render('YdleHubBundle:Config:typenode.html.twig', array(
            'form' => $form->createView(),
            'current' => 'typesensor',
            'mainpage' => 'config',
            'items' => $types
        ));
    }
726318
public static function create_from_request($request) {
        if($type = $request->getVar('accept')) {
            try {
                if(array_key_exists($type, self::$lookup)) {
                    return self::create(self::$lookup[$type]);
                }
            } catch(\Exception $e) {}
        }
        $types = $request->getAcceptMimetypes();
        foreach($types as $type) {
            try {
                return self::create($type);
            } catch(RestUserException $e) {}
        }
        return self::create();
    }
706329
public static function setFromURL(Request $request)
    {
        if(!\Request::route('lang')) {
            // language may be present in url without {param} defined
            $detectLanguageFromRequest = \App\Models\Language::detectLanguageFromRequest($request);
            if ($detectLanguageFromRequest) {
                $request->route()->setParameter('lang', $detectLanguageFromRequest);
                return $detectLanguageFromRequest;
            }
        }
        return null;
    }
213393
public function findByRequest(Request $request): ?PageInterface
    {
        if (null !== $route = $request->attributes->get('_route', null)) {
            return $this->findByRoute($route);
        }

        return null;
    }
1091779
public function parseVerb($request)
    {
        if (isset($request->server['http_x_http_method_override'])) {
            return strtoupper($request->server['http_x_http_method_override']);
        }
        if (isset($request->server['request_method'])) {
            return strtoupper($request->server['request_method']);
        }

        return 'GET';
    }
203553
private function getUri(Request $request): string
    {
        if ($request->attributes->has('ngbmContextUri')) {
            return $request->attributes->get('ngbmContextUri');
        }

        return $request->getRequestUri();
    }
482457
protected function getBackUrl(Request $request)
    {
        if (($backUrl = $request->input('_redirectBack')) == \URL::previous()) {
            $backUrl = null;
            $request->merge(['_redirectBack' => $backUrl]);
        }

        return $backUrl;
    }
1068977
public function search(HTTPRequest $request)
    {
        // Check form field state
        if($this->isDisabled() || $this->isReadonly()) {
            return $this->httpError(403);
        }

        $query = $request->getVar('query');

        // use callbacks if they're set, otherwise used this class's methods for search and processing
        if ($this->getSearchCallback()) {
            $results = call_user_func($this->getSearchCallback(), $query, $this);
        } else {
            $results = $this->getResults($query);
        }

        if ($this->getProcessCallback()) {
            $json = call_user_func($this->getProcessCallback(), $results, $this);
        } else {
            $json = $this->processResults($results);
        }

        return Convert::array2json($json);
    }
1359528
protected function getContentType(ServerRequestInterface $request)
    {
        // Check for an attribute
        if (null !== $accept = $request->getAttribute('Content-Type', null)) {
            return $accept;
        }

        // Check for an accept header
        if ($request->hasHeader('Content-Type')) {
            return $request->getHeaderLine('Content-Type');
        }

        return null;
    }
1290283
public static function query_string($request = null)
    {
        if (!$request) {
            $request = Controller::curr()->Request;
        }

        if (!$request) {
            return '';
        }

        $vars = $request->getVars();
        if (isset($vars['url'])) {
            unset($vars['url']);
        }

        return empty($vars) ? '' : '?' . http_build_query($vars);
    }
597813
protected function getToken(HTTPRequest $request): ?string
    {
        if ($authHeader = $request->getHeader('Authorization')) {
            if (stripos($authHeader, 'Bearer ') === 0) {
                return substr($authHeader, 6);
            }
        }

        return null;
    }
535556
private function getLocaleFromTypo3(Request $request): ?string
    {
        $locale = null;

        if ((bool) $language = $request->attributes->get('language')) {
            /* @var SiteLanguage $language */
            [$locale] = \explode('.', $language->getLocale());
        } elseif ((bool) $site = $request->attributes->get('site')) {
            /* @var Site $site */
            [$locale] = \explode('.', $site->getDefaultLanguage()->getLocale());
        }

        return $locale;
    }
273747
public function getInvTypes(Request $request)
    {

        return response()->json([
            'results' => DB::table('invTypes')
                ->select('typeName as id', 'typeName as text')
                ->where('typeName', 'like', '%' . $request->q . '%')->get(),
        ]);

    }