Tripal
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
Drupal\tripal_layout\Controller\TripalEntityUILayoutController Class Reference
Inheritance diagram for Drupal\tripal_layout\Controller\TripalEntityUILayoutController:
Inheritance graph
[legend]
Collaboration diagram for Drupal\tripal_layout\Controller\TripalEntityUILayoutController:
Collaboration graph
[legend]

Public Member Functions

 applyFormLayout ($tripal_entity_type)
 
 resetFormLayout ($tripal_entity_type)
 
 applyViewLayout ($tripal_entity_type)
 
 resetViewLayout ($tripal_entity_type)
 
 resetLayout (TripalEntityType $tripal_entity_type, string $display_context, ?EntityDisplayBase $display=NULL)
 

Protected Member Functions

 getSetting ($name, $default, $settings=[])
 
 setDisplayOption (string $component_name, string $option_key, mixed $option_value, EntityDisplayBase $display)
 
 setChild ($child, $parent, EntityDisplayBase $display)
 
 addFieldGroups ($field_groups, $display)
 
 addDetailsFieldGroup ($name, EntityDisplayBase $display, $settings=[])
 
 addDetailsSidebarFieldGroup ($name, EntityDisplayBase $display, $settings=[])
 
 addVerticalTabsFieldGroup ($name, EntityDisplayBase $display, $settings=[])
 
 addTabFieldGroup ($name, EntityDisplayBase $display, $settings=[])
 
 addTableFieldGroup ($name, EntityDisplayBase $display, $settings=[])
 
 enableAllComponents (EntityDisplayBase &$display)
 
 resetComponents (EntityDisplayBase &$display)
 
 hideComponentLabels (array $component_names, EntityDisplayBase $display)
 
 clearFieldGroups (EntityDisplayBase $display)
 
 removeEmptyFieldGroups (EntityDisplayBase $display)
 
 hideComponents (array $names, EntityDisplayBase $display)
 
 getLayout (string $bundle, string $display_context)
 
 applyLayout (TripalEntityType $tripal_entity_type, string $display_context, ?EntityDisplayBase $display=NULL)
 

Detailed Description

Controller for applying Tripal layout to a tripal entity type.

Member Function Documentation

◆ addDetailsFieldGroup()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::addDetailsFieldGroup (   $name,
EntityDisplayBase  $display,
  $settings = [] 
)
protected

Adds a 'details' field group.

Parameters
string$nameThe name of the field group component.
\Drupal\Core\Entity\EntityDisplayBase$displayThe display configuration to add the field group component to.
array$settingsAn array of settings to apply to the field group.

◆ addDetailsSidebarFieldGroup()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::addDetailsSidebarFieldGroup (   $name,
EntityDisplayBase  $display,
  $settings = [] 
)
protected

Adds a 'details_sidebar' field group.

Parameters
string$nameThe name of the field group component.
\Drupal\Core\Entity\EntityDisplayBase$displayThe display configuration to add the field group component to.
array$settingsAn array of settings to apply to the field group.

◆ addFieldGroups()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::addFieldGroups (   $field_groups,
  $display 
)
protected

Adds all the field groups defined in a layout.

Currently supports:

  • details
  • field_group_table.
Parameters
array$field_groupsAn array of field groups defined in a layout.
\Drupal\Core\Entity\EntityDisplayBase$displayThe display to add the field groups to.
Returns
void No return value.

◆ addTabFieldGroup()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::addTabFieldGroup (   $name,
EntityDisplayBase  $display,
  $settings = [] 
)
protected

Adds a 'tab' field group.

Parameters
string$nameThe name of the field group component.
\Drupal\Core\Entity\EntityDisplayBase$displayThe display configuration to add the field group component to.
array$settingsAn array of settings to apply to the field group.

◆ addTableFieldGroup()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::addTableFieldGroup (   $name,
EntityDisplayBase  $display,
  $settings = [] 
)
protected

Adds a 'field_group_table' field group.

Parameters
string$nameThe name of the field group component.
\Drupal\Core\Entity\EntityDisplayBase$displayThe display configuration to add the field group component to.
array$settingsAn array of settings to apply to the field group.

◆ addVerticalTabsFieldGroup()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::addVerticalTabsFieldGroup (   $name,
EntityDisplayBase  $display,
  $settings = [] 
)
protected

Adds a 'tabs' field group.

Parameters
string$nameThe name of the field group component.
\Drupal\Core\Entity\EntityDisplayBase$displayThe display configuration to add the field group component to.
array$settingsAn array of settings to apply to the field group.

◆ applyFormLayout()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::applyFormLayout (   $tripal_entity_type)

FORM: Applies the default Tripal layout to a tripal entity form.

Parameters
\Drupal\tripal\Entity\TripalEntityType$tripal_entity_typeThe TripalEntityType whose form display layout we want to apply the default tripal layout to. Note: The tripal layout specific to this TripalEntityType will be applied.
Returns
\Symfony\Component\HttpFoundation\Response Returns the action to take on the page; specifically, returns a redirect action to return to the "Manage Form Display" page for this TripalEntityType.

◆ applyLayout()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::applyLayout ( TripalEntityType  $tripal_entity_type,
string  $display_context,
?EntityDisplayBase  $display = NULL 
)
protected

Applies the default Tripal layout to a tripal entity.

Parameters
\Drupal\tripal\Entity\TripalEntityType$tripal_entity_typeThe bundle whose display is being managed (e.g. organism)
string$display_contextOne of 'view' or 'form' depending on whether the display to apply the tripal layout to is for the page view display or the form display.
\Drupal\Core\Entity\EntityDisplayBase$displayThe display to modified. This is optional and will be loaded based on the first two parameters if not supplied.
Returns
bool TRUE if the layout was applied successfully and FALSE otherwise.

