Extract view parameters from Request attributes

@param Request $request
@param array $exclude Keys to exclude from view

@return array
355233
protected function extractViewParameters(Request $request, array $exclude = [])
    {
        $parameters = [];

        foreach ($request->attributes as $key => $value) {
            if (strpos($key, '_') !== 0 && !in_array($key, $exclude)) {
                $parameters[$key] = $value;
            }
        }

        return $parameters;
    }
29719
public function frontend_excluded_ip_addresses($request)
    {
        $frontend_excluded_ip_addresses = config('lasallecmsfrontend.frontend_excluded_ip_addresses');

        // "true" = exclude
        if (empty($frontend_excluded_ip_addresses)) return false;

        $requestIPAddress = $this->customAdminAuthChecks->getRequestIPAddress($request);

        return $this->customAdminAuthChecks->ipAddressCheck($frontend_excluded_ip_addresses, $requestIPAddress);
    }
200730
public function bindParameters(Request $request)
    {
        // If the route has a regular expression for the host part of the URI, we will
        // compile that and get the parameter matches for this domain. We will then
        // merge them into this parameters array so that this array is completed.
        $params = $this->matchToKeys(
            array_slice($this->bindPathParameters($request), 1)
        );

        // If the route has a regular expression for the host part of the URI, we will
        // compile that and get the parameter matches for this domain. We will then
        // merge them into this parameters array so that this array is completed.
        if (! is_null($this->compiled->getHostRegex())) {
            $params = $this->bindHostParameters($request, $params);
        }

        return $this->parameters = $this->replaceDefaults($params);
    }
603765
public function retrieveCurrent(Request $request)
    {
        if (ConfigQuery::isRewritingEnable()) {
            $view = $request->attributes->get('_view', null);

            $viewLocale = $this->getViewLocale($request);

            $viewId = $view === null ? null : $request->query->get($view . '_id', null);

            $allOtherParameters = $request->query->all();
            if ($view !== null) {
                unset($allOtherParameters['view']);
                if ($viewId !== null) {
                    unset($allOtherParameters[$view . '_id']);
                }
            }
            if ($viewLocale !== null) {
                unset($allOtherParameters['lang']);
                unset($allOtherParameters['locale']);
            }

            $this->retriever->loadSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters);
        } else {
            $allParametersWithoutView = $request->query->all();
            $view = $request->attributes->get('_view');
            if (isset($allOtherParameters['view'])) {
                unset($allOtherParameters['view']);
            }
            $this->retriever->rewrittenUrl = null;
            $this->retriever->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
        }

        return $this->retriever;
    }
161772
final protected function getRequestParameters($request) {
		$parameters = $request->route()->parameters;
		array_unshift($parameters, $request);
		
		return $parameters;
	}
729763
public function getAttributeByName(Request $request, string $name): array
    {
        $matches = \array_filter($this->getReleasedAttributes($request), function ($key) use ($name) {
            return \strtoupper($name) == \strtoupper($key);
        }, ARRAY_FILTER_USE_KEY);
        if (empty($matches)) {
            return [];
        } else {
            return \current($matches);
        }
    }
889881
private function getContentFromRequest(Request $request): array
    {
        $data = json_decode($request->getContent(), true);
        foreach ($data as $key => $value) {
            if ($value === null || $value === '') {
                unset($data[$key]);
            }
        }
        return $data;
    }
350665
protected function getTermData(Request $request)
    {
        $data = [];

        foreach ($this->repository as $field) {
            $data[$field->getName()] = $request->get($field->getName());
        }

        return $data;
    }
888278
protected function getViewParameters(Request $request, Form $form = null, $data = null): array
    {
        $parameters = parent::getViewParameters($request, $form, $data);
        if ('preview' === $this->admin->getCurrentAction()->getCode()) {
            $parameters['disabled'] = $request->query->getBoolean('disabled');
        }

        return $parameters;
    }
896654
private function getTemplateParameters(Request $request)
    {
        // When the media bundle is available, we show a link in the header to the media chooser
        $allBundles = $this->getParameter('kernel.bundles');
        $mediaChooserLink = null;

        if (array_key_exists('KunstmaanMediaBundle', $allBundles)) {
            $params = ['linkChooser' => 1];
            $cKEditorFuncNum = $request->get('CKEditorFuncNum');
            if (!empty($cKEditorFuncNum)) {
                $params['CKEditorFuncNum'] = $cKEditorFuncNum;
            }
            $mediaChooserLink = $this->generateUrl(
                'KunstmaanMediaBundle_chooser',
                $params
            );
        }

        return [
            'mediaChooserLink' => $mediaChooserLink,
        ];
    }
