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 View

Core view: - static doctype storage - static storage for dir names with view scripts - possible to use for any controller/subcontroller/control/\MvcCore\Ext\Form - view prerender preparing and rendering - direct code evaluation - view helpers management - creating by predefined class names bases - instance storing and calling - views sub scripts relative path solving - Url() proxy method, AssetUrl() proxy method - magic calls: - __call() - helpers handling - __set() - to set anything in controller to get it back in view - __get() - to get anything in view previously completed in controller - no special view language implemented... why to use such stupid things...

Direct known subclasses

MvcCore\Ext\Form\Core\View
Namespace: MvcCore
Located at mvccore/src/MvcCore/View.php
Methods summary
public static
# StaticInit( )

Static initialization - complete static::$HelpersClassBases by app configuration.

Static initialization - complete static::$HelpersClassBases by app configuration.

public static
# AddHelpersClassBases( )

Add view helpers class base name(s), example: \MvcCore\View::AddHelpersClassBases('\Any\Other\ViewHelpers\Place\', '...');

Add view helpers class base name(s), example: \MvcCore\View::AddHelpersClassBases('\Any\Other\ViewHelpers\Place\', '...');

public static string
# GetViewScriptFullPath( string $typePath = '', string $corectedRelativePath = '' )

Get view script full path

Get view script full path

Parameters

$typePath
$corectedRelativePath

Returns

string
public
# __construct( MvcCore\Controller & $controller )

Create new view instance.

Create new view instance.

Parameters

$controller
public
# SetUp( mixed & $paramsInstance )

Set up all keys/fields/properties in given array/stdclass/instance into current view context.

Set up all keys/fields/properties in given array/stdclass/instance into current view context.

Parameters

$paramsInstance
public string
# GetContent( )

Return rendered controller/action template content.

Return rendered controller/action template content.

Returns

string
public MvcCore\Controller
# GetController( )

Return controller instance.

Return controller instance.

Returns

MvcCore\Controller
public string
# RenderScript( string $relativePath = '' )

Render controller/action template script and return it's result.

Render controller/action template script and return it's result.

Parameters

$relativePath

Returns

string
public string
# RenderLayout( string $relativePath = '' )

Render layout template script and return it's result.

Render layout template script and return it's result.

Parameters

$relativePath

Returns

string
public string
# RenderLayoutAndContent( string $relativePath = '', string $content = '' )

Render layout template script and return it's result with inner rendered content.

Render layout template script and return it's result with inner rendered content.

Parameters

$relativePath
$relativePatht.
$content

Returns

string
public string
# Render( string $typePath = '', string $relativePath = '' )

Render controller template and all necessary layout templates and return rendered result.

Render controller template and all necessary layout templates and return rendered result.

Parameters

$typePath
$relativePath

Returns

string

Throws

Exception
public string
# Evaluate( string $content = '' )

Evaluate given code as PHP in current view context, any $this keyword will be used as view context.

Evaluate given code as PHP in current view context, any $this keyword will be used as view context.

Parameters

$content

Returns

string
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 = '' )

Get asset url - proxy method into \MvcCore\Controller::AssetUrl();

Get asset url - proxy method into \MvcCore\Controller::AssetUrl();

Parameters

$path

Returns

string
public
# __set( string $name, mixed $value )

Set any value into view context except system keys declared in static::$originalyDeclaredProperties.

Set any value into view context except system keys declared in static::$originalyDeclaredProperties.

Parameters

$name
$value

Throws

Exception
public string|mixed
# __call( string $method, mixed $arguments )

Try to call view helper. If view helper doesn't exist in global helpers store - create new helper instance. If helper already exists in global helpers store - do not create it again - use instance from store. Then call it's public method named in the same way as helper and return result as it is without any conversion! So then there could be called any other helper method if helper instance was returned.

Try to call view helper. If view helper doesn't exist in global helpers store - create new helper instance. If helper already exists in global helpers store - do not create it again - use instance from store. Then call it's public method named in the same way as helper and return result as it is without any conversion! So then there could be called any other helper method if helper instance was returned.

Parameters

$method
$arguments

Returns

string|mixed
Constants summary
string DOCTYPE_HTML4

View output document type HTML4

View output document type HTML4

# 'HTML4'
string DOCTYPE_XHTML

View output document type XHTML

View output document type XHTML

# 'XHTML'
string DOCTYPE_HTML5

View output document type HTML5

View output document type HTML5

# 'HTML5'
string EXTENSION

View script files extenion in Views application directory

View script files extenion in Views application directory

# '.phtml'
Properties summary
public static string $Doctype

Document type (HTML, XHTML or anything you desire)

Document type (HTML, XHTML or anything you desire)

# self::DOCTYPE_HTML5
public static string $ScriptsDir

Controller action templates directory placed in '/App/Views' dir. For read & write.

Controller action templates directory placed in '/App/Views' dir. For read & write.

# 'Scripts'
public static string $HelpersDir

views helpers directory placed in '/App/Views' dir. For read & write.

views helpers directory placed in '/App/Views' dir. For read & write.

# 'Helpers'
public static string $LayoutsDir

Layout templates directory placed in '/App/Views' dir. For read & write.

Layout templates directory placed in '/App/Views' dir. For read & write.

# 'Layouts'
public static array $HelpersClassBases

Helpers classes - base class names. For read & write.

Helpers classes - base class names. For read & write.

# array(/*'\MvcCore\Ext\View\Helpers\'*/)
public MvcCore\Controller|mixed $Controller

Rendered content

Rendered content

#
protected static string $originalyDeclaredProperties

Originaly declared dynamic properties to protect from __set() magic method

Originaly declared dynamic properties to protect from __set() magic method

# array( 'Controller' => 1, '_content' => 1, '_renderedFullPaths'=> 1, )
MvcCore API documentation generated by ApiGen