Craft Themes (3.x)

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
$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()  : mixed
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

$templateCacheEnabled

public bool $templateCacheEnabled

$_renderingBlock

Rendering layout mode

protected string|null $_renderingBlock

$_renderingElement

Element being rendered

protected Element|null $_renderingElement

$_renderingMode

Rendering layout mode

protected string|null $_renderingMode

$_renderingRegion

Region being rendered

protected Region|null $_renderingRegion

$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

getRenderingElement()

Get the current rendering element

public getRenderingElement() : Element|null
Return values
Element|null

getRenderingMode()

Get the current rendering layout mode

public getRenderingMode() : string|null
Return values
string|null

init()

public init() : mixed
Tags
inheritDoc
Return values
mixed

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

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>

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

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

Search results