1038839
public function cgetNodes(Request $request)
    {
        $tree = $this->getBooleanRequestParameter($request, 'tree', false, false);
        $ids = $this->getRequestParameter($request, 'ids');

        if (true === $tree) {
            return $this->getTreeForUuid($request, $this->getRequestParameter($request, 'id', false, null));
        } elseif (null !== $ids) {
            return $this->getNodesByIds($request, $ids);
        }

        $language = $this->getLanguage($request);
        $webspace = $this->getWebspace($request);
        $excludeGhosts = $this->getBooleanRequestParameter($request, 'exclude-ghosts', false, false);

        $parentUuid = $request->get('parentId');
        $depth = $request->get('depth', 1);
        $depth = intval($depth);
        $flat = $request->get('flat', 'true');
        $flat = ('true' === $flat);

        // TODO pagination
        $result = $this->getRepository()->getNodes(
            $parentUuid,
            $webspace,
            $language,
            $depth,
            $flat,
            false,
            $excludeGhosts
        );

        return $this->handleView($this->view($result));
    }
864672
private function getControllerParams(Request $request, $controllerString)
    {
        $query = $request->query->all();
        $methodParameters = $this->getControllerParameters($controllerString);

        $parameters = array();
        foreach ($methodParameters as $methodParameter) {
            $parameterName = $methodParameter->getName();
            if ('request' === $parameterName) continue;

            if (isset($query[$parameterName])) {
                $parameters[$parameterName] = $query[$parameterName];
                unset($query[$parameterName]);
            }
        }

        return array($parameters, $query);
    }
645183
protected function getStrictRequestParameters(Request $request): array
    {
        $data = [];

        foreach ($this->strictUpdateKeys as $value) {
            if ($request->filled($value)) {
                $data[$value] = $request->input($value);
            }
        }

        return $data;
    }
9769
protected function extractProperties(Request $request/*, string $resourceClass*/): array
    {
        @trigger_error(sprintf('The use of "%s::extractProperties()" is deprecated since 2.2. Use the "filters" key of the context instead.', __CLASS__), E_USER_DEPRECATED);

        $resourceClass = \func_num_args() > 1 ? (string) func_get_arg(1) : null;
        $needsFixing = false;
        if (null !== $this->properties) {
            foreach ($this->properties as $property => $value) {
                if (($this->isPropertyNested($property, $resourceClass) || $this->isPropertyEmbedded($property, $resourceClass)) && $request->query->has(str_replace('.', '_', $property))) {
                    $needsFixing = true;
                }
            }
        }

        if ($needsFixing) {
            $request = RequestParser::parseAndDuplicateRequest($request);
        }

        return $request->query->all();
    }
1060023
private function getRequestOptions(Request $request)
    {
        $options = [
            'http_errors' => false,
            'synchronous' => true
        ];

        if ($request->getQuery()) {
            $options['query'] = array_merge($this->getDefaultQuery(), $request->getQuery());
        } else {
            $options['query'] = $this->getDefaultQuery();
        }
        if ($request->getParams())
            $options['json'] = $request->getParams();

        return $options;
    }
538839
public function index(Request $request)
    {
        $query = $this->load()->query();

        /* Verificar como ira compilar...
        $except = isset($this->exceptAttributesIn['index']) ? $this->exceptAttributesIn['index'] : [];

        // Tratar attributes
        $result = [];
        foreach ($query->get() as $model) {
            $result[] = Arr::except($model->toArray(), $except);
        }*/

        return response()->json($query->get());
    }
380565
public function extract(Request $request)
    {
        $trackingParameters = new ParameterBag();

        /** Get value from cookies. */
        foreach ($this->extracters as $extracter) {
            if ($extracter instanceof TrackingParameterCookieExtracterInterface) {
                $trackingParameters->add($extracter->extractFromCookies($request->cookies));
            }
        }

        /** Override cookies' value by query's value if set. */
        foreach ($this->extracters as $extracter) {
            if ($extracter instanceof TrackingParameterQueryExtracterInterface) {
                $trackingParameters->add($extracter->extractFromQuery($request->query));
            }
        }

        return $trackingParameters;
    }