Params
- Full name:
\PhalconKit\Mvc\Controller\Traits\Params
Properties
rawParams
protected array<string,mixed>|null $rawParams
defaultFilters
protected array<string,array|string> $defaultFilters
Methods
getParam
Retrieve a specific parameter value by key.
public getParam(string $key, array|string|null $filters = null, mixed|null $default = null, array|null $params = null): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$filters | array|string|null | |
$default | mixed|null | |
$params | array|null |
Throws:
hasParam
Check if a given key exists in the parameter array.
public hasParam(string $key, array|null $params = null, bool $cached = true): bool
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$params | array|null | |
$cached | bool |
getParams
Retrieve specific or all request parameters.
public getParams(array|null $fields = null, bool $cached = true, bool $deep = true): array<string,mixed>
Usage examples: - getParams() -> all params - getParams(['email', 'password']) -> only those keys - getParams(['email' => [Filter::TRIM], 'password']) -> filtered subset
Parameters:
| Parameter | Type | Description |
|---|---|---|
$fields | array|null | Keys or key=>filters to extract. |
$cached | bool | Whether to reuse cached raw parameters. |
$deep | bool | Whether to apply deep sanitization. |
Throws:
getAllParams
Retrieve all request parameters, optionally applying filters and caching results.
public getAllParams(array|null $filters = null, bool $cached = true, bool $deep = true): array<string,mixed>
Parameters:
| Parameter | Type | Description |
|---|---|---|
$filters | array|null | Temporary filters to apply. |
$cached | bool | Whether to reuse previously loaded parameters. |
$deep | bool | Whether to apply filters recursively. |
Throws:
collectRequestParams
Collect parameters based on the HTTP method.
private collectRequestParams(): array<string,mixed>
applyFilters
Apply filters to parameters (recursively if $deep is true).
public applyFilters(array<string,mixed> $params, array<string,array|string> $filters, bool $deep = true): array<string,mixed>
Parameters:
| Parameter | Type | Description |
|---|---|---|
$params | array | |
$filters | array | |
$deep | bool |
Throws:
deepSanitize
Recursively sanitize nested arrays.
private deepSanitize(mixed $value, array|string $filters): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$value | mixed | |
$filters | array|string |
Throws:
setDefaultFilters
Sets default filters, replacing any previously defined.
public setDefaultFilters(array<string,array|string> $filters): static
Parameters:
| Parameter | Type | Description |
|---|---|---|
$filters | array |
addDefaultFilters
Adds or merges new default filters to existing ones.
public addDefaultFilters(array<string,array|string> $filters): static
Parameters:
| Parameter | Type | Description |
|---|---|---|
$filters | array |
removeFilters
Remove one or many default filters by key.
public removeFilters(string|array<int,string> $keys): static
Parameters:
| Parameter | Type | Description |
|---|---|---|
$keys | string|array |
clearDefaultFilters
Clears all default filters.
public clearDefaultFilters(): static
getDefaultFilters
Get currently active default filters.
public getDefaultFilters(): array<string,array|string>
getRawParams
Retrieves the raw parameters from the request. If caching is enabled, it returns the cached parameters.
public getRawParams(bool $cached = true): array<string,mixed>
Parameters:
| Parameter | Type | Description |
|---|---|---|
$cached | bool | Determines whether to use cached parameters. Defaults to true. |
Return Value:
The raw request parameters.