ViewService
extends Service
in package
Table of Contents
- BEFORE_RENDERING_BLOCK = 'before_rendering_block'
- BEFORE_RENDERING_FIELD = 'before_rendering_field'
- BEFORE_RENDERING_FILE = 'before_rendering_file'
- BEFORE_RENDERING_GROUP = 'before_rendering_group'
- BEFORE_RENDERING_LAYOUT = 'before_rendering_layout'
- BEFORE_RENDERING_REGION = 'before_rendering_region'
- TEMPLATE_CACHE_TAG = 'themes::templates'
- $cache : CacheInterface
- $eagerLoad : bool
- $eagerLoaded : array<string|int, mixed>
- $templateCacheEnabled : bool
- $_devMode : bool
- $_renderingBlock : string|null
- Rendering layout mode
- $_renderingElement : Element|null
- Element being rendered
- $_renderingLayout : LayoutInterface|null
- Layout being rendered
- $_renderingMode : string|null
- Rendering layout mode
- $_renderingRegion : Region|null
- Region being rendered
- $_renderingViewMode : ViewModeInterface|null
- View mode being rendered
- $pageVariables : array<string|int, mixed>
- Variables originally passed to the page
- beforeRenderPage() : mixed
- Handle current page rendering.
- flushTemplateCache() : mixed
- Flush template cache
- getRenderingBlock() : ViewModeInterface|null
- Get the current rendering block
- getRenderingElement() : Element|null
- Get the current rendering element
- getRenderingLayout() : LayoutInterface|null
- Get the current rendering layout
- getRenderingMode() : string|null
- Get the current rendering layout mode
- getRenderingRegion() : RegionInterface|null
- Get the current rendering region
- getRenderingViewMode() : ViewModeInterface|null
- Get the current rendering view mode
- init() : void
- renderBlock() : string
- Renders a block
- renderField() : string
- Renders a field
- renderFile() : string
- Renders an asset file
- renderGroup() : string
- Renders a group
- renderLayout() : string
- Renders a layout for a view mode and an element
- renderRegion() : string
- Renders a region
- blockCacheService() : BlockCacheService
- Get the block cache service
- blockProviderService() : BlockProvidersService
- Get the block providers service
- blocksService() : BlockService
- Get the blocks service
- displayService() : DisplayService
- Get the display service
- eagerLoadingService() : EagerLoadingService
- Get the eager loading service
- fieldDisplayersService() : FieldDisplayerService
- Get the field displayers service
- fieldsService() : FieldsService
- Get the fields service
- fileDisplayerService() : FileDisplayerService
- Get the file displayers service
- getDevMode() : bool
- Are we in dev mode ?
- getDevModeHtml() : string
- Get the dev mode html
- getPageVariables() : array<string|int, mixed>
- Add the page variables and the themes variables to an array
- groupsService() : GroupsService
- Get the groups service
- layoutService() : LayoutService
- Get the layout service
- matrixService() : MatrixService
- Get the matrix service
- render() : string
- Renders an array of templates
- resolveTemplate() : string
- Resolves a template from an array of templates
- resolveTemplateFromCache() : string
- Resolves a template from cache
- themesRegistry() : ThemesRegistry
- Get the themes registry
- triggerEvent() : mixed
- Triggers an event
- triggerRenderingEvent() : Event
- Triggers an event
- viewModesService() : ViewModeService
- Get the view mode service
- viewService() : ViewService
- Get the view service
Constants
BEFORE_RENDERING_BLOCK
public
mixed
BEFORE_RENDERING_BLOCK
= 'before_rendering_block'
BEFORE_RENDERING_FIELD
public
mixed
BEFORE_RENDERING_FIELD
= 'before_rendering_field'
BEFORE_RENDERING_FILE
public
mixed
BEFORE_RENDERING_FILE
= 'before_rendering_file'
BEFORE_RENDERING_GROUP
public
mixed
BEFORE_RENDERING_GROUP
= 'before_rendering_group'
BEFORE_RENDERING_LAYOUT
public
mixed
BEFORE_RENDERING_LAYOUT
= 'before_rendering_layout'
BEFORE_RENDERING_REGION
public
mixed
BEFORE_RENDERING_REGION
= 'before_rendering_region'
TEMPLATE_CACHE_TAG
public
mixed
TEMPLATE_CACHE_TAG
= 'themes::templates'
Properties
$cache
public
CacheInterface
$cache
$eagerLoad
public
bool
$eagerLoad
$eagerLoaded
public
array<string|int, mixed>
$eagerLoaded
= []
$templateCacheEnabled
public
bool
$templateCacheEnabled
$_devMode
protected
bool
$_devMode
$_renderingBlock
Rendering layout mode
protected
string|null
$_renderingBlock
$_renderingElement
Element being rendered
protected
Element|null
$_renderingElement
$_renderingLayout
Layout being rendered
protected
LayoutInterface|null
$_renderingLayout
$_renderingMode
Rendering layout mode
protected
string|null
$_renderingMode
$_renderingRegion
Region being rendered
protected
Region|null
$_renderingRegion
$_renderingViewMode
View mode being rendered
protected
ViewModeInterface|null
$_renderingViewMode
$pageVariables
Variables originally passed to the page
protected
array<string|int, mixed>
$pageVariables
= []
Methods
beforeRenderPage()
Handle current page rendering.
public
beforeRenderPage(TemplateEvent $event) : mixed
If a theme is set then we'll look for the theme layout for that request and add it to the template variables.
Parameters
- $event : TemplateEvent
Return values
mixed —flushTemplateCache()
Flush template cache
public
flushTemplateCache() : mixed
Return values
mixed —getRenderingBlock()
Get the current rendering block
public
getRenderingBlock() : ViewModeInterface|null
Return values
ViewModeInterface|null —getRenderingElement()
Get the current rendering element
public
getRenderingElement() : Element|null
Return values
Element|null —getRenderingLayout()
Get the current rendering layout
public
getRenderingLayout() : LayoutInterface|null
Return values
LayoutInterface|null —getRenderingMode()
Get the current rendering layout mode
public
getRenderingMode() : string|null
Return values
string|null —getRenderingRegion()
Get the current rendering region
public
getRenderingRegion() : RegionInterface|null
Return values
RegionInterface|null —getRenderingViewMode()
Get the current rendering view mode
public
getRenderingViewMode() : ViewModeInterface|null
Return values
ViewModeInterface|null —init()
public
init() : void
Tags
Return values
void —renderBlock()
Renders a block
public
renderBlock(BlockInterface $block) : string
Parameters
- $block : BlockInterface
Return values
string —renderField()
Renders a field
public
renderField(FieldInterface $field, mixed $value) : string
Parameters
- $field : FieldInterface
- $value : mixed
Return values
string —renderFile()
Renders an asset file
public
renderFile(Asset $asset, FieldInterface $field, FileDisplayerInterface $displayer) : string
Parameters
- $asset : Asset
- $field : FieldInterface
- $displayer : FileDisplayerInterface
Return values
string —renderGroup()
Renders a group
public
renderGroup(GroupInterface $group) : string
Parameters
- $group : GroupInterface
Return values
string —renderLayout()
Renders a layout for a view mode and an element
public
renderLayout(LayoutInterface $layout, string|ViewModeInterface $viewMode, Element|null $element[, string $mode = LayoutInterface::RENDER_MODE_DISPLAYS ]) : string
Parameters
- $layout : LayoutInterface
- $viewMode : string|ViewModeInterface
- $element : Element|null
- $mode : string = LayoutInterface::RENDER_MODE_DISPLAYS
Return values
string —renderRegion()
Renders a region
public
renderRegion(Region $region) : string
Parameters
- $region : Region
Return values
string —blockCacheService()
Get the block cache service
protected
blockCacheService() : BlockCacheService
Return values
BlockCacheService —blockProviderService()
Get the block providers service
protected
blockProviderService() : BlockProvidersService
Return values
BlockProvidersService —blocksService()
Get the blocks service
protected
blocksService() : BlockService
Return values
BlockService —displayService()
Get the display service
protected
displayService() : DisplayService
Return values
DisplayService —eagerLoadingService()
Get the eager loading service
protected
eagerLoadingService() : EagerLoadingService
Return values
EagerLoadingService —fieldDisplayersService()
Get the field displayers service
protected
fieldDisplayersService() : FieldDisplayerService
Return values
FieldDisplayerService —fieldsService()
Get the fields service
protected
fieldsService() : FieldsService
Return values
FieldsService —fileDisplayerService()
Get the file displayers service
protected
fileDisplayerService() : FileDisplayerService
Return values
FileDisplayerService —getDevMode()
Are we in dev mode ?
protected
getDevMode() : bool
Return values
bool —getDevModeHtml()
Get the dev mode html
protected
getDevModeHtml(array<string|int, string> $templates, string $currentTemplate, array<string|int, mixed> $variables) : string
Parameters
- $templates : array<string|int, string>
- $currentTemplate : string
- $variables : array<string|int, mixed>
Return values
string —getPageVariables()
Add the page variables and the themes variables to an array
protected
getPageVariables([array<string|int, mixed> $variables = [] ]) : array<string|int, mixed>
Parameters
- $variables : array<string|int, mixed> = []
Return values
array<string|int, mixed> —groupsService()
Get the groups service
protected
groupsService() : GroupsService
Return values
GroupsService —layoutService()
Get the layout service
protected
layoutService() : LayoutService
Return values
LayoutService —matrixService()
Get the matrix service
protected
matrixService() : MatrixService
Return values
MatrixService —render()
Renders an array of templates
protected
render(string $eventType, array<string|int, string> $templates, array<string|int, mixed> $variables) : string
Parameters
- $eventType : string
- $templates : array<string|int, string>
- $variables : array<string|int, mixed>
Return values
string —resolveTemplate()
Resolves a template from an array of templates
protected
resolveTemplate(array<string|int, string> $templates) : string
Parameters
- $templates : array<string|int, string>
Return values
string —resolveTemplateFromCache()
Resolves a template from cache
protected
resolveTemplateFromCache(array<string|int, string> $templates) : string
Parameters
- $templates : array<string|int, string>
Return values
string —themesRegistry()
Get the themes registry
protected
themesRegistry() : ThemesRegistry
Return values
ThemesRegistry —triggerEvent()
Triggers an event
protected
triggerEvent(string $type, Event $event) : mixed
Parameters
- $type : string
- $event : Event
Return values
mixed —triggerRenderingEvent()
Triggers an event
protected
triggerRenderingEvent(string $eventType, array<string|int, string> $templates, array<string|int, mixed> $variables) : Event
Parameters
- $eventType : string
- $templates : array<string|int, string>
- $variables : array<string|int, mixed>
Return values
Event —viewModesService()
Get the view mode service
protected
viewModesService() : ViewModeService
Return values
ViewModeService —viewService()
Get the view service
protected
viewService() : ViewService