• PHP reference
  • Sandbox

Response

class Sandbox\Response extends ExtendableObject

Class to control page output.

Properties

string $views_root

The default directory to retrieve templates from.

string $views_partials_root

The default directory to retrieve partial templates from.

HelperManager $viewHelpers

View engine helpers.

EngineInterface|string $viewEngine

View engine. Defaults to HandlebarsEngine.

array $viewOptions

Default view rendering options.

Methods

__construct(Controller $controller)

Response constructor.

Parameters

  • Controller $controller

end()

End standard request output.

http(integer $code)

Set HTTP status code.

Parameters

  • integer $code

title(string $title)

Set the page title.

Parameters

  • string $title

content_type(string $mime = 'text/html')

Set HTTP mime type.

Parameters

  • string $mime

mime(string $mime = 'text/html')

Set HTTP mime type (copy of content_type method).

Parameters

  • string $mime

downloadable(string $filename = 'download')

Force browser to download document (content-disposition: attachment).

Parameters

  • string $filename The filename to use for the downloaded file

redirect(string $url)

Redirect user to URL.

$address also be a predefined keyword: - logout: Redirect to logout page - home: Go to homepage of current subdomain (/) - help: Go to help center

Parameters

  • string $url

cancel_standard_output()

Cancel standard (template) output.

json(array|object $data, boolean $parse_lang = true, boolean $die = true)

Respond with JSON.

Parameters

  • array|object $data Data to send as JSON
  • boolean $parse_lang Whether to parse strings between percent signs as translatable
  • boolean $die Whether to die after outputting the JSON

View|null view($template, array $data = [], array $options = [], boolean $return = false)

Output a template.

Parameters

  • $template
  • array $data
  • array $options
  • boolean $return

Return Value

viewHelper(string|array $name, callable $callable = null)

Add a Handlebars view helper.

Parameters

  • string|array $name
  • callable $callable

Inherited from ExtendableObject

final static ExtendableObject instance()

Get instance.

Return Value

final static boolean hasInstance()

Check whether there is an instance of this class available.

Return Value

  • boolean

final boolean extension($extension)

Call class method, if it exists.

Parameters

  • $extension

Return Value

  • boolean