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
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
null
string
Returns
Add a route for a GET request
get(string|\Zend\Mvc\Router\RouteInterface $route, callable $controller) : \Phlyty\Route
Parameters
$controller
callable
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
Map a route to a callback
map(string|\Zend\Mvc\Router\RouteInterface $route, callable $controller) : \Phlyty\Route
Parameters
$controller
callable
Exceptions
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
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
array
object
Returns
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
Set the request object instance
setRequest(\Zend\Http\PhpEnvironment\Request $request) : \Phlyty\App
Set the response object instance
setResponse(\Zend\Http\PhpEnvironment\Response $response) : \Phlyty\App
Set view object
setView(\Phlyty\View\ViewInterface $view) : \Phlyty\App
Set view model prototype object
setViewModelPrototype(object $model) : \Phlyty\App
Parameters
$model
object
Exceptions
Returns
Stop execution
stop() : void
Stops execution immediately, returning the response as it currently
stands.
Exceptions
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
Returns
string
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)
Register the route listener with the route event
registerRouteListener()
Determine what methods a route responds to
registerRouteMethods(\Phlyty\Route $route, int $index)
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
Returns
mixed
The last handler return value
Properties
Named routes - used to generate URLs
$namedRoutes : array
Index of route that matched
$routeIndex : null | int
Whether or not we've already registered the route listener
$routeListenerRegistered : bool
Routes by method
$routesByMethod : array
Array of method => Route[] pairs
Prototype object for view models
$viewModelPrototype : object