diff --git a/modules/ui_patterns_layouts/src/Plugin/Layout/PatternLayout.php b/modules/ui_patterns_layouts/src/Plugin/Layout/PatternLayout.php index fcbddd8aebf250cffb06d098e8808b7652778d6c..c3ade96677447ac51a6fa78f415d0ff8079e8dcd 100644 --- a/modules/ui_patterns_layouts/src/Plugin/Layout/PatternLayout.php +++ b/modules/ui_patterns_layouts/src/Plugin/Layout/PatternLayout.php @@ -4,6 +4,7 @@ namespace Drupal\ui_patterns_layouts\Plugin\Layout; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Layout\LayoutDefault; +use Drupal\Core\Layout\LayoutDefinition; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\PluginFormInterface; use Drupal\ui_patterns\UiPatternsManager; @@ -30,12 +31,12 @@ class PatternLayout extends LayoutDefault implements PluginFormInterface, Contai * A configuration array containing information about the plugin instance. * @param string $plugin_id * The plugin_id for the plugin instance. - * @param mixed $plugin_definition + * @param \Drupal\Core\Layout\LayoutDefinition $plugin_definition * The plugin implementation definition. * @param \Drupal\ui_patterns\UiPatternsManager $pattern_manager * Pattern manager service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, UiPatternsManager $pattern_manager) { + public function __construct(array $configuration, $plugin_id, LayoutDefinition $plugin_definition, UiPatternsManager $pattern_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->patternManager = $pattern_manager; } @@ -57,7 +58,6 @@ class PatternLayout extends LayoutDefault implements PluginFormInterface, Contai */ public function build(array $regions) { $configuration = $this->getConfiguration(); - $definition = $this->getPluginDefinition(); // Remove default field template if "Only content" option has been selected. if ($configuration['pattern']['field_templates'] == 'only_content') { @@ -72,7 +72,7 @@ class PatternLayout extends LayoutDefault implements PluginFormInterface, Contai return [ '#type' => 'pattern', - '#id' => $definition['pattern'], + '#id' => $this->getPluginDefinition()->get('additional')['pattern'], '#fields' => $fields, ]; } diff --git a/modules/ui_patterns_layouts/ui_patterns_layouts.module b/modules/ui_patterns_layouts/ui_patterns_layouts.module index b0a07b9d3b150b544b0b3911e424c8557faabf52..27b4bdbd1c6e7ff06a418df6c2200118e6575d3a 100644 --- a/modules/ui_patterns_layouts/ui_patterns_layouts.module +++ b/modules/ui_patterns_layouts/ui_patterns_layouts.module @@ -12,7 +12,7 @@ use Drupal\Core\Layout\LayoutDefinition; * Implements hook_layout_alter(). */ function ui_patterns_layouts_layout_alter(&$definitions) { - + // @todo: Use layout deriver instead. $pattern_definitions = \Drupal::service('plugin.manager.ui_patterns')->getDefinitions(); foreach ($pattern_definitions as $pattern_definition) { $definition = [ @@ -24,8 +24,8 @@ function ui_patterns_layouts_layout_alter(&$definitions) { 'pattern' => $pattern_definition['id'], 'template' => 'pattern-' . $pattern_definition['id'], ]; - foreach ($pattern_definition['fields'] as $field_name => $field) { - $definition['regions'][$field_name]['label'] = $field['label']; + foreach ($pattern_definition['fields'] as $field) { + $definition['regions'][$field['name']]['label'] = $field['label']; } $definitions['pattern_' . $pattern_definition['id']] = new LayoutDefinition($definition); } diff --git a/modules/ui_patterns_test/config/install/core.entity_form_display.node.article.default.yml b/modules/ui_patterns_test/config/install/core.entity_form_display.node.article.default.yml index 8985cf959622dd72547874e58534129c75138c59..76699b9ce8b592739c6eaf9c4647836f501b7031 100644 --- a/modules/ui_patterns_test/config/install/core.entity_form_display.node.article.default.yml +++ b/modules/ui_patterns_test/config/install/core.entity_form_display.node.article.default.yml @@ -13,6 +13,8 @@ dependencies: module: - comment - image + - link + - paragraphs - path - text id: node.article.default @@ -28,45 +30,76 @@ content: summary_rows: 3 placeholder: '' third_party_settings: { } + region: content comment: type: comment_default - weight: 20 + weight: 8 settings: { } third_party_settings: { } + region: content created: type: datetime_timestamp - weight: 10 + weight: 5 settings: { } third_party_settings: { } + region: content field_image: type: image_image - weight: 4 + weight: 3 settings: progress_indicator: throbber preview_image_style: thumbnail third_party_settings: { } + region: content + field_links: + type: link_default + weight: 11 + region: content + settings: + placeholder_url: '' + placeholder_title: '' + third_party_settings: { } + field_paragraphs: + type: entity_reference_paragraphs + weight: 10 + region: content + settings: + title: Paragraph + title_plural: Paragraphs + edit_mode: open + add_mode: dropdown + form_display_mode: default + default_paragraph_type: '' + third_party_settings: { } field_tags: type: entity_reference_autocomplete_tags - weight: 3 - settings: { } + weight: 2 + settings: + match_operator: CONTAINS + size: 60 + placeholder: '' third_party_settings: { } + region: content path: type: path - weight: 30 + weight: 9 settings: { } third_party_settings: { } + region: content promote: type: boolean_checkbox settings: display_label: true - weight: 15 + weight: 6 third_party_settings: { } + region: content sticky: type: boolean_checkbox settings: display_label: true - weight: 16 + weight: 7 third_party_settings: { } + region: content title: type: string_textfield weight: 0 @@ -74,14 +107,14 @@ content: size: 60 placeholder: '' third_party_settings: { } + region: content uid: type: entity_reference_autocomplete - weight: 5 + weight: 4 settings: match_operator: CONTAINS size: 60 placeholder: '' third_party_settings: { } -hidden: - field_links: true - field_paragraphs: true + region: content +hidden: { } diff --git a/modules/ui_patterns_test/config/install/core.entity_form_display.paragraph.jumbotron.default.yml b/modules/ui_patterns_test/config/install/core.entity_form_display.paragraph.jumbotron.default.yml index 19ac3c2e86a7090f1d083b456a22bf05f714076c..351fa2889f52026054810e7a95aad7267254298d 100644 --- a/modules/ui_patterns_test/config/install/core.entity_form_display.paragraph.jumbotron.default.yml +++ b/modules/ui_patterns_test/config/install/core.entity_form_display.paragraph.jumbotron.default.yml @@ -17,6 +17,7 @@ content: placeholder: '' third_party_settings: { } type: string_textarea + region: content field_title: weight: 0 settings: @@ -24,6 +25,7 @@ content: placeholder: '' third_party_settings: { } type: string_textfield + region: content hidden: created: true status: true diff --git a/modules/ui_patterns_test/config/install/core.entity_view_display.node.article.default.yml b/modules/ui_patterns_test/config/install/core.entity_view_display.node.article.default.yml index 56160d4fe8382378bbf41bb2a3d6aec42993930b..d4f0a40510bc58fb07683026145d7c6ed804937b 100644 --- a/modules/ui_patterns_test/config/install/core.entity_view_display.node.article.default.yml +++ b/modules/ui_patterns_test/config/install/core.entity_view_display.node.article.default.yml @@ -27,6 +27,7 @@ content: settings: { } third_party_settings: { } label: hidden + region: content comment: type: comment_default weight: 110 @@ -35,6 +36,7 @@ content: view_mode: default pager_id: 0 third_party_settings: { } + region: content field_image: type: image weight: -1 @@ -43,6 +45,7 @@ content: image_link: '' third_party_settings: { } label: hidden + region: content field_tags: type: entity_reference_label weight: 10 @@ -50,8 +53,10 @@ content: settings: link: true third_party_settings: { } + region: content links: weight: 100 + region: content hidden: field_image: true field_links: true diff --git a/modules/ui_patterns_test/config/install/core.entity_view_display.node.article.full.yml b/modules/ui_patterns_test/config/install/core.entity_view_display.node.article.full.yml index 099273acc67b5765d342552d758f8074e93caf20..13e28fb7233a5a5e1ddb8c6598ca8cd80fb8bdd2 100644 --- a/modules/ui_patterns_test/config/install/core.entity_view_display.node.article.full.yml +++ b/modules/ui_patterns_test/config/install/core.entity_view_display.node.article.full.yml @@ -120,6 +120,7 @@ content: plugin: ds_field_template source: body label: hidden + region: content field_image: type: image weight: 1 @@ -135,6 +136,7 @@ content: lb-col: false classes: { } label: hidden + region: content field_links: type: link weight: 4 @@ -163,6 +165,7 @@ content: weight: 1 plugin: ds_field_template source: field_links__title + region: content field_paragraphs: type: entity_reference_revisions_entity_view weight: 3 @@ -171,6 +174,7 @@ content: view_mode: default link: '' third_party_settings: { } + region: content field_tags: type: entity_reference_label weight: 9 @@ -180,6 +184,7 @@ content: third_party_settings: ds: ds_limit: '' + region: content hidden: comment: true links: true diff --git a/modules/ui_patterns_test/config/install/core.entity_view_display.paragraph.jumbotron.default.yml b/modules/ui_patterns_test/config/install/core.entity_view_display.paragraph.jumbotron.default.yml index b8398d5efb679f719085acf3ddd6b2cef6eb7818..cff61ce130518c9857b410fb24c51b0be1074e18 100644 --- a/modules/ui_patterns_test/config/install/core.entity_view_display.paragraph.jumbotron.default.yml +++ b/modules/ui_patterns_test/config/install/core.entity_view_display.paragraph.jumbotron.default.yml @@ -11,8 +11,7 @@ third_party_settings: ds: layout: id: pattern_jumbotron - path: null - library: '' + library: null disable_css: false entity_classes: all_classes settings: @@ -29,18 +28,20 @@ bundle: jumbotron mode: default content: field_subtitle: + type: basic_string weight: 1 - label: above + region: subtitle + label: hidden settings: { } third_party_settings: { } - type: basic_string field_title: + type: string weight: 0 - label: above + region: title + label: hidden settings: link_to_entity: false third_party_settings: { } - type: string hidden: created: true uid: true diff --git a/modules/ui_patterns_test/ui_patterns_test.features.yml b/modules/ui_patterns_test/ui_patterns_test.features.yml index 01913257d07097e2b84161820862f75a14766c05..a8e255b84c7462f6d27efcfe7cc655adc96a8f01 100644 --- a/modules/ui_patterns_test/ui_patterns_test.features.yml +++ b/modules/ui_patterns_test/ui_patterns_test.features.yml @@ -1,16 +1,3 @@ excluded: - - block.block.ui_patterns_test_theme_account_menu - - block.block.ui_patterns_test_theme_branding - - block.block.ui_patterns_test_theme_breadcrumbs - - block.block.ui_patterns_test_theme_content - - block.block.ui_patterns_test_theme_footer - - block.block.ui_patterns_test_theme_help - - block.block.ui_patterns_test_theme_local_actions - - block.block.ui_patterns_test_theme_local_tasks - - block.block.ui_patterns_test_theme_main_menu - - block.block.ui_patterns_test_theme_messages - - block.block.ui_patterns_test_theme_powered - - block.block.ui_patterns_test_theme_search - - block.block.ui_patterns_test_theme_tools - ui_patterns_test_theme.settings required: true diff --git a/modules/ui_patterns_test/ui_patterns_test.info.yml b/modules/ui_patterns_test/ui_patterns_test.info.yml index 97a5110f1d9f6e4c922c8e73adedd408273ead84..8c274fe2aa144879c50d075fe21ace7aac92ab59 100644 --- a/modules/ui_patterns_test/ui_patterns_test.info.yml +++ b/modules/ui_patterns_test/ui_patterns_test.info.yml @@ -30,8 +30,8 @@ dependencies: - ui_patterns_ds - ui_patterns_field_group - ui_patterns_layouts - - ui_patterns_views - ui_patterns_library + - ui_patterns_views - user - views - views_ui