final class RobotsController extends AbstractController (View source)

Methods

setControllerContext(ServerRequestInterface $request, ResponseFactoryInterface $responseFactory, StreamFactoryInterface $streamFactory, ContainerInterface $container)

Initializes the controller runtime context before an action is executed.

void
ServerRequestInterface from AbstractController

Returns the current PSR-7 server request for the dispatched action.

ServerRequestInterface
input(string $key, mixed $default = null)

Returns a combined request input value.

mixed
query(string $key, mixed $default = null)

Returns a query string parameter.

mixed

Returns all query string parameters.

array
post(string $key, mixed $default = null)

Returns a parsed body value.

mixed

Returns all parsed body values.

array
string|null from AbstractController
header(string $name, string|null $default = null)

Returns a request header value.

string|null

Returns all request headers grouped by header name.

array
cookie(string $name, mixed $default = null)

Returns a cookie parameter.

mixed

Returns all cookie parameters.

array
server(string $key, mixed $default = null)

Returns a server parameter.

mixed

Returns all server parameters.

array
body()

Returns the raw request body.

string
jsonInput(string $key, mixed $default = null)

Returns a value from the decoded JSON request payload.

mixed

Returns the decoded JSON request payload.

array

Reports whether the request content type is JSON.

bool

Reports whether the request Accept header allows JSON responses.

bool

Reports whether the request should be treated as expecting JSON.

bool
UploadedFileInterface|array|null from AbstractController
file(string $name)

Returns an uploaded file entry by name.

UploadedFileInterface|array|null
files()

Returns all uploaded files indexed by input name.

array

Reports whether the request was made through AJAX/XHR semantics.

bool
string|null from AbstractController
ip()

Returns the resolved client IP address when available.

string|null
string|null from AbstractController
userAgent(string|null $default = null)

Returns the User-Agent header value.

string|null
string|null from AbstractController
referer(string|null $default = null)

Returns the Referer header value.

string|null
method()

Returns the normalized HTTP method.

string
isMethod(HttpMethod|string $method)

Reports whether the current request uses the given HTTP method.

bool
isGet()

Reports whether the request method is GET.

bool
isPost()

Reports whether the request method is POST.

bool
isPut()

Reports whether the request method is PUT.

bool

Reports whether the request method is PATCH.

bool

Reports whether the request method is DELETE.

bool
isHead()

Reports whether the request method is HEAD.

bool

Reports whether the request method is OPTIONS.

bool
inputString(string $key, string $default = '')

Returns an input value converted to string semantics.

string
inputInt(string $key, int $default = 0)

Returns an input value converted to integer semantics.

int
inputFloat(string $key, float $default = 0.0)

Returns an input value converted to float semantics.

float
inputBool(string $key, bool $default = false)

Returns an input value converted to boolean semantics.

bool
ResponseInterface from AbstractController
text(string $content, int $status = 200)

Creates a plain text response.

ResponseInterface
ResponseInterface from AbstractController
html(string $content, int $status = 200)

Creates an HTML response.

ResponseInterface
ResponseInterface from AbstractController
json(array $payload, int $status = 200)

Creates a JSON response from the provided payload.

ResponseInterface
ResponseInterface from AbstractController
redirect(string $to, int $status = 302)

Creates a redirect response.

ResponseInterface
ResponseInterface from AbstractController
download(string $filePath, string|null $downloadName = null, string $contentType = 'application/octet-stream')

Creates a file download response.

ResponseInterface
ResponseInterface from AbstractController
response(string $content = '', int $status = 200, string $contentType = 'text/html; charset=UTF-8')

Creates a generic response with an explicit content type.

ResponseInterface
ResponseInterface from AbstractController
stream(callable $producer, int $status = 200, string $contentType = 'text/plain; charset=UTF-8', array $headers = [])

Creates a streamed response produced by the given callback.

ResponseInterface
app()

Returns the application context available to the controller.

Returns the breadcrumb component service.

router()

Returns the framework router service.

url()

Returns the framework URL generator.

Returns the form validation service.

upload()

Returns the upload factory service.

Returns the filesystem service.

view()

Returns the view renderer service.

flash()

