LayoutService
extends Service
in package
Table of Contents
- CONFIG_KEY = 'themes.layouts'
- DEFAULT_HANDLE = 'default'
- EVENT_AFTER_DELETE = 'after_delete'
- EVENT_AFTER_SAVE = 'after_save'
- EVENT_AVAILABLE_LAYOUTS = 'available_layouts'
- EVENT_BEFORE_APPLY_DELETE = 'before_apply_delete'
- EVENT_BEFORE_DELETE = 'before_delete'
- EVENT_BEFORE_SAVE = 'before_save'
- EVENT_REGISTER_TYPES = 'register_types'
- EVENT_RESOLVE_REQUEST_LAYOUT = 'resolve_request_layout'
- USER_HANDLE = 'user'
- $isInstalling : bool
- Marker when layouts are being installed
- $_layouts : Collection
- $_types : array<string|int, mixed>
- copyIntoCustom() : LayoutInterface
- Copy a layout into custom one
- create() : LayoutInterface
- Create a layout from config
- createCustom() : CustomLayout
- Create a custom layout
- deleteCustom() : bool
- Delete a custom layout
- get() : LayoutInterface|null
- Get a layout
- getAll() : Collection
- All layouts getter
- getBlockLayouts() : array<string|int, LayoutInterface>
- Get all layouts that can have blocks indexed by theme's handle
- getById() : LayoutInterface
- Get layout by id
- getByUid() : LayoutInterface
- Get layout by uid
- getCustom() : CustomLayout|null
- Get a custom layout by handle
- getDefault() : LayoutInterface|null
- Get default layout for a theme
- getForTheme() : array<string|int, LayoutInterface>
- Get all layouts for a theme
- getForType() : array<string|int, LayoutInterface>
- Returns all layouts for a type
- getRecordByUid() : LayoutRecord
- Get layout record by uid, or a new one if it's not found
- getType() : string|null
- Get the type of a layout
- getTypes() : array<string|int, mixed>
- Get defined layouts types
- getWithDisplays() : array<string|int, LayoutInterface>
- Get all layouts with displays indexed by theme's handle
- handleChanged() : mixed
- Handles a change in layout config
- handleDeleted() : mixed
- Handles a deletion in layout config
- installAll() : mixed
- (Re)create all layouts for all themes.
- installForTheme() : bool
- (Re)create layouts for a theme, will deletes orphans.
- onCraftElementDeleted() : mixed
- Callback when an element (entry type, category group etc) is deleted
- onCraftElementSaved() : mixed
- Callback when an element (entry type, category group etc) is saved
- rebuildConfig() : mixed
- Respond to rebuild config event
- resolveForRequest() : LayoutInterface|null
- Resolve current layout.
- save() : bool
- Save a layout
- uninstallForTheme() : bool
- Deletes all layouts for a theme.
- withDisplays() : array<string|int, LayoutInterface>
- Get all layouts that have displays
- add() : mixed
- Add a layout to internal cache
- blockCacheService() : BlockCacheService
- Get the block cache service
- blockProviderService() : BlockProvidersService
- Get the block providers service
- blocksService() : BlockService
- Get the blocks service
- createCategoryLayouts() : array<string|int, LayoutInterface>
- Creates all categories layouts
- createEntryLayouts() : array<string|int, LayoutInterface>
- Creates all entries layouts
- createGlobalsLayouts() : array<string|int, LayoutInterface>
- Creates all globals layouts
- createTagsLayouts() : array<string|int, LayoutInterface>
- Creates all tags layouts
- createVolumesLayouts() : array<string|int, LayoutInterface>
- Creates all volumes layouts
- delete() : bool
- Deletes a layout
- 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
- getAvailable() : array<string|int, LayoutInterface>
- Get all available layouts
- getCustomLayouts() : array<string|int, LayoutInterface>
- Get all custom layouts for a theme
- getThemeHandle() : string
- Get theme handle from a theme parameter
- groupsService() : GroupsService
- Get the groups service
- installLayoutData() : bool
- Install layout data
- layoutService() : LayoutService
- Get the layout service
- matrixService() : MatrixService
- Get the matrix service
- themesRegistry() : ThemesRegistry
- Get the themes registry
- triggerEvent() : mixed
- Triggers an event
- viewModesService() : ViewModeService
- Get the view mode service
- viewService() : ViewService
- Get the view service
Constants
CONFIG_KEY
public
mixed
CONFIG_KEY
= 'themes.layouts'
DEFAULT_HANDLE
public
mixed
DEFAULT_HANDLE
= 'default'
EVENT_AFTER_DELETE
public
mixed
EVENT_AFTER_DELETE
= 'after_delete'
EVENT_AFTER_SAVE
public
mixed
EVENT_AFTER_SAVE
= 'after_save'
EVENT_AVAILABLE_LAYOUTS
public
mixed
EVENT_AVAILABLE_LAYOUTS
= 'available_layouts'
Tags
EVENT_BEFORE_APPLY_DELETE
public
mixed
EVENT_BEFORE_APPLY_DELETE
= 'before_apply_delete'
EVENT_BEFORE_DELETE
public
mixed
EVENT_BEFORE_DELETE
= 'before_delete'
EVENT_BEFORE_SAVE
public
mixed
EVENT_BEFORE_SAVE
= 'before_save'
EVENT_REGISTER_TYPES
public
mixed
EVENT_REGISTER_TYPES
= 'register_types'
Tags
EVENT_RESOLVE_REQUEST_LAYOUT
public
mixed
EVENT_RESOLVE_REQUEST_LAYOUT
= 'resolve_request_layout'
Tags
USER_HANDLE
public
mixed
USER_HANDLE
= 'user'
Properties
$isInstalling
Marker when layouts are being installed
public
static bool
$isInstalling
= false
$_layouts
protected
Collection
$_layouts
$_types
protected
array<string|int, mixed>
$_types
Tags
Methods
copyIntoCustom()
Copy a layout into custom one
public
copyIntoCustom(LayoutInterface $layout, string $name, string $handle) : LayoutInterface
Parameters
- $layout : LayoutInterface
- $name : string
- $handle : string
Return values
LayoutInterface —create()
Create a layout from config
public
create(array<string|int, mixed>|ActiveRecord $config) : LayoutInterface
Parameters
- $config : array<string|int, mixed>|ActiveRecord
Tags
Return values
LayoutInterface —createCustom()
Create a custom layout
public
createCustom(array<string|int, mixed> $data) : CustomLayout
Parameters
- $data : array<string|int, mixed>
Return values
CustomLayout —deleteCustom()
Delete a custom layout
public
deleteCustom(CustomLayout $layout) : bool
Parameters
- $layout : CustomLayout
Return values
bool —get()
Get a layout
public
get(string|ThemeInterface $theme, string $type[, string $elementUid = '' ]) : LayoutInterface|null
Parameters
- $theme : string|ThemeInterface
-
theme instance or theme handle
- $type : string
- $elementUid : string = ''
Return values
LayoutInterface|null —getAll()
All layouts getter
public
getAll() : Collection
Return values
Collection —getBlockLayouts()
Get all layouts that can have blocks indexed by theme's handle
public
getBlockLayouts() : array<string|int, LayoutInterface>
Return values
array<string|int, LayoutInterface> —getById()
Get layout by id
public
getById(int $id) : LayoutInterface
Parameters
- $id : int
Tags
Return values
LayoutInterface —getByUid()
Get layout by uid
public
getByUid(string $uid) : LayoutInterface
Parameters
- $uid : string
Tags
Return values
LayoutInterface —getCustom()
Get a custom layout by handle
public
getCustom(string|ThemeInterface $theme, string $handle) : CustomLayout|null
Parameters
- $theme : string|ThemeInterface
-
theme instance or theme handle
- $handle : string
Return values
CustomLayout|null —getDefault()
Get default layout for a theme
public
getDefault(string|ThemeInterface $theme) : LayoutInterface|null
Parameters
- $theme : string|ThemeInterface
-
theme instance or theme handle
Return values
LayoutInterface|null —getForTheme()
Get all layouts for a theme
public
getForTheme(string|ThemeInterface $theme[, bool|null $withHasDisplays = null ][, bool|null $withHasBlocks = null ]) : array<string|int, LayoutInterface>
Parameters
- $theme : string|ThemeInterface
-
theme instance or theme handle
- $withHasDisplays : bool|null = null
- $withHasBlocks : bool|null = null
Return values
array<string|int, LayoutInterface> —getForType()
Returns all layouts for a type
public
getForType(string|ThemeInterface $theme, string $type) : array<string|int, LayoutInterface>
Parameters
- $theme : string|ThemeInterface
-
theme instance or theme handle
- $type : string
Return values
array<string|int, LayoutInterface> —getRecordByUid()
Get layout record by uid, or a new one if it's not found
public
getRecordByUid(string $uid) : LayoutRecord
Parameters
- $uid : string
Return values
LayoutRecord —getType()
Get the type of a layout
public
getType(LayoutInterface $layout) : string|null
Parameters
- $layout : LayoutInterface
Tags
Return values
string|null —getTypes()
Get defined layouts types
public
getTypes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getWithDisplays()
Get all layouts with displays indexed by theme's handle
public
getWithDisplays() : array<string|int, LayoutInterface>
Return values
array<string|int, LayoutInterface> —handleChanged()
Handles a change in layout config
public
handleChanged(ConfigEvent $event) : mixed
Parameters
- $event : ConfigEvent
Return values
mixed —handleDeleted()
Handles a deletion in layout config
public
handleDeleted(ConfigEvent $event) : mixed
Parameters
- $event : ConfigEvent
Return values
mixed —installAll()
(Re)create all layouts for all themes.
public
installAll() : mixed
Return values
mixed —installForTheme()
(Re)create layouts for a theme, will deletes orphans.
public
installForTheme(ThemeInterface $theme) : bool
Parameters
- $theme : ThemeInterface
Return values
bool —onCraftElementDeleted()
Callback when an element (entry type, category group etc) is deleted
public
onCraftElementDeleted(string $uid) : mixed
Parameters
- $uid : string
Return values
mixed —onCraftElementSaved()
Callback when an element (entry type, category group etc) is saved
public
onCraftElementSaved(string $type[, string $uid = '' ]) : mixed
Parameters
- $type : string
- $uid : string = ''
Return values
mixed —rebuildConfig()
Respond to rebuild config event
public
rebuildConfig(RebuildConfigEvent $e) : mixed
Parameters
- $e : RebuildConfigEvent
Return values
mixed —resolveForRequest()
Resolve current layout.
public
resolveForRequest(string|ThemeInterface $theme, Element $element) : LayoutInterface|null
Parameters
- $theme : string|ThemeInterface
-
theme instance or theme handle
- $element : Element
Return values
LayoutInterface|null —save()
Save a layout
public
save(LayoutInterface $layout[, bool $validate = true ]) : bool
Parameters
- $layout : LayoutInterface
- $validate : bool = true
Tags
Return values
bool —uninstallForTheme()
Deletes all layouts for a theme.
public
uninstallForTheme(ThemeInterface $theme) : bool
Parameters
- $theme : ThemeInterface
Return values
bool —withDisplays()
Get all layouts that have displays
public
withDisplays() : array<string|int, LayoutInterface>
Return values
array<string|int, LayoutInterface> —add()
Add a layout to internal cache
protected
add(LayoutInterface $layout) : mixed
Parameters
- $layout : LayoutInterface
Return values
mixed —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 —createCategoryLayouts()
Creates all categories layouts
protected
createCategoryLayouts(string $themeHandle) : array<string|int, LayoutInterface>
Parameters
- $themeHandle : string
Return values
array<string|int, LayoutInterface> —createEntryLayouts()
Creates all entries layouts
protected
createEntryLayouts(string $themeHandle) : array<string|int, LayoutInterface>
Parameters
- $themeHandle : string
Return values
array<string|int, LayoutInterface> —createGlobalsLayouts()
Creates all globals layouts
protected
createGlobalsLayouts(string $themeHandle) : array<string|int, LayoutInterface>
Parameters
- $themeHandle : string
Return values
array<string|int, LayoutInterface> —createTagsLayouts()
Creates all tags layouts
protected
createTagsLayouts(string $themeHandle) : array<string|int, LayoutInterface>
Parameters
- $themeHandle : string
Return values
array<string|int, LayoutInterface> —createVolumesLayouts()
Creates all volumes layouts
protected
createVolumesLayouts(string $themeHandle) : array<string|int, LayoutInterface>
Parameters
- $themeHandle : string
Return values
array<string|int, LayoutInterface> —delete()
Deletes a layout
protected
delete(LayoutInterface $layout[, bool $force = false ]) : bool
Parameters
- $layout : LayoutInterface
- $force : bool = false
Tags
Return values
bool —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 —getAvailable()
Get all available layouts
protected
getAvailable(string $themeHandle) : array<string|int, LayoutInterface>
Parameters
- $themeHandle : string
Return values
array<string|int, LayoutInterface> —getCustomLayouts()
Get all custom layouts for a theme
protected
getCustomLayouts(string $themeHandle) : array<string|int, LayoutInterface>
Parameters
- $themeHandle : string
Return values
array<string|int, LayoutInterface> —getThemeHandle()
Get theme handle from a theme parameter
protected
getThemeHandle(string|ThemeInterface $theme) : string
Parameters
- $theme : string|ThemeInterface
-
theme instance or theme handle
Tags
Return values
string —groupsService()
Get the groups service
protected
groupsService() : GroupsService
Return values
GroupsService —installLayoutData()
Install layout data
protected
installLayoutData(LayoutInterface $layout) : bool
Parameters
- $layout : LayoutInterface
Return values
bool —layoutService()
Get the layout service
protected
layoutService() : LayoutService
Return values
LayoutService —matrixService()
Get the matrix service
protected
matrixService() : MatrixService
Return values
MatrixService —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 —viewModesService()
Get the view mode service
protected
viewModesService() : ViewModeService
Return values
ViewModeService —viewService()
Get the view service
protected
viewService() : ViewService