Elgg  Version 3.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Elgg\ViewsService Class Reference

WARNING: API IN FLUX. More...

Public Member Functions

 __construct (PluginHooksService $hooks, LoggerInterface $logger, HttpRequest $request=null)
 Constructor. More...
 
 setViewtype ($viewtype= '')
 Set the viewtype. More...
 
 getViewtype ()
 Get the viewtype. More...
 
 clampViewtypeToPopulatedViews ()
 If the current viewtype has no views, reset it to "default". More...
 
 isValidViewtype ($viewtype)
 Checks if $viewtype is a string suitable for use as a viewtype name. More...
 
 autoregisterViews ($view_base, $folder, $viewtype)
 Auto-registers views from a location. More...
 
 findViewFile ($view, $viewtype)
 Find the view file. More...
 
 setViewDir ($view, $location, $viewtype= '')
 Set an alternative base location for a view. More...
 
 registerViewtypeFallback ($viewtype)
 Register a viewtype to fall back to a default view if a view isn't found for that viewtype. More...
 
 doesViewtypeFallback ($viewtype)
 Checks if a viewtype falls back to default. More...
 
 renderDeprecatedView ($view, array $vars, $suggestion, $version)
 Display a view with a deprecation notice. More...
 
 getViewList ($view)
 Get the views, including extensions, used to render a view. More...
 
 renderView ($view, array $vars=[], $viewtype= '', $issue_missing_notice=true, array $extensions_tree=[])
 Renders a view. More...
 
 viewExists ($view, $viewtype= '', $recurse=true)
 Returns whether the specified view exists. More...
 
 extendView ($view, $view_extension, $priority=501)
 Extends a view with another view. More...
 
 viewIsExtended ($view)
 Is the given view extended? More...
 
 viewHasHookHandlers ($view)
 Do hook handlers exist to modify the view? More...
 
 unextendView ($view, $view_extension)
 Unextends a view. More...
 
 registerCacheableView ($view)
 Register a view a cacheable. More...
 
 isCacheableView ($view)
 Is the view cacheable. More...
 
 registerPluginViews ($path, &$failed_dir= '')
 Register a plugin's views. More...
 
 mergeViewsSpec (array $spec)
 Merge a specification of absolute view paths. More...
 
 listViews ($viewtype= 'default')
 List all views in a viewtype. More...
 
 getInspectorData ()
 Get inspector data. More...
 
 configureFromCache (SystemCache $cache)
 Configure locations from the cache. More...
 
 cacheConfiguration (SystemCache $cache)
 Cache the configuration. More...
 

Static Public Member Functions

static canonicalizeViewName ($alias)
 Takes a view name and returns the canonical name for that view. More...
 

Public Attributes

const VIEW_HOOK = 'view'
 
const VIEW_VARS_HOOK = 'view_vars'
 
const OUTPUT_KEY = '__view_output'
 
const BASE_VIEW_PRIORITY = 500
 

Protected Member Functions

 fileExists ($path)
 Wrapper for file_exists() that caches false results (the stat cache only caches true results). More...
 

Protected Attributes

 $file_exists_cache = []
 

Detailed Description

WARNING: API IN FLUX.

DO NOT USE DIRECTLY.

Use the elgg_* versions instead.

Definition at line 19 of file ViewsService.php.

Constructor & Destructor Documentation

Elgg\ViewsService::__construct ( PluginHooksService  $hooks,
LoggerInterface  $logger,
HttpRequest  $request = null 
)

Constructor.

Parameters
PluginHooksService$hooksThe hooks service
LoggerInterface$loggerLogger
\Elgg\Http\Request$requestHttp Request

Definition at line 94 of file ViewsService.php.

Member Function Documentation

Elgg\ViewsService::autoregisterViews (   $view_base,
  $folder,
  $viewtype 
)

Auto-registers views from a location.

Parameters
string$view_baseOptional The base of the view name without the view type.
string$folderRequired The folder to begin looking in
string$viewtypeThe type of view we're looking at (default, rss, etc)
Returns
bool returns false if folder can't be read
See also
autoregister_views()

Definition at line 230 of file ViewsService.php.

Elgg\ViewsService::cacheConfiguration ( SystemCache  $cache)

Cache the configuration.

Parameters
SystemCache$cacheThe system cache
Returns
void

Definition at line 848 of file ViewsService.php.

static Elgg\ViewsService::canonicalizeViewName (   $alias)
static

Takes a view name and returns the canonical name for that view.

Parameters
string$aliasThe possibly non-canonical view name.
Returns
string The canonical view name.

Definition at line 194 of file ViewsService.php.

Elgg\ViewsService::clampViewtypeToPopulatedViews ( )

If the current viewtype has no views, reset it to "default".

Returns
void

Definition at line 140 of file ViewsService.php.

Elgg\ViewsService::configureFromCache ( SystemCache  $cache)

Configure locations from the cache.

Parameters
SystemCache$cacheThe system cache
Returns
bool

Definition at line 825 of file ViewsService.php.

Elgg\ViewsService::doesViewtypeFallback (   $viewtype)

Checks if a viewtype falls back to default.

Parameters
string$viewtypeViewtype
Returns
bool
See also
elgg_does_viewtype_fallback()

Definition at line 334 of file ViewsService.php.

Elgg\ViewsService::extendView (   $view,
  $view_extension,
  $priority = 501 
)

Extends a view with another view.

Parameters
string$viewThe view to extend.
string$view_extensionThis view is added to $view
int$priorityThe priority, from 0 to 1000, to add at (lowest numbers displayed first)
Returns
void
See also
elgg_extend_view()

Definition at line 580 of file ViewsService.php.

Elgg\ViewsService::fileExists (   $path)
protected

Wrapper for file_exists() that caches false results (the stat cache only caches true results).

This saves us from many unneeded file stat calls when a common view uses a fallback.

Parameters
string$pathPath to the file
Returns
bool

Definition at line 475 of file ViewsService.php.

Elgg\ViewsService::findViewFile (   $view,
  $viewtype 
)

Find the view file.

Parameters
string$viewView name
string$viewtypeViewtype
Returns
string Empty string if not found

Definition at line 271 of file ViewsService.php.

Elgg\ViewsService::getInspectorData ( )

Get inspector data.

Returns
array

Definition at line 800 of file ViewsService.php.

Elgg\ViewsService::getViewList (   $view)

Get the views, including extensions, used to render a view.

Keys returned are view priorities. View existence is not checked.

Parameters
string$viewView name
Returns
string[]

Definition at line 370 of file ViewsService.php.

Elgg\ViewsService::getViewtype ( )

Get the viewtype.

Returns
string

Definition at line 127 of file ViewsService.php.

Elgg\ViewsService::isCacheableView (   $view)

Is the view cacheable.

Parameters
string$viewthe view name
Returns
bool

Definition at line 675 of file ViewsService.php.

Elgg\ViewsService::isValidViewtype (   $viewtype)

Checks if $viewtype is a string suitable for use as a viewtype name.

Parameters
string$viewtypePotential viewtype name. Alphanumeric chars plus _ allowed.
Returns
bool

Definition at line 175 of file ViewsService.php.

Elgg\ViewsService::listViews (   $viewtype = 'default')

List all views in a viewtype.

Parameters
string$viewtypeViewtype
Returns
string[]

Definition at line 787 of file ViewsService.php.

Elgg\ViewsService::mergeViewsSpec ( array  $spec)

Merge a specification of absolute view paths.

Parameters
array$specSpecification viewtype => [ view_name => path or array of paths ]
Returns
void

Definition at line 754 of file ViewsService.php.

Elgg\ViewsService::registerCacheableView (   $view)

Register a view a cacheable.

Parameters
string$viewthe view name
Returns
void

Definition at line 662 of file ViewsService.php.

Elgg\ViewsService::registerPluginViews (   $path,
$failed_dir = '' 
)

Register a plugin's views.

Parameters
string$pathBase path of the plugin
string$failed_dirThis var is set to the failed directory if registration fails
Returns
bool

Definition at line 712 of file ViewsService.php.

Elgg\ViewsService::registerViewtypeFallback (   $viewtype)

Register a viewtype to fall back to a default view if a view isn't found for that viewtype.

Parameters
string$viewtypeThe viewtype to register
Returns
void
See also
elgg_register_viewtype_fallback()

Definition at line 321 of file ViewsService.php.

Elgg\ViewsService::renderDeprecatedView (   $view,
array  $vars,
  $suggestion,
  $version 
)

Display a view with a deprecation notice.

No missing view NOTICE is logged

Parameters
string$viewThe name and location of the view to use
array$varsVariables to pass to the view
string$suggestionSuggestion with the deprecation message
string$versionHuman-readable release version: 1.7, 1.8, ...
Returns
string The parsed view
See also
elgg_view()

Definition at line 350 of file ViewsService.php.

Elgg\ViewsService::renderView (   $view,
array  $vars = [],
  $viewtype = '',
  $issue_missing_notice = true,
array  $extensions_tree = [] 
)

Renders a view.

Parameters
string$viewName of the view
array$varsVariables to pass to the view
string$viewtypeViewtype to use
bool$issue_missing_noticeShould a missing notice be issued
array$extensions_treeArray of views that are before the current view in the extension path
Returns
string
See also
elgg_view()

Definition at line 391 of file ViewsService.php.

Elgg\ViewsService::setViewDir (   $view,
  $location,
  $viewtype = '' 
)

Set an alternative base location for a view.

Parameters
string$viewName of the view
string$locationFull path to the view file
string$viewtypeThe viewtype to register this under
Returns
void
See also
elgg_set_view_location()

Definition at line 295 of file ViewsService.php.

Elgg\ViewsService::setViewtype (   $viewtype = '')

Set the viewtype.

Parameters
string$viewtypeViewtype
Returns
bool

Definition at line 107 of file ViewsService.php.

Elgg\ViewsService::unextendView (   $view,
  $view_extension 
)

Unextends a view.

Parameters
string$viewThe view that was extended.
string$view_extensionThis view that was added to $view
Returns
bool
See also
elgg_unextend_view()

Definition at line 634 of file ViewsService.php.

Elgg\ViewsService::viewExists (   $view,
  $viewtype = '',
  $recurse = true 
)

Returns whether the specified view exists.

Parameters
string$viewThe view name
string$viewtypeIf set, forces the viewtype
bool$recurseIf false, do not check extensions
Returns
bool
See also
elgg_view_exists()

Definition at line 531 of file ViewsService.php.

Elgg\ViewsService::viewHasHookHandlers (   $view)

Do hook handlers exist to modify the view?

Parameters
string$viewView name
Returns
bool

Definition at line 620 of file ViewsService.php.

Elgg\ViewsService::viewIsExtended (   $view)

Is the given view extended?

Parameters
string$viewView name
Returns
bool

Definition at line 609 of file ViewsService.php.

Member Data Documentation

Elgg\ViewsService::$file_exists_cache = []
protected

Definition at line 32 of file ViewsService.php.

const Elgg\ViewsService::BASE_VIEW_PRIORITY = 500

Definition at line 26 of file ViewsService.php.

const Elgg\ViewsService::OUTPUT_KEY = '__view_output'

Definition at line 25 of file ViewsService.php.

const Elgg\ViewsService::VIEW_HOOK = 'view'

Definition at line 23 of file ViewsService.php.

const Elgg\ViewsService::VIEW_VARS_HOOK = 'view_vars'

Definition at line 24 of file ViewsService.php.


The documentation for this class was generated from the following file: