FieldsService
extends Service
in package
Table of Contents
- CONFIG_KEY = 'themes.fields'
- EVENT_REGISTER_FIELDS = 'registerFields'
- $_fields : Collection
- $_parentPivots : Collection
- $_registered : array<string|int, string>
- List of registered fields, indexed by their types
- buildConfig() : array<string|int, mixed>
- Build the config for a craft field
- create() : FieldInterface
- Create a field from config or active record
- createFromField() : FieldInterface
- Create a field from a craft field
- delete() : bool
- Deletes a field
- getAll() : Collection
- Get all fields
- getAllForCraftField() : array<string|int, FieldInterface>
- Get all fields for a craft field id
- getById() : FieldInterface
- Get a field by id
- getChild() : FieldInterface|null
- Get the child of a field related to a Craft field.
- getChildren() : array<string|int, FieldInterface>
- Get the children of a field
- getChildrenPivots() : array<string|int, ParentPivotRecord>
- Get the children pivots for a parent
- getFieldClassByType() : string
- Get a field class for a type
- getForDisplay() : FieldInterface|null
- Get a field for a display
- getParent() : FieldInterface|null
- Get the parent of a field
- getParentPivotRecord() : ParentPivotRecord
- Get a parent pivot record, or creates a new one
- getParentPivots() : Collection
- Get all parent pivots
- getRecordByUid() : FieldRecord
- get a record by uid
- getRegisteredFields() : array<string|int, string>
- Get all registered fields
- getTypeForCraftField() : string
- Get the type of field for a craft field
- getValidTypes() : array<string|int, string>
- Get all valid field types
- handleChanged() : mixed
- Handles a change in field config
- handleDeleted() : mixed
- Handles a deletion in field config
- onCraftFieldSaved() : mixed
- Handles a craft field save: If the type of field has changed we#ll delete the field and recreate it Otherwise we'll rebuild it in case changes are to be made by the field
- populateFromData() : FieldInterface
- Populates a field from array of data
- rebuildConfig() : mixed
- Respond to rebuild config event
- save() : bool
- Saves a field
- add() : mixed
- Add a field 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
- groupsService() : GroupsService
- Get the groups service
- layoutService() : LayoutService
- Get the layout service
- matrixService() : MatrixService
- Get the matrix service
- register() : mixed
- Registers fields
- resolveParent() : FieldInterface|null
- Resolve the parent of a field
- 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.fields'
EVENT_REGISTER_FIELDS
public
mixed
EVENT_REGISTER_FIELDS
= 'registerFields'
Properties
$_fields
private
Collection
$_fields
$_parentPivots
private
Collection
$_parentPivots
$_registered
List of registered fields, indexed by their types
private
array<string|int, string>
$_registered
Methods
buildConfig()
Build the config for a craft field
public
buildConfig(Field $craftField) : array<string|int, mixed>
Parameters
- $craftField : Field
Return values
array<string|int, mixed> —create()
Create a field from config or active record
public
create(array<string|int, mixed>|ActiveRecord $config) : FieldInterface
Parameters
- $config : array<string|int, mixed>|ActiveRecord
Tags
Return values
FieldInterface —createFromField()
Create a field from a craft field
public
createFromField(Field $craftField) : FieldInterface
Parameters
- $craftField : Field
Return values
FieldInterface —delete()
Deletes a field
public
delete(FieldInterface $field) : bool
Parameters
- $field : FieldInterface
Return values
bool —getAll()
Get all fields
public
getAll() : Collection
Return values
Collection —getAllForCraftField()
Get all fields for a craft field id
public
getAllForCraftField(int $fieldId) : array<string|int, FieldInterface>
Parameters
- $fieldId : int
Return values
array<string|int, FieldInterface> —getById()
Get a field by id
public
getById(int $id) : FieldInterface
Parameters
- $id : int
Return values
FieldInterface —getChild()
Get the child of a field related to a Craft field.
public
getChild(FieldInterface $field, Field $craftField) : FieldInterface|null
Warning, if the parent could contain the same Craft field more than once you may get a wrong result here.
Parameters
- $field : FieldInterface
- $craftField : Field
Return values
FieldInterface|null —getChildren()
Get the children of a field
public
getChildren(FieldInterface $field) : array<string|int, FieldInterface>
Parameters
- $field : FieldInterface
Return values
array<string|int, FieldInterface> —getChildrenPivots()
Get the children pivots for a parent
public
getChildrenPivots(int $parentId) : array<string|int, ParentPivotRecord>
Parameters
- $parentId : int
Return values
array<string|int, ParentPivotRecord> —getFieldClassByType()
Get a field class for a type
public
getFieldClassByType(string $type) : string
Parameters
- $type : string
Return values
string —getForDisplay()
Get a field for a display
public
getForDisplay(DisplayInterface $display) : FieldInterface|null
Parameters
- $display : DisplayInterface
Return values
FieldInterface|null —getParent()
Get the parent of a field
public
getParent(FieldInterface $field) : FieldInterface|null
Parameters
- $field : FieldInterface
Return values
FieldInterface|null —getParentPivotRecord()
Get a parent pivot record, or creates a new one
public
getParentPivotRecord(int $parentId, int $fieldId) : ParentPivotRecord
Parameters
- $parentId : int
- $fieldId : int
Return values
ParentPivotRecord —getParentPivots()
Get all parent pivots
public
getParentPivots() : Collection
Return values
Collection —getRecordByUid()
get a record by uid
public
getRecordByUid(string $uid) : FieldRecord
Parameters
- $uid : string
Return values
FieldRecord —getRegisteredFields()
Get all registered fields
public
getRegisteredFields() : array<string|int, string>
Return values
array<string|int, string> —getTypeForCraftField()
Get the type of field for a craft field
public
getTypeForCraftField(Field $field) : string
Parameters
- $field : Field
Return values
string —getValidTypes()
Get all valid field types
public
getValidTypes() : array<string|int, string>
Return values
array<string|int, string> —handleChanged()
Handles a change in field config
public
handleChanged(ConfigEvent $event) : mixed
Parameters
- $event : ConfigEvent
Return values
mixed —handleDeleted()
Handles a deletion in field config
public
handleDeleted(ConfigEvent $event) : mixed
Parameters
- $event : ConfigEvent
Return values
mixed —onCraftFieldSaved()
Handles a craft field save: If the type of field has changed we#ll delete the field and recreate it Otherwise we'll rebuild it in case changes are to be made by the field
public
onCraftFieldSaved(FieldEvent $event) : mixed
Parameters
- $event : FieldEvent
Return values
mixed —populateFromData()
Populates a field from array of data
public
populateFromData(array<string|int, mixed> $data) : FieldInterface
Parameters
- $data : array<string|int, mixed>
Return values
FieldInterface —rebuildConfig()
Respond to rebuild config event
public
rebuildConfig(RebuildConfigEvent $e) : mixed
Parameters
- $e : RebuildConfigEvent
Return values
mixed —save()
Saves a field
public
save(FieldInterface $field[, bool $validate = true ]) : bool
Parameters
- $field : FieldInterface
- $validate : bool = true
Return values
bool —add()
Add a field to internal cache
protected
add(FieldInterface $field) : mixed
Parameters
- $field : FieldInterface
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 —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 —register()
Registers fields
protected
register() : mixed
Return values
mixed —resolveParent()
Resolve the parent of a field
protected
resolveParent(FieldInterface $field) : FieldInterface|null
Parameters
- $field : FieldInterface
Return values
FieldInterface|null —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