Loading core/lib/Drupal/Core/Field/FallbackFieldTypeCategory.php +4 −3 Original line number Diff line number Diff line Loading @@ -10,13 +10,14 @@ class FallbackFieldTypeCategory extends FieldTypeCategory { /** * {@inheritdoc} */ public function __construct(array $configuration) { public function __construct(array $configuration, string $plugin_id, array $plugin_definition) { $plugin_id = $configuration['unique_identifier']; $plugin_definition = [ 'label' => $configuration['label'] ?? '', 'description' => $configuration['description'] ?? '', 'weight' => $configuration['weight'] ?? 0, ]; parent::__construct($configuration, $configuration['unique_identifier'], $plugin_definition); ] + $plugin_definition; parent::__construct($configuration, $plugin_id, $plugin_definition); } } core/lib/Drupal/Core/Field/FieldTypeCategory.php +7 −0 Original line number Diff line number Diff line Loading @@ -33,4 +33,11 @@ public function getWeight(): int { return $this->pluginDefinition['weight']; } /** * {@inheritdoc} */ public function getLibraries(): array { return $this->pluginDefinition['libraries'] ?? []; } } core/lib/Drupal/Core/Field/FieldTypeCategoryInterface.php +8 −0 Original line number Diff line number Diff line Loading @@ -33,4 +33,12 @@ public function getDescription(): TranslatableMarkup; */ public function getWeight(): int; /** * Returns asset libraries for the field group. * * @return array * The asset libraries to attach. */ public function getLibraries(): array; } core/lib/Drupal/Core/Field/FieldTypeCategoryManager.php +4 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ * label: STRING * description: STRING * weight: INTEGER * libraries: * - STRING * @endcode * For example: * @code Loading @@ -26,6 +28,8 @@ * label: Text * description: Text fields. * weight: 2 * libraries: * - module_name/library_name * @endcode * * @see \Drupal\Core\Field\FieldTypeCategoryInterface Loading core/modules/comment/comment.module +8 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Core\Entity\Entity\EntityViewMode; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Field\FieldTypeCategoryManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; Loading Loading @@ -785,8 +786,12 @@ function comment_entity_view_display_presave(EntityViewDisplayInterface $display } /** * Implements hook_preprocess_form_element__new_storage_type(). * Implements hook_field_type_category_info_alter(). */ function comment_preprocess_form_element__new_storage_type(&$variables) { $variables['#attached']['library'][] = 'comment/drupal.comment-icon'; function comment_field_type_category_info_alter(&$definitions) { // TRICKY: the `comment` field type belongs in the `general` category, so the // libraries need to be attached using an alter hook. if (array_key_exists(FieldTypeCategoryManagerInterface::FALLBACK_CATEGORY, $definitions)) { $definitions[FieldTypeCategoryManagerInterface::FALLBACK_CATEGORY]['libraries'][] = 'comment/drupal.comment-icon'; } } Loading
core/lib/Drupal/Core/Field/FallbackFieldTypeCategory.php +4 −3 Original line number Diff line number Diff line Loading @@ -10,13 +10,14 @@ class FallbackFieldTypeCategory extends FieldTypeCategory { /** * {@inheritdoc} */ public function __construct(array $configuration) { public function __construct(array $configuration, string $plugin_id, array $plugin_definition) { $plugin_id = $configuration['unique_identifier']; $plugin_definition = [ 'label' => $configuration['label'] ?? '', 'description' => $configuration['description'] ?? '', 'weight' => $configuration['weight'] ?? 0, ]; parent::__construct($configuration, $configuration['unique_identifier'], $plugin_definition); ] + $plugin_definition; parent::__construct($configuration, $plugin_id, $plugin_definition); } }
core/lib/Drupal/Core/Field/FieldTypeCategory.php +7 −0 Original line number Diff line number Diff line Loading @@ -33,4 +33,11 @@ public function getWeight(): int { return $this->pluginDefinition['weight']; } /** * {@inheritdoc} */ public function getLibraries(): array { return $this->pluginDefinition['libraries'] ?? []; } }
core/lib/Drupal/Core/Field/FieldTypeCategoryInterface.php +8 −0 Original line number Diff line number Diff line Loading @@ -33,4 +33,12 @@ public function getDescription(): TranslatableMarkup; */ public function getWeight(): int; /** * Returns asset libraries for the field group. * * @return array * The asset libraries to attach. */ public function getLibraries(): array; }
core/lib/Drupal/Core/Field/FieldTypeCategoryManager.php +4 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ * label: STRING * description: STRING * weight: INTEGER * libraries: * - STRING * @endcode * For example: * @code Loading @@ -26,6 +28,8 @@ * label: Text * description: Text fields. * weight: 2 * libraries: * - module_name/library_name * @endcode * * @see \Drupal\Core\Field\FieldTypeCategoryInterface Loading
core/modules/comment/comment.module +8 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Core\Entity\Entity\EntityViewMode; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Field\FieldTypeCategoryManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; Loading Loading @@ -785,8 +786,12 @@ function comment_entity_view_display_presave(EntityViewDisplayInterface $display } /** * Implements hook_preprocess_form_element__new_storage_type(). * Implements hook_field_type_category_info_alter(). */ function comment_preprocess_form_element__new_storage_type(&$variables) { $variables['#attached']['library'][] = 'comment/drupal.comment-icon'; function comment_field_type_category_info_alter(&$definitions) { // TRICKY: the `comment` field type belongs in the `general` category, so the // libraries need to be attached using an alter hook. if (array_key_exists(FieldTypeCategoryManagerInterface::FALLBACK_CATEGORY, $definitions)) { $definitions[FieldTypeCategoryManagerInterface::FALLBACK_CATEGORY]['libraries'][] = 'comment/drupal.comment-icon'; } }