Created
August 16, 2023 22:18
-
-
Save ahebrank/9af2ab70264ee773208496613601223a to your computer and use it in GitHub Desktop.
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
diff --git a/embederator.theme.inc b/embederator.theme.inc | |
index 91df87e..4165143 100644 | |
--- a/embederator.theme.inc | |
+++ b/embederator.theme.inc | |
@@ -31,7 +31,9 @@ function template_preprocess_embederator(array &$variables) { | |
// Add the wrapper class from the entity config. | |
$entity_type = \Drupal::service('entity_type.manager')->getStorage('embederator_type')->load($bundle_id); | |
- $variables['wrapper_class'] = $entity_type->getWrapperClass(); | |
+ if (!is_null($entity_type)) { | |
+ $variables['wrapper_class'] = $entity_type->getWrapperClass(); | |
+ } | |
} | |
/** | |
diff --git a/src/Plugin/Field/FieldFormatter/EmbederatorFormatter.php b/src/Plugin/Field/FieldFormatter/EmbederatorFormatter.php | |
index 25d669a..9e3f015 100644 | |
--- a/src/Plugin/Field/FieldFormatter/EmbederatorFormatter.php | |
+++ b/src/Plugin/Field/FieldFormatter/EmbederatorFormatter.php | |
@@ -36,6 +36,13 @@ class EmbederatorFormatter extends FormatterBase { | |
$type = $entity->getType(); | |
$embederator_type = $entity_manager->getStorage('embederator_type')->load($type); | |
+ $elements = []; | |
+ | |
+ if (is_null($embederator_type)) { | |
+ // Something went wrong. | |
+ return $elements; | |
+ } | |
+ | |
// Hook context. | |
$context = [ | |
'embederator_type' => $embederator_type, | |
@@ -43,8 +50,6 @@ class EmbederatorFormatter extends FormatterBase { | |
'settings' => $settings, | |
]; | |
- $elements = []; | |
- | |
// Determine laziness. | |
$loadstyle = $this->getSetting('loadstyle'); | |
if ($loadstyle == 'noquery') { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment