Verified Commit ba543b96 authored by Dave Long's avatar Dave Long
Browse files

Issue #2985882 by tim.plunkett, Mirakolous, ravi.shankar, ayush9598, Rajab...

Issue #2985882 by tim.plunkett, Mirakolous, ravi.shankar, ayush9598, Rajab Natshah, andypost, Anybody, kattekrab, devarch, Freddy Rodriguez, adubovskoy, corneliusd, mradcliffe, longwave, lukasss, Pancho, Graber, dpi, joshf, lordzik, dorianwinterfeld, jacov, kdmdrupal, jlancaster, jborgesr, joarferme, tonytheferg, chrisrockwell, agilman, kducharm, Sam152, scotwith1t, labboy0276, Spokje, jazzfiction, Shrutidkadam, ab2211, Dave Kopecek, segx, alexmoreno, themaurice, the_glitch, NWOM, kwfinken, berliner, design.er, ouissla, zterry95, jamsilver, fonant, Rajendar Reddy, Christopher Riley, BramDriesen, webdrips: Workaround for "Call to a member function getLabel() after enabling layout_builder"

(cherry picked from commit 4b2afe95)
parent 8f222442
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
use Drupal\Core\Field\FieldConfigInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\Core\Field\FormatterPluginManager;
use Drupal\Core\Logger\LoggerChannelTrait;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Context\EntityContextDefinition;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
@@ -24,6 +25,7 @@
class FieldBlockDeriver extends DeriverBase implements ContainerDeriverInterface {

  use StringTranslationTrait;
  use LoggerChannelTrait;

  /**
   * The entity type repository.
@@ -99,7 +101,12 @@ public function getDerivativeDefinitions($base_plugin_definition) {

        foreach ($field_info['bundles'] as $bundle) {
          $derivative = $base_plugin_definition;
          $field_definition = $this->entityFieldManager->getFieldDefinitions($entity_type_id, $bundle)[$field_name];
          $field_definitions = $this->entityFieldManager->getFieldDefinitions($entity_type_id, $bundle);
          if (empty($field_definitions[$field_name])) {
            $this->getLogger('field')->error('Field %field_name exists but is missing a corresponding field definition and may be misconfigured.', ['%field_name' => "$entity_type_id.$bundle.$field_name"]);
            continue;
          }
          $field_definition = $field_definitions[$field_name];

          // Store the default formatter on the definition.
          $derivative['default_formatter'] = '';