protected function LazyForm::getEnabledFiltersAndFields in Lazy-load 8.2
Same name and namespace in other branches
- 8.3 src/Form/LazyForm.php \Drupal\lazy\Form\LazyForm::getEnabledFiltersAndFields()
Gets enabled filter formats.
Parameters
array|null $status: Array of filter-formats and entity bundles.
1 call to LazyForm::getEnabledFiltersAndFields()
- LazyForm::buildForm in src/
Form/ LazyForm.php - Form constructor.
File
- src/
Form/ LazyForm.php, line 35
Class
- LazyForm
- Configure Lazy settings for this site.
Namespace
Drupal\lazy\FormCode
protected function getEnabledFiltersAndFields($status) {
$links = [];
$anchor_links = [];
if (!empty($status)) {
foreach ($status as $name => $bool_value) {
if ($bool_value && is_string($name)) {
if (strpos($name, 'filter.format.') === 0 && ($filter_format = substr($name, 14))) {
$links['filter'][$filter_format] = [
'uri' => Url::fromRoute('entity.filter_format.edit_form', [
'filter_format' => $filter_format,
])
->toString(),
'title' => $filter_format,
];
}
elseif (($entity = explode('--', $name)) && count($entity)) {
list($entity_type, $entity_bundle, $view_mode) = $entity;
if ($entity_type !== NULL && $entity_bundle !== NULL) {
$links['field']["{$entity_type}--{$entity_bundle}--{$view_mode}"] = [
'uri' => Url::fromRoute("entity.entity_view_display.{$entity_type}.view_mode", [
($entity_type === 'paragraph' ? 'paragraphs' : $entity_type) . '_type' => $entity_bundle,
'view_mode_name' => $view_mode,
])
->toString(),
'title' => $entity_bundle . " ({$view_mode})",
];
}
}
}
}
foreach ($links as $key => $link_group) {
foreach ($link_group as $link) {
$anchor_links[$key][] = '<a href="' . $link['uri'] . '">' . $link['title'] . '</a>';
}
}
}
$filter_links_result = isset($anchor_links['filter']) && count($anchor_links['filter']) ? implode(', ', $anchor_links['filter']) : 'none';
$field_links_result = isset($anchor_links['field']) && count($anchor_links['field']) ? implode(', ', $anchor_links['field']) : 'none';
$filter_message_type = $filter_links_result === 'none' ? MessengerInterface::TYPE_WARNING : MessengerInterface::TYPE_STATUS;
$this
->messenger()
->addMessage($this
->t("The <strong>text-formats</strong> have lazy-loading enabled: {$filter_links_result}"), $filter_message_type);
$field_message_type = $field_links_result === 'none' ? MessengerInterface::TYPE_WARNING : MessengerInterface::TYPE_STATUS;
$this
->messenger()
->addMessage($this
->t("The <strong>image fields</strong> have lazy-loading enabled: {$field_links_result}"), $field_message_type);
}