DisplayService
extends Service
in package
Table of Contents
- CONFIG_KEY = 'themes.displays'
- EVENT_AFTER_DELETE = 'after_delete'
- EVENT_AFTER_SAVE = 'after_save'
- EVENT_BEFORE_APPLY_DELETE = 'before_apply_delete'
- EVENT_BEFORE_DELETE = 'before_delete'
- EVENT_BEFORE_SAVE = 'before_save'
- TYPE_FIELD = 'field'
- TYPE_GROUP = 'group'
- TYPES = [self::TYPE_FIELD, self::TYPE_GROUP]
- $_displays : Collection
- cleanUp() : mixed
- Clean up for view mode, deletes old displays
- create() : DisplayInterface
- Create a display from config
- createViewModeDisplays() : array<string|int, DisplayInterface>
- Create all displays for a view mode, will rebuild the existing ones
- delete() : bool
- Deletes a display
- getAll() : Collection
- Get all displays
- getById() : DisplayInterface|null
- Get a display by id
- getByUid() : DisplayInterface|null
- Get a display by uid
- getForFieldType() : DisplayInterface|null
- Get all displays for a view mode and a field type
- getForGroup() : array<string|int, DisplayInterface>
- Get all displays for a group
- getForLayout() : array<string|int, DisplayInterface>
- Get all displays for a layout
- getForViewMode() : array<string|int, DisplayInterface>
- Get all displays for a view mode
- getRecordByUid() : DisplayRecord
- Get field record by uid or a new one if not found
- handleChanged() : mixed
- Handles a change in display config
- handleDeleted() : mixed
- Handles a deletion in display config
- populateFromData() : DisplayInterface
- Populate a display from an array of data
- rebuildConfig() : mixed
- Respond to rebuild config event
- save() : bool
- Saves a display
- add() : mixed
- Add a display to internal cache
- 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
- getForCraftField() : DisplayInterface|null
- Get a display for a craft field and a view mode
- getNextOrder() : int
- Get next order in displays for a view mode
- groupsService() : GroupsService
- Get the groups service
- 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.displays'
EVENT_AFTER_DELETE
public
mixed
EVENT_AFTER_DELETE
= 'after_delete'
EVENT_AFTER_SAVE
public
mixed
EVENT_AFTER_SAVE
= 'after_save'
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'
TYPE_FIELD
public
mixed
TYPE_FIELD
= 'field'
TYPE_GROUP
public
mixed
TYPE_GROUP
= 'group'
TYPES
public
mixed
TYPES
= [self::TYPE_FIELD, self::TYPE_GROUP]
Properties
$_displays
private
Collection
$_displays
Methods
cleanUp()
Clean up for view mode, deletes old displays
public
cleanUp(array<string|int, mixed> $displays, ViewModeInterface $viewMode) : mixed
Parameters
- $displays : array<string|int, mixed>
- $viewMode : ViewModeInterface
Return values
mixed —create()
Create a display from config
public
create(array<string|int, mixed>|ActiveRecord $config) : DisplayInterface
Parameters
- $config : array<string|int, mixed>|ActiveRecord
Return values
DisplayInterface —createViewModeDisplays()
Create all displays for a view mode, will rebuild the existing ones
public
createViewModeDisplays(ViewModeInterface $viewMode) : array<string|int, DisplayInterface>
Parameters
- $viewMode : ViewModeInterface
Return values
array<string|int, DisplayInterface> —delete()
Deletes a display
public
delete(DisplayInterface $display) : bool
Parameters
- $display : DisplayInterface
Return values
bool —getAll()
Get all displays
public
getAll() : Collection
Return values
Collection —getById()
Get a display by id
public
getById(int $id) : DisplayInterface|null
Parameters
- $id : int
Return values
DisplayInterface|null —getByUid()
Get a display by uid
public
getByUid(int $uid) : DisplayInterface|null
Parameters
- $uid : int
Return values
DisplayInterface|null —getForFieldType()
Get all displays for a view mode and a field type
public
getForFieldType(ViewModeInterface $viewMode, string $type) : DisplayInterface|null
Parameters
- $viewMode : ViewModeInterface
- $type : string
Return values
DisplayInterface|null —getForGroup()
Get all displays for a group
public
getForGroup(int $groupId) : array<string|int, DisplayInterface>
Parameters
- $groupId : int
Return values
array<string|int, DisplayInterface> —getForLayout()
Get all displays for a layout
public
getForLayout(LayoutInterface $layout) : array<string|int, DisplayInterface>
Parameters
- $layout : LayoutInterface
Return values
array<string|int, DisplayInterface> —getForViewMode()
Get all displays for a view mode
public
getForViewMode(ViewModeInterface $viewMode[, bool $onlyRoots = true ]) : array<string|int, DisplayInterface>
Parameters
- $viewMode : ViewModeInterface
- $onlyRoots : bool = true
-
Fetch only the root displays (that aren't in groups)
Return values
array<string|int, DisplayInterface> —getRecordByUid()
Get field record by uid or a new one if not found
public
getRecordByUid(string $uid) : DisplayRecord
Parameters
- $uid : string
Return values
DisplayRecord —handleChanged()
Handles a change in display config
public
handleChanged(ConfigEvent $event) : mixed
Parameters
- $event : ConfigEvent
Return values
mixed —handleDeleted()
Handles a deletion in display config
public
handleDeleted(ConfigEvent $event) : mixed
Parameters
- $event : ConfigEvent
Return values
mixed —populateFromData()
Populate a display from an array of data
public
populateFromData(array<string|int, mixed> $data) : DisplayInterface
Parameters
- $data : array<string|int, mixed>
Return values
DisplayInterface —rebuildConfig()
Respond to rebuild config event
public
rebuildConfig(RebuildConfigEvent $e) : mixed
Parameters
- $e : RebuildConfigEvent
Return values
mixed —save()
Saves a display
public
save(DisplayInterface $display[, bool $validate = true ]) : bool
Parameters
- $display : DisplayInterface
- $validate : bool = true
Return values
bool —add()
Add a display to internal cache
protected
add(DisplayInterface $display) : mixed
Parameters
- $display : DisplayInterface
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 —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 —getForCraftField()
Get a display for a craft field and a view mode
protected
getForCraftField([int|null $fieldId = null ], ViewModeInterface $viewMode) : DisplayInterface|null
Parameters
- $fieldId : int|null = null
- $viewMode : ViewModeInterface
Return values
DisplayInterface|null —getNextOrder()
Get next order in displays for a view mode
protected
getNextOrder(ViewModeInterface $viewMode) : int
Parameters
- $viewMode : ViewModeInterface
Return values
int —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 —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