Skip to content

Instantly share code, notes, and snippets.

@miteshmap
Last active February 23, 2022 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miteshmap/f8d33b936e658334b54470033e8928b8 to your computer and use it in GitHub Desktop.
Save miteshmap/f8d33b936e658334b54470033e8928b8 to your computer and use it in GitHub Desktop.
Check the plugin is exist or not in layout builder
<?php
$display = \Drupal::entityTypeManager()
->getStorage('entity_view_display')
->load($param->getEntityTypeId() . '.' . $param->bundle() . '.default');
if ($display && $display->isLayoutBuilderEnabled()) {
foreach($display->getSections() as $section) {
$result = (bool) array_filter(
$section->getComponents(),
function (SectionComponent $component) use ($plugin_id) {
return $component->getPluginId() === $plugin_id;
}
);
if ($result) {
return TRUE;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment