Skip to content
Snippets Groups Projects
Commit 30c387fb authored by Mikael Meulle's avatar Mikael Meulle
Browse files

Issue #3513546 by just_like_good_vibes, liam morland: TypeError:...

Issue #3513546 by just_like_good_vibes, liam morland: TypeError: ::findEntityBundleWithField(): $entity_type_id must be of type string, null given
parent c6474735
Branches
Tags
1 merge request!352Issue #3513546 by just_like_good_vibes: TypeError: ::findEntityBundleWithField(): $entity_type_id must be of type string, null given
Pipeline #451285 passed
......@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Drupal\ui_patterns_field_formatters\Plugin\Field\FieldFormatter;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Form\FormStateInterface;
......@@ -215,6 +216,9 @@ abstract class ComponentFormatterBase extends FormatterBase {
if (!$entity) {
$entity = $this->chainContextEntityResolver->guessEntity($contexts);
}
if (!$entity_type_id) {
return $contexts;
}
if (!$entity || !$this->checkEntityHasField($entity, $entity_type_id, $field_name)) {
// Generate a default bundle when it is missing,
// this covers contexts like the display of a field in a view.
......@@ -227,6 +231,13 @@ abstract class ComponentFormatterBase extends FormatterBase {
return $contexts;
}
/**
* {@inheritdoc}
*/
public static function isApplicable(FieldDefinitionInterface $field_definition) {
return ($field_definition->getTargetEntityTypeId() !== NULL) && parent::isApplicable($field_definition);
}
/**
* {@inheritdoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment