Make map behavior library optional.

This commit is contained in:
Michael Stenta 2024-01-20 11:49:38 -05:00
parent cce51328c0
commit f7e6318026
1 changed files with 4 additions and 2 deletions

View File

@ -92,8 +92,10 @@ class MapRenderEvent extends Event {
/** @var \Drupal\farm_map\Entity\MapBehaviorInterface $behavior */
$behavior = $this->entityTypeManager->getStorage('map_behavior')->load($behavior_name);
// Attach the library.
$this->element['#attached']['library'][] = $behavior->getLibrary();
// If the behavior has a library, attach it.
if (!empty($behavior->getLibrary())) {
$this->element['#attached']['library'][] = $behavior->getLibrary();
}
// Add behavior settings if supplied.
if (!empty($settings)) {