foreach ($form_values['display_modes_custom'
] as $mode =>
$value) { if (!
empty($value) &&
empty($current_statuses[$mode])) { // If no display exists for the newly enabled view mode, initialize
// it with those from the 'default' view mode, which were used so
// far.
if (!
$this->entityTypeManager->
getStorage($this->entity->
getEntityTypeId())->
load($this->entity->
getTargetEntityTypeId() . '.' .
$this->entity->
getTargetBundle() . '.' .
$mode)) { $display =
$this->
getEntityDisplay($this->entity->
getTargetEntityTypeId(),
$this->entity->
getTargetBundle(), 'default'
)->
createCopy($mode);
$display->
save();
} $display_mode_label =
$display_modes[$mode]['label'
];
$url =
$this->
getOverviewUrl($mode);
$this->
messenger()->
addStatus($this->
t('The %display_mode mode now uses custom display settings. You might want to <a href=":url">configure them</a>.',
['%display_mode' =>
$display_mode_label, ':url' =>
$url->
toString()]));
} $statuses[$mode] = !
empty($value);
} $this->
saveDisplayStatuses($statuses);
} $this->
messenger()->
addStatus($this->
t('Your settings have been saved.'
));
}