You are here

public static function EntityViewDisplayAlterer::smartTitleBuilder in Smart Title 8

Entity builder for Smart Title.

Parameters

string $entity_type_id: The id of the entity views display config entity type. Here, this will be always 'entity_view_display'.

\Drupal\Core\Entity\Display\EntityViewDisplayInterface $entity_view_display: The entity view display config entity.

array $form: The renderable array of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The FormState object.

File

src/EntityViewDisplayAlterer.php, line 338

Class

EntityViewDisplayAlterer
Entity view display form alterer class for Smart Title.

Namespace

Drupal\smart_title

Code

public static function smartTitleBuilder($entity_type_id, EntityViewDisplayInterface $entity_view_display, array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('smart_title__enabled')) {
    $entity_view_display
      ->setThirdPartySetting('smart_title', 'enabled', TRUE);
  }
  else {
    $entity_view_display
      ->setThirdPartySetting('smart_title', 'enabled', FALSE)
      ->unsetThirdPartySetting('smart_title', 'settings')
      ->removeComponent('smart_title');
  }
}