class MessageUIFieldDisplayManagerService in Message UI 8
Class MessageUIFieldDisplayManagerService.
@package Drupal\message_ui
Hierarchy
- class \Drupal\message_ui\MessageUIFieldDisplayManagerService implements MessageUIFieldDisplayManagerServiceInterface
Expanded class hierarchy of MessageUIFieldDisplayManagerService
1 string reference to 'MessageUIFieldDisplayManagerService'
1 service uses MessageUIFieldDisplayManagerService
File
- src/
MessageUIFieldDisplayManagerService.php, line 12
Namespace
Drupal\message_uiView source
class MessageUIFieldDisplayManagerService implements MessageUIFieldDisplayManagerServiceInterface {
/**
* The entity storage manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public function setFieldsDisplay($template) {
$this->entityTypeManager
->getStorage('entity_form_display')
->resetCache();
/** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $form_display */
$form_display = $this->entityTypeManager
->getStorage('entity_form_display')
->load("message.{$template}.default");
if (!$form_display) {
$form_display = \Drupal::entityTypeManager()
->getStorage('entity_form_display')
->create([
'targetEntityType' => 'message',
'bundle' => $template,
'mode' => 'default',
'status' => TRUE,
]);
foreach (array_keys($form_display
->get('hidden')) as $hidden) {
$form_display
->setComponent($hidden, [
'field_name' => $hidden,
]);
$form_display
->save();
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MessageUIFieldDisplayManagerService:: |
protected | property | The entity storage manager. | |
MessageUIFieldDisplayManagerService:: |
public | function |
Setting the fields to display. Overrides MessageUIFieldDisplayManagerServiceInterface:: |
|
MessageUIFieldDisplayManagerService:: |
public | function | Constructor. |