Returns the flash message bag.

controllerService(string $id)

Returns a controller-scoped service resolved from the container.

object
setLang(string|null $locale)

Sets the active locale on both translator and validator services.

void
trans(string $key, array $replacements = [], string|null $locale = null)

Translates a localized key with optional replacements.

string
transGroup(string $group, string|null $locale = null)

Returns the complete translation group for the given locale.

array
ResponseInterface
index()
ResponseInterface

Details

setControllerContext

final void setControllerContext(ServerRequestInterface $request, ResponseFactoryInterface $responseFactory, StreamFactoryInterface $streamFactory, ContainerInterface $container)

Initializes the controller runtime context before an action is executed.

This framework-managed entrypoint stores the current request, response factory, stream factory, and service container, then creates the controller context, response helpers, and service accessors used by derived controllers.

Parameters

ServerRequestInterface $request
ResponseFactoryInterface $responseFactory
StreamFactoryInterface $streamFactory
ContainerInterface $container

Return Value

void

request

protected ServerRequestInterface request()

Returns the current PSR-7 server request for the dispatched action.

Return Value

ServerRequestInterface

input

protected mixed input(string $key, mixed $default = null)

Returns a combined request input value.

Parameters

string $key
mixed $default

Return Value

mixed

query

protected mixed query(string $key, mixed $default = null)

Returns a query string parameter.

Parameters

string $key
mixed $default

Return Value

mixed

queryAll

protected array queryAll()

Returns all query string parameters.

Return Value

array

post

protected mixed post(string $key, mixed $default = null)

Returns a parsed body value.

Parameters

string $key
mixed $default

Return Value

mixed

postAll

protected array postAll()

Returns all parsed body values.

Return Value

array

header

protected string|null header(string $name, string|null $default = null)

Returns a request header value.

Parameters

string $name
string|null $default

Return Value

string|null

headers

protected array headers()

Returns all request headers grouped by header name.

Return Value

array
protected mixed cookie(string $name, mixed $default = null)

Returns a cookie parameter.

Parameters

string $name
mixed $default

Return Value

mixed

cookies

protected array cookies()

Returns all cookie parameters.

Return Value

array

server

protected mixed server(string $key, mixed $default = null)

Returns a server parameter.

Parameters

string $key
mixed $default

Return Value

mixed

serverAll

protected array serverAll()

Returns all server parameters.

Return Value

array

body

protected string body()

Returns the raw request body.

Return Value

string

jsonInput

protected mixed jsonInput(string $key, mixed $default = null)

Returns a value from the decoded JSON request payload.

Parameters

string $key
mixed $default

Return Value

mixed

jsonPayload

protected array jsonPayload()

Returns the decoded JSON request payload.

Return Value

array

isJsonRequest

protected bool isJsonRequest()

Reports whether the request content type is JSON.

Return Value

bool

acceptsJson

protected bool acceptsJson()

Reports whether the request Accept header allows JSON responses.

Return Value

bool

expectsJson

protected bool expectsJson()

Reports whether the request should be treated as expecting JSON.

Return Value

bool

file

protected UploadedFileInterface|array|null file(string $name)

Returns an uploaded file entry by name.

Parameters

string $name

Return Value

UploadedFileInterface|array|null

files

protected array files()

Returns all uploaded files indexed by input name.

Return Value

array

isAjaxRequest

protected bool isAjaxRequest()

Reports whether the request was made through AJAX/XHR semantics.

Return Value

bool

ip

protected string|null ip()

Returns the resolved client IP address when available.

Return Value

string|null

userAgent

protected string|null userAgent(string|null $default = null)

Returns the User-Agent header value.

Parameters

string|null $default

Return Value

string|null

referer

protected string|null referer(string|null $default = null)

Returns the Referer header value.

Parameters

string|null $default

Return Value

string|null

method

protected string method()

Returns the normalized HTTP method.

Return Value

string

isMethod

protected bool isMethod(HttpMethod|string $method)

Reports whether the current request uses the given HTTP method.

Parameters

HttpMethod|string $method

Return Value

bool

isGet

protected bool isGet()

Reports whether the request method is GET.

Return Value

bool