◆ applyViewLayout()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::applyViewLayout (   $tripal_entity_type)

VIEW: Applies the default Tripal layout to a tripal entity view.

Parameters
\Drupal\tripal\Entity\TripalEntityType$tripal_entity_typeThe TripalEntityType whose view display layout we want to apply the default tripal layout to. Note: The tripal layout specific to this TripalEntityType will be applied.
Returns
\Symfony\Component\HttpFoundation\Response Returns the action to take on the page; specifically, returns a redirect action to return to the "Manage Display" page for this TripalEntityType.

◆ clearFieldGroups()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::clearFieldGroups ( EntityDisplayBase  $display)
protected

Removes all field groups from the display.

Parameters
\Drupal\Core\Entity\EntityDisplayBase$displayThe entity display object.

◆ enableAllComponents()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::enableAllComponents ( EntityDisplayBase &  $display)
protected

Sets all fields to be enabled in the form display.

Parameters
\Drupal\Core\Entity\EntityDisplayBase&$displayThe entity display object.

◆ getLayout()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::getLayout ( string  $bundle,
string  $display_context 
)
protected

Retrieves the layout configuration for the given bundle.

Parameters
string$bundleThe TripalEntityType to return the display for.
string$display_contextOne of 'view' or 'form' depending on whether you want the display for the page view display or the form display.
Returns
array The layout configuration if there is one, the first layout if there are multiple for the TripalEntityType and FALSE if there are none.

◆ getSetting()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::getSetting (   $name,
  $default,
  $settings = [] 
)
protected

A generic function for getting a setting and providing the default.

Parameters
string$nameThe setting name.
unknown$defaultThe default value if no setting is set.
array$settingsThe list of settings.
Returns
mixed The setting value.

◆ hideComponentLabels()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::hideComponentLabels ( array  $component_names,
EntityDisplayBase  $display 
)
protected

Hides the label of all the components listed.

Parameters
array$component_namesA list of component names whose label we want to hide.
\Drupal\Core\Entity\EntityDisplayBase$displayThe display the components belong to.
Returns
void No return value.

◆ hideComponents()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::hideComponents ( array  $names,
EntityDisplayBase  $display 
)
protected

Hides a field from display.

Parameters
array$namesThe names of the field components.
\Drupal\Core\Entity\EntityDisplayBase$displayThe display configuration.

◆ removeEmptyFieldGroups()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::removeEmptyFieldGroups ( EntityDisplayBase  $display)
protected

Removes any field groups without children from the current display.

Parameters
\Drupal\Core\Entity\EntityDisplayBase$displayThe display to act on (i.e. the current display)
Returns
void No return value.

◆ resetComponents()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::resetComponents ( EntityDisplayBase &  $display)
protected

Resets all enabled components to their default display settings.

Parameters
\Drupal\Core\Entity\EntityDisplayBase$displayThe entity display object.
Returns
void No return value.

◆ resetFormLayout()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::resetFormLayout (   $tripal_entity_type)

FORM: Removes all layout applied by this module to the tripal entity form.

Parameters
\Drupal\tripal\Entity\TripalEntityType$tripal_entity_typeThe TripalEntityType whose form display layout we want to reset to it's defaults.
Returns
\Symfony\Component\HttpFoundation\Response Returns the action to take on the page; specifically, returns a redirect action to return to the "Manage Form Display" page for this TripalEntityType.

◆ resetLayout()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::resetLayout ( TripalEntityType  $tripal_entity_type,
string  $display_context,
?EntityDisplayBase  $display = NULL 
)

Clears any field groups, enables all fields, and resets them to defaults.

All fields are reset to their default display options.

Parameters
\Drupal\tripal\Entity\TripalEntityType$tripal_entity_typeThe bundle whose display is being managed (e.g. organism)
string$display_contextOne of 'view' or 'form' depending on whether the display to be reset is for the page view display or the form display.
\Drupal\Core\Entity\EntityDisplayBase$displayThe display to be reset. This is optional and will be loaded based on the first two parameters if not supplied.

◆ resetViewLayout()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::resetViewLayout (   $tripal_entity_type)

VIEW: Removes all layout applied by this module to the tripal entity view.

Parameters
\Drupal\tripal\Entity\TripalEntityType$tripal_entity_typeThe TripalEntityType whose view display layout we want to reset to it's defaults.
Returns
\Symfony\Component\HttpFoundation\Response Returns the action to take on the page; specifically, returns a redirect action to return to the "Manage Display" page for this TripalEntityType.

◆ setChild()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::setChild (   $child,
  $parent,
EntityDisplayBase  $display 
)
protected

Sets the child as a child of the provided parent in the supplied display.

For example, this may mean setting a field as a child of a field group.

Parameters
string$childThe name of the child component. The child must be one of the following in order to be supported:
  • an enabled field component
  • a hidden field component
  • a field group.
string$parentThe name of the parent component.
\Drupal\Core\Entity\EntityDisplayBase$displayThe display to set the child as a child of the parent in.

◆ setDisplayOption()

Drupal\tripal_layout\Controller\TripalEntityUILayoutController::setDisplayOption ( string  $component_name,
string  $option_key,
mixed  $option_value,
EntityDisplayBase  $display 
)
protected

Sets the display option for a component without affecting other options.

Note: this will override an existing version of that option.

Parameters
string$component_nameThe name of the component you want to set a display option for.
string$option_keyThe key for the display option (e.g. 'weight')
mixed$option_valueThe value for the display option.
\Drupal\Core\Entity\EntityDisplayBase$displayThe display the component is in and that you want to set it for.
Returns
void No return value.

The documentation for this class was generated from the following file: