Last active
February 23, 2022 17:30
-
-
Save miteshmap/f8d33b936e658334b54470033e8928b8 to your computer and use it in GitHub Desktop.
Check the plugin is exist or not in layout builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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