Craft Themes (3.x)

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

EVENT_REGISTER_FIELDS

public mixed EVENT_REGISTER_FIELDS = 'registerFields'

Properties

$_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>

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>

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

getFieldClassByType()

Get a field class for a type

public getFieldClassByType(string $type) : string
Parameters
$type : string
Return values
string

getParentPivots()

Get all parent pivots

public getParentPivots() : Collection
Return values
Collection

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

matrixService()

Get the matrix service

protected matrixService() : MatrixService
Return values
MatrixService

register()

Registers fields

protected register() : mixed
Return values
mixed

triggerEvent()

Triggers an event

protected triggerEvent(string $type, Event $event) : mixed
Parameters
$type : string
$event : Event
Return values
mixed

Search results