interface EntityDisplayRepositoryInterface (View source)

Provides an interface for an entity display repository.

Constants

DEFAULT_DISPLAY_MODE

The default display mode ID.

Methods

array
getAllViewModes()

Gets the entity view mode info for all entity types.

array
getViewModes(string $entity_type_id)

Gets the entity view mode info for a specific entity type.

array
getAllFormModes()

Gets the entity form mode info for all entity types.

array
getFormModes(string $entity_type_id)

Gets the entity form mode info for a specific entity type.

array
getViewModeOptions(string $entity_type_id)

Gets an array of view mode options.

array
getFormModeOptions(string $entity_type_id)

Gets an array of form mode options.

array
getViewModeOptionsByBundle(string $entity_type_id, string $bundle)

Returns an array of enabled view mode options by bundle.

array
getFormModeOptionsByBundle(string $entity_type_id, string $bundle)

Returns an array of enabled form mode options by bundle.

$this
clearDisplayModeInfo()

Clears the gathered display mode info.

getViewDisplay(string $entity_type, string $bundle, string $view_mode = self::DEFAULT_DISPLAY_MODE)

Returns the entity view display associated with a bundle and view mode.

getFormDisplay(string $entity_type, string $bundle, string $form_mode = self::DEFAULT_DISPLAY_MODE)

Returns the entity form display associated with a bundle and form mode.

Details

array getAllViewModes()

Gets the entity view mode info for all entity types.

Return Value

array

The view mode info for all entity types.

array getViewModes(string $entity_type_id)

Gets the entity view mode info for a specific entity type.

Parameters

string $entity_type_id

The entity type whose view mode info should be returned.

Return Value

array

The view mode info for a specific entity type.

array getAllFormModes()

Gets the entity form mode info for all entity types.

Return Value

array

The form mode info for all entity types.

array getFormModes(string $entity_type_id)

Gets the entity form mode info for a specific entity type.

Parameters

string $entity_type_id

The entity type whose form mode info should be returned.

Return Value

array

The form mode info for a specific entity type.

array getViewModeOptions(string $entity_type_id)

Gets an array of view mode options.

Parameters

string $entity_type_id

The entity type whose view mode options should be returned.

Return Value

array

An array of view mode labels, keyed by the display mode ID.

array getFormModeOptions(string $entity_type_id)

Gets an array of form mode options.

Parameters

string $entity_type_id

The entity type whose form mode options should be returned.

Return Value

array

An array of form mode labels, keyed by the display mode ID.

array getViewModeOptionsByBundle(string $entity_type_id, string $bundle)

Returns an array of enabled view mode options by bundle.

Parameters

string $entity_type_id

The entity type whose view mode options should be returned.

string $bundle

The name of the bundle.

Return Value

array

An array of view mode labels, keyed by the display mode ID.

array getFormModeOptionsByBundle(string $entity_type_id, string $bundle)

Returns an array of enabled form mode options by bundle.

Parameters

string $entity_type_id

The entity type whose form mode options should be returned.

string $bundle

The name of the bundle.

Return Value

array

An array of form mode labels, keyed by the display mode ID.

$this clearDisplayModeInfo()

Clears the gathered display mode info.

Return Value

$this

EntityViewDisplayInterface getViewDisplay(string $entity_type, string $bundle, string $view_mode = self::DEFAULT_DISPLAY_MODE)

Returns the entity view display associated with a bundle and view mode.

Use this function when assigning suggested display options for a component in a given view mode. Note that they will only be actually used at render time if the view mode itself is configured to use dedicated display settings for the bundle; if not, the 'default' display is used instead.

The function reads the entity view display from the current configuration, or returns a ready-to-use empty one if configuration entry exists yet for this bundle and view mode. This streamlines manipulation of display objects by always returning a consistent object that reflects the current state of the configuration.

Example usage:

  • Set the 'body' field to be displayed and the 'field_image' field to be hidden on article nodes in the 'default' display.

Parameters

string $entity_type

The entity type.

string $bundle

The bundle.

string $view_mode

(optional) The view mode. Defaults to self::DEFAULT_DISPLAY_MODE.

Return Value

EntityViewDisplayInterface

The entity view display associated with the view mode.

EntityFormDisplayInterface getFormDisplay(string $entity_type, string $bundle, string $form_mode = self::DEFAULT_DISPLAY_MODE)

Returns the entity form display associated with a bundle and form mode.

The function reads the entity form display object from the current configuration, or returns a ready-to-use empty one if no configuration entry exists yet for this bundle and form mode. This streamlines manipulation of entity form displays by always returning a consistent object that reflects the current state of the configuration.

Example usage:

  • Set the 'body' field to be displayed with the 'text_textarea_with_summary' widget and the 'field_image' field to be hidden on article nodes in the 'default' form mode.

Parameters

string $entity_type

The entity type.

string $bundle

The bundle.

string $form_mode

(optional) The form mode. Defaults to self::DEFAULT_DISPLAY_MODE.

Return Value

EntityFormDisplayInterface

The entity form display associated with the given form mode.

See also

EntityStorageInterface::create
EntityStorageInterface::load