PHP Class FOF30\View\ViewTemplateFinder

Show file Open project: akeeba/fof Class Usage Examples

Protected Properties

Property Type Description
$container The container of the view, for quick reference
$defaultLayout Default layout's name (default: "default")
$defaultTpl Default subtemplate name (default: empty)
$extensions The layout template extensions to look for
$sidePrefix Which application side prefix should I use by default (site, admin, auto, any)
$strictLayout Should Should I only look for this layout or also the default layout?
$strictTpl Should I only look for the defined subtemplate or also no subtemplate?
$strictView Should I only look in the specified view (true) or also the pluralised/singularised (false)
$view The view we are attached to

Public Methods

Method Description
__construct ( View $view, array $config = [] ) Public constructor. The config array can contain the following keys extensions array defaultLayout string defaultTpl string strictView bool strictTpl bool strictLayout bool sidePrefix string For the descriptions of each key please see the same-named property of this class
addExtension ( string $extension ) : void Add an extension to the list of view template extensions
getDefaultLayout ( ) : string Returns the default layout name
getDefaultTpl ( ) : string Returns the default subtemplate name
getExtensions ( ) : array Get the list of view template extensions
getSidePrefix ( ) : string Returns the application side prefix which will be used by default in getViewTemplateUris. It can be one of: site Public front-end admin Administrator back-end auto Automatically figure out if it should be site or admin any First look in the current application side, then look on the other side of the application
getViewTemplateUris ( array $parameters ) : array Returns a list of template URIs for a specific component, view, template and sub-template. The $parameters array can have any of the following keys: component string The name of the component, e.g. com_something view string The name of the view layout string The name of the layout tpl string The name of the subtemplate strictView bool Should I only look in the specified view, or should I look in the pluralised/singularised view as well? strictLayout bool Should I only look for this layout, or also for the default layout? strictTpl bool Should I only look for this subtemplate or also for no subtemplate? sidePrefix string The application side prefix (site, admin, auto, any)
isStrictLayout ( ) : boolean Returns the "strict layout" flag. When the flag is false we will look for a view template with both the specified and the default template name in getViewTemplateUris. When true we will only look for the specified view template.
isStrictTpl ( ) : boolean Returns the "strict template" flag. When the flag is false we will look for a view template with or without the subtemplate defined in getViewTemplateUris. If it's true we will only look for the subtemplate specified.
isStrictView ( ) : boolean Returns the "strict view" flag. When the flag is false we will look for the view template in both the singularised and pluralised view. If it's true we will only look for the view template in the view specified in getViewTemplateUris.
parseTemplateUri ( string $uri = '' ) : array Parses a template URI in the form of admin:component/view/layout to an array listing the application section (admin, site), component, view and template referenced therein.
removeExtension ( string $extension ) : void Remove an extension from the list of view template extensions
resolveUriToPath ( string $uri, string $layoutTemplate = '', array $extraPaths = [] ) : string Resolves a view template URI (e.g. any:com_foobar/Items/cheese) to an absolute filesystem path (e.g. /var/www/html/administrator/components/com_foobar/View/Items/tmpl/cheese.php)
setDefaultLayout ( string $defaultLayout ) : void Sets the default layout name
setDefaultTpl ( string $defaultTpl ) Sets the default subtemplate name
setExtensions ( array $extensions ) : void Set the list of view template extensions
setSidePrefix ( string $sidePrefix ) : void Sets the application side prefix which will be used by default in getViewTemplateUris. It can be one of: site Public front-end admin Administrator back-end auto Automatically figure out if it should be site or admin any First look in the current application side, then look on the other side of the application
setStrictLayout ( boolean $strictLayout ) : void Sets the "strict layout" flag. When the flag is false we will look for a view template with both the specified and the default template name in getViewTemplateUris. When true we will only look for the specified view template.
setStrictTpl ( boolean $strictTpl ) : void Sets the "strict template" flag. When the flag is false we will look for a view template with or without the subtemplate defined in getViewTemplateUris. If it's true we will only look for the subtemplate specified.
setStrictView ( boolean $strictView ) : void Sets the "strict view" flag. When the flag is false we will look for the view template in both the singularised and pluralised view. If it's true we will only look for the view template in the view specified in getViewTemplateUris.

Method Details

__construct() public method

Public constructor. The config array can contain the following keys extensions array defaultLayout string defaultTpl string strictView bool strictTpl bool strictLayout bool sidePrefix string For the descriptions of each key please see the same-named property of this class
public __construct ( View $view, array $config = [] )
$view View The view we are attached to
$config array The configuration for this view template finder

addExtension() public method

Add an extension to the list of view template extensions
public addExtension ( string $extension ) : void
$extension string
return void

getDefaultLayout() public method

Returns the default layout name
public getDefaultLayout ( ) : string
return string

getDefaultTpl() public method

Returns the default subtemplate name
public getDefaultTpl ( ) : string
return string

getExtensions() public method

Get the list of view template extensions
public getExtensions ( ) : array
return array

getSidePrefix() public method

Returns the application side prefix which will be used by default in getViewTemplateUris. It can be one of: site Public front-end admin Administrator back-end auto Automatically figure out if it should be site or admin any First look in the current application side, then look on the other side of the application
public getSidePrefix ( ) : string
return string

getViewTemplateUris() public method

Returns a list of template URIs for a specific component, view, template and sub-template. The $parameters array can have any of the following keys: component string The name of the component, e.g. com_something view string The name of the view layout string The name of the layout tpl string The name of the subtemplate strictView bool Should I only look in the specified view, or should I look in the pluralised/singularised view as well? strictLayout bool Should I only look for this layout, or also for the default layout? strictTpl bool Should I only look for this subtemplate or also for no subtemplate? sidePrefix string The application side prefix (site, admin, auto, any)
public getViewTemplateUris ( array $parameters ) : array
$parameters array See above
return array

isStrictLayout() public method

Returns the "strict layout" flag. When the flag is false we will look for a view template with both the specified and the default template name in getViewTemplateUris. When true we will only look for the specified view template.
public isStrictLayout ( ) : boolean
return boolean

isStrictTpl() public method

Returns the "strict template" flag. When the flag is false we will look for a view template with or without the subtemplate defined in getViewTemplateUris. If it's true we will only look for the subtemplate specified.
public isStrictTpl ( ) : boolean
return boolean

isStrictView() public method

Returns the "strict view" flag. When the flag is false we will look for the view template in both the singularised and pluralised view. If it's true we will only look for the view template in the view specified in getViewTemplateUris.
public isStrictView ( ) : boolean
return boolean

parseTemplateUri() public method

Parses a template URI in the form of admin:component/view/layout to an array listing the application section (admin, site), component, view and template referenced therein.
public parseTemplateUri ( string $uri = '' ) : array
$uri string The template path to parse
return array A hash array with the parsed path parts. Keys: admin, component, view, template

removeExtension() public method

Remove an extension from the list of view template extensions
public removeExtension ( string $extension ) : void
$extension string
return void

resolveUriToPath() public method

Resolves a view template URI (e.g. any:com_foobar/Items/cheese) to an absolute filesystem path (e.g. /var/www/html/administrator/components/com_foobar/View/Items/tmpl/cheese.php)
public resolveUriToPath ( string $uri, string $layoutTemplate = '', array $extraPaths = [] ) : string
$uri string The view template URI to parse
$layoutTemplate string The layout template override of the View class
$extraPaths array Any extra lookup paths where we'll be looking for this view template
return string

setDefaultLayout() public method

Sets the default layout name
public setDefaultLayout ( string $defaultLayout ) : void
$defaultLayout string
return void

setDefaultTpl() public method

Sets the default subtemplate name
public setDefaultTpl ( string $defaultTpl )
$defaultTpl string

setExtensions() public method

Set the list of view template extensions
public setExtensions ( array $extensions ) : void
$extensions array
return void

setSidePrefix() public method

Sets the application side prefix which will be used by default in getViewTemplateUris. It can be one of: site Public front-end admin Administrator back-end auto Automatically figure out if it should be site or admin any First look in the current application side, then look on the other side of the application
public setSidePrefix ( string $sidePrefix ) : void
$sidePrefix string
return void

setStrictLayout() public method

Sets the "strict layout" flag. When the flag is false we will look for a view template with both the specified and the default template name in getViewTemplateUris. When true we will only look for the specified view template.
public setStrictLayout ( boolean $strictLayout ) : void
$strictLayout boolean
return void

setStrictTpl() public method

Sets the "strict template" flag. When the flag is false we will look for a view template with or without the subtemplate defined in getViewTemplateUris. If it's true we will only look for the subtemplate specified.
public setStrictTpl ( boolean $strictTpl ) : void
$strictTpl boolean
return void

setStrictView() public method

Sets the "strict view" flag. When the flag is false we will look for the view template in both the singularised and pluralised view. If it's true we will only look for the view template in the view specified in getViewTemplateUris.
public setStrictView ( boolean $strictView ) : void
$strictView boolean
return void

Property Details

$container protected property

The container of the view, for quick reference
protected $container

$defaultLayout protected property

Default layout's name (default: "default")
protected $defaultLayout

$defaultTpl protected property

Default subtemplate name (default: empty)
protected $defaultTpl

$extensions protected property

The layout template extensions to look for
protected $extensions

$sidePrefix protected property

Which application side prefix should I use by default (site, admin, auto, any)
protected $sidePrefix

$strictLayout protected property

Should Should I only look for this layout or also the default layout?
protected $strictLayout

$strictTpl protected property

Should I only look for the defined subtemplate or also no subtemplate?
protected $strictTpl

$strictView protected property

Should I only look in the specified view (true) or also the pluralised/singularised (false)
protected $strictView

$view protected property

The view we are attached to
protected $view