isPost

protected bool isPost()

Reports whether the request method is POST.

Return Value

bool

isPut

protected bool isPut()

Reports whether the request method is PUT.

Return Value

bool

isPatch

protected bool isPatch()

Reports whether the request method is PATCH.

Return Value

bool

isDelete

protected bool isDelete()

Reports whether the request method is DELETE.

Return Value

bool

isHead

protected bool isHead()

Reports whether the request method is HEAD.

Return Value

bool

isOptions

protected bool isOptions()

Reports whether the request method is OPTIONS.

Return Value

bool

inputString

protected string inputString(string $key, string $default = '')

Returns an input value converted to string semantics.

Parameters

string $key
string $default

Return Value

string

inputInt

protected int inputInt(string $key, int $default = 0)

Returns an input value converted to integer semantics.

Parameters

string $key
int $default

Return Value

int

inputFloat

protected float inputFloat(string $key, float $default = 0.0)

Returns an input value converted to float semantics.

Parameters

string $key
float $default

Return Value

float

inputBool

protected bool inputBool(string $key, bool $default = false)

Returns an input value converted to boolean semantics.

Parameters

string $key
bool $default

Return Value

bool

text

protected ResponseInterface text(string $content, int $status = 200)

Creates a plain text response.

Parameters

string $content
int $status

Return Value

ResponseInterface

html

protected ResponseInterface html(string $content, int $status = 200)

Creates an HTML response.

Parameters

string $content
int $status

Return Value

ResponseInterface

json

protected ResponseInterface json(array $payload, int $status = 200)

Creates a JSON response from the provided payload.

Parameters

array $payload
int $status

Return Value

ResponseInterface

redirect

protected ResponseInterface redirect(string $to, int $status = 302)

Creates a redirect response.

Parameters

string $to
int $status

Return Value

ResponseInterface

download

protected ResponseInterface download(string $filePath, string|null $downloadName = null, string $contentType = 'application/octet-stream')

Creates a file download response.

Parameters

string $filePath
string|null $downloadName
string $contentType

Return Value

ResponseInterface

response

protected ResponseInterface response(string $content = '', int $status = 200, string $contentType = 'text/html; charset=UTF-8')

Creates a generic response with an explicit content type.

Parameters

string $content
int $status
string $contentType

Return Value

ResponseInterface

stream

protected ResponseInterface stream(callable $producer, int $status = 200, string $contentType = 'text/plain; charset=UTF-8', array $headers = [])

Creates a streamed response produced by the given callback.

Parameters

callable $producer
int $status
string $contentType
array $headers

Return Value

ResponseInterface

app

Returns the application context available to the controller.

Return Value

ApplicationContext

breadcrumb

Returns the breadcrumb component service.

Return Value

BreadcrumbComponent

router

protected Router router()

Returns the framework router service.

Return Value

Router

url

Returns the framework URL generator.

Return Value

UrlGenerator

validator

Returns the form validation service.

Return Value

FormValidation

upload

Returns the upload factory service.

Return Value

UploadFactory

translator

Returns the translator service.

Return Value

TranslatorInterface

filesystem

protected Filesystem filesystem()

Returns the filesystem service.

Return Value

Filesystem

view

protected View view()

Returns the view renderer service.

Return Value

View

flash

Returns the flash message bag.

Return Value

FlashBagInterface

controllerService

protected object controllerService(string $id)

Returns a controller-scoped service resolved from the container.

Parameters

string $id

Return Value

object

setLang

protected void setLang(string|null $locale)

Sets the active locale on both translator and validator services.

Parameters

string|null $locale

Return Value

void

trans

protected string trans(string $key, array $replacements = [], string|null $locale = null)

Translates a localized key with optional replacements.

Parameters

string $key
array $replacements
string|null $locale

Return Value

string

transGroup

protected array transGroup(string $group, string|null $locale = null)

Returns the complete translation group for the given locale.

Parameters

string $group
string|null $locale

Return Value

array

__construct

__construct(RobotsTxtGenerator $generator)

No description

Parameters

RobotsTxtGenerator $generator

index

ResponseInterface index()

No description

Return Value

ResponseInterface