diff --git a/core/lib/Drupal/Core/Field/FormatterPluginManager.php b/core/lib/Drupal/Core/Field/FormatterPluginManager.php index c30ab0e..8c2a959 100644 --- a/core/lib/Drupal/Core/Field/FormatterPluginManager.php +++ b/core/lib/Drupal/Core/Field/FormatterPluginManager.php @@ -95,8 +95,8 @@ public function createInstance($plugin_id, array $configuration) { * - settings: (array) Settings specific to the formatter. Each setting * defaults to the default value specified in the formatter definition. * - * @return \Drupal\Core\Field\FormatterInterface - * A formatter object. + * @return \Drupal\Core\Field\FormatterInterface|null + * A formatter object or NULL when plugin is not found. */ public function getInstance(array $options) { $configuration = $options['configuration']; @@ -117,6 +117,9 @@ public function getInstance(array $options) { if (!isset($definition['class']) || !in_array($field_type, $definition['field_types'])) { // Grab the default widget for the field type. $field_type_definition = $this->fieldTypeManager->getDefinition($field_type); + if (empty($field_type_definition['default_formatter'])) { + return NULL; + } $plugin_id = $field_type_definition['default_formatter']; } diff --git a/core/lib/Drupal/Core/Field/WidgetPluginManager.php b/core/lib/Drupal/Core/Field/WidgetPluginManager.php index 5ca455a..10ec063 100644 --- a/core/lib/Drupal/Core/Field/WidgetPluginManager.php +++ b/core/lib/Drupal/Core/Field/WidgetPluginManager.php @@ -75,8 +75,8 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac * - settings: (array) Settings specific to the widget. Each setting * defaults to the default value specified in the widget definition. * - * @return \Drupal\Core\Field\WidgetInterface - * A Widget object. + * @return \Drupal\Core\Field\WidgetInterface|null + * A Widget object or NULL when plugin is not found. */ public function getInstance(array $options) { // Fill in defaults for missing properties. @@ -103,6 +103,9 @@ public function getInstance(array $options) { if (!isset($definition['class']) || !in_array($field_type, $definition['field_types'])) { // Grab the default widget for the field type. $field_type_definition = $this->fieldTypeManager->getDefinition($field_type); + if (empty($field_type_definition['default_widget'])) { + return NULL; + } $plugin_id = $field_type_definition['default_widget']; } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php index a7e3c5c..d391047 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php @@ -136,7 +136,7 @@ protected function getPluginOptions($field_type) { * {@inheritdoc} */ protected function getDefaultPlugin($field_type) { - return $this->fieldTypes[$field_type]['default_formatter']; + return isset($this->fieldTypes[$field_type]['default_formatter']) ? $this->fieldTypes[$field_type]['default_formatter'] : NULL; } /** diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php index 0f05907..aba308c 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php @@ -103,7 +103,7 @@ protected function getPluginOptions($field_type) { * {@inheritdoc} */ protected function getDefaultPlugin($field_type) { - return $this->fieldTypes[$field_type]['default_widget']; + return isset($this->fieldTypes[$field_type]['default_widget']) ? $this->fieldTypes[$field_type]['default_widget'] : NULL; } /**