Overview

Namespaces

  • MvcCore
    • Ext
      • Auth
        • Virtual
      • Debug
        • Tracy
      • Form
        • Core
        • Validators
      • Request
      • Router
        • Lang
      • View
        • Helpers
  • None

Classes

  • Config
  • Controller
  • Debug
  • Model
  • Request
  • Response
  • Route
  • Router
  • Session
  • Tool
  • View
  • Overview
  • Namespace
  • Class
  • Tree

Class Controller

Application controller: - template methods: (necessary to call parent at method begin) - Init() - called after controller is created - session start - all internal variables initialized except view - PreDispatch() - called after Init, before every controller action - view initialization - internal actions: - AssetAction() - handling internal MvcCore http request to get assets from packed package - url proxy method, reading request param proxy method - view rendering or no-rendering management - http responses and redirects management - basic error responses rendering - request termination (to write and close session)

Direct known subclasses

MvcCore\Ext\Auth\Virtual\Controller

Indirect known subclasses

MvcCore\Ext\Auth\Controller
Namespace: MvcCore
Located at mvccore/src/MvcCore/Controller.php
Methods summary
public
# __construct( MvcCore\Request & $request = NULL, MvcCore\Response & $response = NULL )

Create new controller instance - always called from \MvcCore app instance before controller is dispatched. Never used in application controllers.

Create new controller instance - always called from \MvcCore app instance before controller is dispatched. Never used in application controllers.

Parameters

$request
$response
public
# Init( )

Application controllers initialization. This is best time to initialize language, locale or session.

Application controllers initialization. This is best time to initialize language, locale or session.

public
# PreDispatch( )

Application pre render common action - always used in application controllers. This is best time to define any common properties or common view properties.

Application pre render common action - always used in application controllers. This is best time to define any common properties or common view properties.

public string
# GetParam( string $name = "", string $pregReplaceAllowedChars = "a-zA-Z0-9_/\-\.\@" )

Get param value, filtered for characters defined as second argument to use them in preg_replace(). Shortcut for $this->request->GetParam();

Get param value, filtered for characters defined as second argument to use them in preg_replace(). Shortcut for $this->request->GetParam();

Parameters

$name
$pregReplaceAllowedChars

Returns

string
public MvcCore\Request &
# GetRequest( )

Get current application request object as reference.

Get current application request object as reference.

Returns

MvcCore\Request
public MvcCore\Controller
# SetRequest( MvcCore\Request & $request )

Get current application request object, rarely used.

Get current application request object, rarely used.

Parameters

$request

Returns

MvcCore\Controller
public MvcCore\View|null &
# GetView( )

Return current controller view object if any. Before PreDispatch() should be still NULL.

Return current controller view object if any. Before PreDispatch() should be still NULL.

Returns

MvcCore\View|null
public MvcCore\Controller
# SetView( MvcCore\View & $view )

Set current controller view object, rarely used.

Set current controller view object, rarely used.

Parameters

$view

Returns

MvcCore\Controller
public string
# GetLayout( )

Get layout name: 'front' | 'admin' | 'account' ...

Get layout name: 'front' | 'admin' | 'account' ...

Returns

string
public MvcCore\Controller
# SetLayout( string $layout = '' )

Set layout name

Set layout name

Parameters

$layout

Returns

MvcCore\Controller
public
# DisableView( )

Disable view rendering - always called in text or ajax responses.

Disable view rendering - always called in text or ajax responses.

public
# AssetAction( )

Return small assets content with proper headers in single file application mode

Return small assets content with proper headers in single file application mode

Throws

Exception
public
# Render( mixed $controllerName = '', mixed $actionName = '' )

Render and send prepared controller view, all sub views and controller layout view.

Render and send prepared controller view, all sub views and controller layout view.

Parameters

$controllerName
$actionName
public
# HtmlResponse( mixed $output = "" )

Send rendered html output to user.

Send rendered html output to user.

Parameters

$output
public
# JsonResponse( mixed $data = array() )

Send any php value serialized in json to user.

Send any php value serialized in json to user.

Parameters

$data
public string
# Url( string $controllerActionOrRouteName = 'Index:Index', array $params = array() )

Generates url by: - 'Controller:Action' name and params array (for routes configuration when routes array has keys with 'Controller:Action' strings and routes has not controller name and action name defined inside) - route name and params array (route name is key in routes configuration array, should be any string but routes must have information about controller name and action name inside) Result address should have two forms: - nice rewrited url by routes configuration (for apps with .htaccess supporting url_rewrite and when first param is key in routes configuration array) - for all other cases is url form: index.php?controller=ctrlName&action=actionName (when first param is not founded in routes configuration array)

Generates url by: - 'Controller:Action' name and params array (for routes configuration when routes array has keys with 'Controller:Action' strings and routes has not controller name and action name defined inside) - route name and params array (route name is key in routes configuration array, should be any string but routes must have information about controller name and action name inside) Result address should have two forms: - nice rewrited url by routes configuration (for apps with .htaccess supporting url_rewrite and when first param is key in routes configuration array) - for all other cases is url form: index.php?controller=ctrlName&action=actionName (when first param is not founded in routes configuration array)

Parameters

$controllerActionOrRouteName
Should be 'Controller:Action' combination or just any route name as custom specific string
$params
optional

Returns

string
public string
# AssetUrl( string $path = '' )

Return asset path or single file mode url

Return asset path or single file mode url

Parameters

$path

Returns

string
public
# RenderError( string $exceptionMessage = '' )

Render controller action for error or error plain text response.

Render controller action for error or error plain text response.

Parameters

$exceptionMessage
public
# RenderNotFound( )

Render not found controller action or not found plain text response.

Render not found controller action or not found plain text response.

public
# Terminate( )

Terminate request. Write session, send headers if possible and echo response body.

Terminate request. Write session, send headers if possible and echo response body.

public static
# Redirect( string $location = '', integer $code = \MvcCore\Response::SEE_OTHER )

Redirect user browser to another location.

Redirect user browser to another location.

Parameters

$location
$code
Properties summary
protected MvcCore\Request $request

Request object - parsed uri, query params, app paths...

Request object - parsed uri, query params, app paths...

#
protected MvcCore\Response $response

Response object - headers and rendered body

Response object - headers and rendered body

#
protected string $controller

Requested controller name - dashed

Requested controller name - dashed

# ''
protected string $action

Requested action name - dashed

Requested action name - dashed

# ''
protected boolean $ajax

Boolean about ajax request

Boolean about ajax request

# FALSE
protected MvcCore\View $view

Class store object for view properties

Class store object for view properties

# NULL
protected string $layout

Layout name to render html wrapper around rendered view

Layout name to render html wrapper around rendered view

# 'layout'
protected boolean $viewEnabled

Boolean about disabled or enabled view to render at last

Boolean about disabled or enabled view to render at last

# TRUE
protected static string $staticPath

Path to all static files - css, js, imgs and fonts

Path to all static files - css, js, imgs and fonts

# '/static'
protected static string $tmpPath

Path to temporary directory with generated css and js files

Path to temporary directory with generated css and js files

# '/Var/Tmp'
MvcCore API documentation generated by ApiGen