PHP Class Elgg\ViewsService

Use the elgg_* versions instead.
Since: 1.9.0
Show file Open project: elgg/elgg Class Usage Examples

Public Properties

Property Type Description
$view_path Absolute path of the views directory

Protected Properties

Property Type Description
$file_exists_cache array

Public Methods

Method Description
__construct ( PluginHooksService $hooks, Logger $logger ) Constructor
autoregisterViews ( $view_base, $folder, $viewtype )
cacheConfiguration ( SystemCache $cache ) : void Cache the configuration
canonicalizeViewName ( string $alias ) : string Takes a view name and returns the canonical name for that view.
configureFromCache ( SystemCache $cache ) : boolean Configure locations from the cache
doesViewtypeFallback ( $viewtype )
extendView ( $view, $view_extension, $priority = 501 )
findViewFile ( string $view, string $viewtype ) : string Find the view file
getInspectorData ( ) : array Get inspector data
getViewList ( string $view ) : string[] Get the views, including extensions, used to render a view
isCacheableView ( $view )
listViews ( string $viewtype = 'default' ) : string[] List all views in a viewtype
mergeViewsSpec ( array $spec ) Merge a specification of absolute view paths
registerCacheableView ( $view )
registerPluginViews ( string $path, string &$failed_dir = '' ) : boolean Register a plugin's views
registerViewtypeFallback ( $viewtype )
renderDeprecatedView ( string $view, array $vars, string $suggestion, string $version ) : string Display a view with a deprecation notice. No missing view NOTICE is logged
renderView ( $view, array $vars = [], $ignored = false, $viewtype = '', $issue_missing_notice = true )
setViewDir ( string $view, string $location, string $viewtype = '' )
unextendView ( $view, $view_extension )
viewExists ( $view, $viewtype = '', $recurse = true )
viewHasHookHandlers ( string $view ) : boolean Do hook handlers exist to modify the view?
viewIsExtended ( string $view ) : boolean Is the given view extended?

Protected Methods

Method Description
fileExists ( string $path ) : boolean Wrapper for file_exists() that caches false results (the stat cache only caches true results).

Private Methods

Method Description
renderViewFile ( string $view, array $vars, string $viewtype, boolean $issue_missing_notice ) : string | false Includes view PHP or static file
setViewLocation ( string $view, string $viewtype, string $path ) : void Update the location of a view file

Method Details

__construct() public method

Constructor
public __construct ( PluginHooksService $hooks, Logger $logger )
$hooks PluginHooksService The hooks service
$logger Logger Logger

autoregisterViews() public method

public autoregisterViews ( $view_base, $folder, $viewtype )

cacheConfiguration() public method

Cache the configuration
public cacheConfiguration ( SystemCache $cache ) : void
$cache Elgg\Cache\SystemCache The system cache
return void

canonicalizeViewName() public method

Takes a view name and returns the canonical name for that view.
public canonicalizeViewName ( string $alias ) : string
$alias string The possibly non-canonical view name.
return string The canonical view name.

configureFromCache() public method

Configure locations from the cache
public configureFromCache ( SystemCache $cache ) : boolean
$cache Elgg\Cache\SystemCache The system cache
return boolean

doesViewtypeFallback() public method

public doesViewtypeFallback ( $viewtype )

extendView() public method

public extendView ( $view, $view_extension, $priority = 501 )

fileExists() protected method

This saves us from many unneeded file stat calls when a common view uses a fallback.
protected fileExists ( string $path ) : boolean
$path string Path to the file
return boolean

findViewFile() public method

Find the view file
public findViewFile ( string $view, string $viewtype ) : string
$view string View name
$viewtype string Viewtype
return string Empty string if not found

getInspectorData() public method

Get inspector data
public getInspectorData ( ) : array
return array

getViewList() public method

Keys returned are view priorities. View existence is not checked.
public getViewList ( string $view ) : string[]
$view string View name
return string[]

isCacheableView() public method

public isCacheableView ( $view )

listViews() public method

List all views in a viewtype
public listViews ( string $viewtype = 'default' ) : string[]
$viewtype string Viewtype
return string[]

mergeViewsSpec() public method

Merge a specification of absolute view paths
public mergeViewsSpec ( array $spec )
$spec array Specification viewtype => [ view_name => path or array of paths ]

registerCacheableView() public method

public registerCacheableView ( $view )

registerPluginViews() public method

Register a plugin's views
public registerPluginViews ( string $path, string &$failed_dir = '' ) : boolean
$path string Base path of the plugin
$failed_dir string This var is set to the failed directory if registration fails
return boolean

registerViewtypeFallback() public method

public registerViewtypeFallback ( $viewtype )

renderDeprecatedView() public method

Display a view with a deprecation notice. No missing view NOTICE is logged
See also: elgg_view()
public renderDeprecatedView ( string $view, array $vars, string $suggestion, string $version ) : string
$view string The name and location of the view to use
$vars array Variables to pass to the view
$suggestion string Suggestion with the deprecation message
$version string Human-readable *release* version: 1.7, 1.8, ...
return string The parsed view

renderView() public method

public renderView ( $view, array $vars = [], $ignored = false, $viewtype = '', $issue_missing_notice = true )
$vars array

setViewDir() public method

public setViewDir ( string $view, string $location, string $viewtype = '' )
$view string Name of the view
$location string Full path to the view file
$viewtype string The viewtype to register this under

unextendView() public method

public unextendView ( $view, $view_extension )

viewExists() public method

public viewExists ( $view, $viewtype = '', $recurse = true )

viewHasHookHandlers() public method

Do hook handlers exist to modify the view?
public viewHasHookHandlers ( string $view ) : boolean
$view string View name
return boolean

viewIsExtended() public method

Is the given view extended?
public viewIsExtended ( string $view ) : boolean
$view string View name
return boolean

Property Details

$file_exists_cache protected property

See also: fileExists
protected array $file_exists_cache
return array

$view_path public property

Absolute path of the views directory
public $view_path