Application container

category Phlyty
package Phlyty

 Methods

Add a route for a DELETE request

delete(string | \Zend\Mvc\Router\RouteInterface $route, \Phlyty\callable $controller) : \Phlyty\Route

Parameters

$route

string\Zend\Mvc\Router\RouteInterface

$controller

\Phlyty\callable

Returns

Create and return an application event instance

event() : \Phlyty\AppEvent

Sets the target to the App object instance, and, if a route has been matched, adds it to the instance.

Returns

Retrieve event manager instance

events() : \Zend\EventManager\EventManagerInterface

If not present, lazy-loads and registers one.

Returns

\Zend\EventManager\EventManagerInterface

Create or retrieve a flash message

flash(string $name, null | string $message) : \Phlyty\App | string

Parameters

$name

string

$message

nullstring

Returns

\Phlyty\Appstring

Add a route for a GET request

get(string | \Zend\Mvc\Router\RouteInterface $route, \Phlyty\callable $controller) : \Phlyty\Route

Parameters

$route

string\Zend\Mvc\Router\RouteInterface

$controller

\Phlyty\callable

Returns

Get flash messenger instance

getFlashMessenger() : \Zend\Mvc\Controller\Plugin\FlashMessenger

Lazy instantiates one if none provided

Returns

\Zend\Mvc\Controller\Plugin\FlashMessenger

Retrieve logger

getLog() : \Zend\Log\Logger

Lazy instantiates one if none present.

Returns

\Zend\Log\Logger

Halt execution

halt(int $status, string $message) : void

Halts execution, and sets the response status code to $status, as well as sets the response body to the provided message (if any). Any previous content in the response body will be overwritten.

Parameters

$status

int

HTTP response status

$message

string

HTTP response body

Exceptions

\Phlyty\Exception\HaltException

Map a route to a callback

map(string | \Zend\Mvc\Router\RouteInterface $route, \Phlyty\callable $controller) : \Phlyty\Route

Parameters

$route

string\Zend\Mvc\Router\RouteInterface

$controller

\Phlyty\callable

Exceptions

\Phlyty\Exception\InvalidRouteException

Returns

Add a route for a OPTIONS request

options(string | \Zend\Mvc\Router\RouteInterface $route, \Phlyty\callable $controller) : \Phlyty\Route

Parameters

$route

string\Zend\Mvc\Router\RouteInterface

$controller

\Phlyty\callable

Returns

Return the route match parameters

params() : \Zend\Mvc\Router\RouteMatch

If none has been set yet, lazy instantiates an empty Router\RouteMatch container.

Returns

\Zend\Mvc\Router\RouteMatch

Pass execution on to next matching route

pass() 

Add a route for a PATCH request

patch(string | \Zend\Mvc\Router\RouteInterface $route, \Phlyty\callable $controller) : \Phlyty\Route

Parameters

$route

string\Zend\Mvc\Router\RouteInterface

$controller

\Phlyty\callable

Returns

Add a route for a POST request

post(string | \Zend\Mvc\Router\RouteInterface $route, \Phlyty\callable $controller) : \Phlyty\Route

Parameters

$route

string\Zend\Mvc\Router\RouteInterface

$controller

\Phlyty\callable

Returns

Add a route for a PUT request

put(string | \Zend\Mvc\Router\RouteInterface $route, \Phlyty\callable $controller) : \Phlyty\Route

Parameters

$route

string\Zend\Mvc\Router\RouteInterface

$controller

\Phlyty\callable

Returns

Redirect

redirect(string | \Zend\Uri\UriInterface $uri, int $status) : void

Stop execution, and redirect to the provided location.

Parameters

$uri

string\Zend\Uri\UriInterface

$status

int

Exceptions

\Phlyty\Exception\HaltException

Render a template

render(string $template, array | object $viewModel) : \Phlyty\App

Renders a template, with any view model provided, and injects the content into the response object.

Parameters

$template

string

$viewModel

arrayobject

Returns

Retrieve the request environment

request() : \Zend\Http\PhpEnvironment\Request

Returns

\Zend\Http\PhpEnvironment\Request

Retrieve the response environment

response() : \Zend\Http\PhpEnvironment\Response

Returns

\Zend\Http\PhpEnvironment\Response

Run the application

run() 

triggers begin
triggers route
triggers halt
triggers 404
triggers 501
triggers 500
triggers finish

Set the event manager instance

setEventManager(\Zend\EventManager\EventManagerInterface $events) : \Phlyty\App

Parameters

$events

\Zend\EventManager\EventManagerInterface

Returns

Set flash messenger instance

setFlashMessenger(\Zend\Mvc\Controller\Plugin\FlashMessenger $flashMessenger) : \Phlyty\App

Parameters

$flashMessenger

\Zend\Mvc\Controller\Plugin\FlashMessenger

Returns

Set logger

setLog(\Zend\Log\Logger $log) : \Phlyty\App

Parameters

$log

\Zend\Log\Logger

Returns

Set the request object instance

setRequest(\Zend\Http\PhpEnvironment\Request $request) : \Phlyty\App

Parameters

$request

\Zend\Http\PhpEnvironment\Request

Returns

Set the response object instance

setResponse(\Zend\Http\PhpEnvironment\Response $response) : \Phlyty\App

Parameters

$response

\Zend\Http\PhpEnvironment\Response

Returns

Set view object

setView(\Phlyty\View\ViewInterface $view) : \Phlyty\App

Parameters

Returns

Set view model prototype object

setViewModelPrototype(object $model) : \Phlyty\App

Parameters

$model

object

Exceptions

\Phlyty\Exception\InvalidViewModelException

Returns

Stop execution

stop() : void

Stops execution immediately, returning the response as it currently stands.

Exceptions

\Phlyty\Exception\HaltException

Trigger a named event

trigger(string $name, array $params) : \Zend\EventManager\ResponseCollection

Allows optionally passing more params if desired.

Parameters

$name

string

$params

array

Returns

\Zend\EventManager\ResponseCollection

Generates a URL based on a named route

urlFor(string $route, array $params, array $options) : string

Parameters

$route

string

Named Route instance

$params

array

Parameters to use in url generation, if any

$options

array

Router\RouteInterface-specific options to use in url generation, if any

Exceptions

\Phlyty\Exception\InvalidRouteException

Returns

string

Retrieve view instance

view() : \Phlyty\View\ViewInterface

If none present, lazy-loads View\MustacheView instance.

Returns

Retrieve a view model instance

viewModel() : object

Always returns a new view model instance, cloned from the instance in $viewModelPrototype. If no prototype exists, creates one from View\MustacheViewModel.

Returns

object