Application container

category Phlyty
package Phlyty

 Methods

Add a route for a DELETE request

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

Parameters

$controller

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

Create a flash message or retrieve the flash messages for a specific namespace

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

Parameters

$name

string

$message

nullstring

Returns

Add a route for a GET request

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

Parameters

$controller

callable

Returns

Get flash messenger instance

getFlashMessenger() : \Zend\Mvc\Controller\Plugin\FlashMessenger
Lazy instantiates one if none provided

Returns

Retrieve logger

getLog() : \Zend\Log\Logger
Lazy instantiates one if none present.

Returns

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, callable $controller) : \Phlyty\Route

Parameters

$controller

callable

Exceptions

\Phlyty\Exception\InvalidRouteException

Returns

Add a route for a OPTIONS request

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

Parameters

$controller

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

Pass execution on to next matching route

pass() 

Add a route for a PATCH request

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

Parameters

$controller

callable

Returns

Add a route for a POST request

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

Parameters

$controller

callable

Returns

Add a route for a PUT request

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

Parameters

$controller

callable

Returns

Redirect

redirect(string|\Zend\Uri\UriInterface $uri, int $status = 302) : void
Stop execution, and redirect to the provided location.

Parameters

$status

int

Exceptions

\Phlyty\Exception\HaltException

Render a template

render(string $template, array|object $viewModel = array()) : \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

Retrieve the response environment

response() : \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

Set flash messenger instance

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

Parameters

Returns

Set logger

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

Parameters

Returns

Set the request object instance

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

Parameters

Returns

Set the response object instance

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

Parameters

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 = array()) : \Zend\EventManager\ResponseCollection
Allows optionally passing more params if desired.

Parameters

$name

string

$params

array

Returns

Generates a URL based on a named route

urlFor(string $route = null, array $params = array(), array $options = array()) : 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

Prepare routes

prepareRoutes() 
Ensure no duplicate routes, determine what named routes are available, and determine which routes respond to which methods.

Register a named route

registerNamedRoute(\Phlyty\Route $route) 

Parameters

$route

\Phlyty\Route

Exceptions

\Phlyty\Exception\DuplicateRouteException if route with the same name already registered

Register the route listener with the route event

registerRouteListener() 

Determine what methods a route responds to

registerRouteMethods(\Phlyty\Route $route, int $index) 

Parameters

$route

\Phlyty\Route

$index

int

Route the request

route(\Zend\Http\PhpEnvironment\Request $request, string $method) : mixed
Attempts to match a route. If matched, sets $params and $routeIndex. Otherwise, throws an Exception\PageNotFoundException.

Parameters

$method

string

Exceptions

\Phlyty\Exception\PageNotFoundException

Returns

mixedThe last handler return value

 Properties

 

Event manager instance

$events : \Zend\EventManager\EventManagerInterface

Default

 

Flash messenger instance

$flashMessenger : \Zend\Mvc\Controller\Plugin\FlashMessenger

Default

 

Logger

$log : \Zend\Log\Logger

Default

By default, has no writers attached
 

Named routes - used to generate URLs

$namedRoutes : array

Default

array()
 

Parameters returned as the result of a route match

$params : null | \Zend\Mvc\Router\RouteMatch

Default

 

Request environment

$request : \Zend\Http\PhpEnvironment\Request

Default

 

Response environment

$response : \Zend\Http\PhpEnvironment\Response

Default

 

Index of route that matched

$routeIndex : null | int

Default

-1
 

Whether or not we've already registered the route listener

$routeListenerRegistered : bool

Default

false
 

Routes

$routes : \Phlyty\Route[]

Default

array()
 

Routes by method

$routesByMethod : array

Default

array()
Array of method => Route[] pairs
 

View

$view : \Phlyty\View\ViewInterface

Default

 

Prototype object for view models

$viewModelPrototype : object

Default