Skip to content

Commit d2e31dd

Browse files
authored
Merge pull request #13 from localgovdrupal/master
Let's merge to release branch and tag 1.0.0-alpha3
2 parents ae39181 + 3df8d4b commit d2e31dd

File tree

29 files changed

+270
-233
lines changed

29 files changed

+270
-233
lines changed

composer.json

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
"patches": {
2121
"drupal/viewsreference": {
2222
"Implement configuration schema for Views reference field storage+settings and widget+formatter https://www.drupal.org/project/viewsreference/issues/2957529": "https://www.drupal.org/files/issues/2020-07-16/2957529-10.viewsreference.patch"
23+
},
24+
"drupal/layout_paragraphs": {
25+
"Fix missing schema for link in view mode: https://www.drupal.org/project/layout_paragraphs/issues/3161998": "https://www.drupal.org/files/issues/2020-07-28/missing_link_config_schema-3161998-2.patch"
2326
}
2427
}
2528
}

config/install/field.field.node.localgov_subsites_overview.localgov_subsites_banner.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ entity_type: node
1414
bundle: localgov_subsites_overview
1515
label: Banner
1616
description: ''
17-
required: true
17+
required: false
1818
translatable: false
1919
default_value: { }
2020
default_value_callback: ''
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
langcode: en
2+
status: true
3+
dependencies:
4+
module:
5+
- localgov_subsites
6+
theme:
7+
- localgov_theme
8+
id: subsitebanner
9+
theme: localgov_theme
10+
region: banner
11+
weight: -7
12+
provider: null
13+
plugin: localgov_subsite_banner
14+
settings:
15+
id: localgov_subsite_banner
16+
label: 'Subsite banner'
17+
provider: localgov_subsites
18+
label_display: '0'
19+
context_mapping:
20+
node: '@node.node_route_context:node'
21+
visibility: { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
langcode: en
2+
status: true
3+
dependencies:
4+
module:
5+
- localgov_subsites
6+
theme:
7+
- localgov_theme
8+
id: subsitenavigation
9+
theme: localgov_theme
10+
region: sidebar_second
11+
weight: -7
12+
provider: null
13+
plugin: localgov_subsite_navigation
14+
settings:
15+
id: localgov_subsite_navigation
16+
label: 'Subsite navigation'
17+
provider: localgov_subsites
18+
label_display: visible
19+
context_mapping:
20+
node: '@node.node_route_context:node'
21+
visibility: { }

localgov_subsites.module

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function localgov_subsites_preprocess_page(&$variables) {
5454

5555
if (in_array($node->bundle(), [
5656
'localgov_subsites_overview',
57-
'localgov_subsites_page'
57+
'localgov_subsites_page',
5858
])) {
5959
$subsite = \Drupal::service('class_resolver')
6060
->getInstanceFromDefinition(Subsite::class)

config/install/core.entity_view_display.paragraph.localgov_banner_primary.default.yml renamed to modules/localgov_subsites_paragraphs/config/install/core.entity_view_display.paragraph.localgov_banner_primary.default.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ langcode: en
22
status: true
33
dependencies:
44
config:
5+
- field.field.paragraph.localgov_banner_primary.localgov_image
56
- field.field.paragraph.localgov_banner_primary.localgov_subsites_banner_logo
67
- field.field.paragraph.localgov_banner_primary.localgov_subsites_banner_text
7-
- field.field.paragraph.localgov_banner_primary.localgov_image
88
- field.field.paragraph.localgov_banner_primary.localgov_title
99
- field.field.paragraph.localgov_banner_primary.localgov_url
1010
- paragraphs.paragraphs_type.localgov_banner_primary
@@ -15,6 +15,17 @@ targetEntityType: paragraph
1515
bundle: localgov_banner_primary
1616
mode: default
1717
content:
18+
localgov_image:
19+
weight: 0
20+
label: hidden
21+
settings:
22+
view_mode: responsive_banner
23+
link: false
24+
third_party_settings:
25+
field_formatter_class:
26+
class: ''
27+
type: entity_reference_entity_view
28+
region: content
1829
localgov_subsites_banner_logo:
1930
type: entity_reference_entity_view
2031
weight: 4
@@ -33,17 +44,6 @@ content:
3344
third_party_settings: { }
3445
type: basic_string
3546
region: content
36-
localgov_image:
37-
weight: 0
38-
label: hidden
39-
settings:
40-
view_mode: responsive_hero_or_banner
41-
link: false
42-
third_party_settings:
43-
field_formatter_class:
44-
class: ''
45-
type: entity_reference_entity_view
46-
region: content
4747
localgov_title:
4848
weight: 1
4949
label: hidden

config/install/core.entity_view_display.paragraph.localgov_banner_secondary.default.yml renamed to modules/localgov_subsites_paragraphs/config/install/core.entity_view_display.paragraph.localgov_banner_secondary.default.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ content:
1515
weight: 0
1616
label: hidden
1717
settings:
18-
view_mode: responsive_hero_or_banner
18+
view_mode: responsive_banner
1919
link: false
2020
third_party_settings:
2121
field_formatter_class:

modules/localgov_subsites_paragraphs/config/install/paragraphs.paragraphs_type.localgov_featured_subsite.yml

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
uuid: e479ad59-fd24-447e-9300-9e7f1e9d8c67
21
langcode: en
32
status: true
43
dependencies: { }
5-
_core:
6-
default_config_hash: OhGFgbEq2S7SqeYtg2B2ZrOP6h-peTkJBx_xjKQqtz0
74
id: localgov_featured_subsite
85
label: 'Featured subsite'
96
icon_uuid: null

modules/localgov_subsites_paragraphs/localgov_subsites_paragraphs.module

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ function localgov_subsites_paragraphs_theme($existing, $type, $theme, $path) {
2727
'template' => 'paragraph--localgov-accordion-pane',
2828
'base hook' => 'paragraph',
2929
],
30+
'paragraph__localgov_banner_primary' => [
31+
'template' => 'paragraph--localgov-banner-primary',
32+
'base hook' => 'paragraph',
33+
],
34+
'paragraph__localgov_banner_secondary' => [
35+
'template' => 'paragraph--localgov-banner-secondary',
36+
'base hook' => 'paragraph',
37+
],
3038
'paragraph__localgov_box_link' => [
3139
'template' => 'paragraph--localgov-box-link',
3240
'base hook' => 'paragraph',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div class="bg-white">
2+
<div class="banner-header mx-auto">
3+
<div class="relative subsite-banner{{ call_to_action ? ' subsite-banner--overview' }}">
4+
<div class="subsite-banner__image">
5+
{{ content }}
6+
</div>
7+
</div>
8+
</div>
9+
</div>
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div class="bg-white">
2+
<div class="banner-header mx-auto">
3+
<div class="relative subsite-banner{{ call_to_action ? ' subsite-banner--overview' }}">
4+
<div class="subsite-banner__image">
5+
{{ content }}
6+
</div>
7+
</div>
8+
</div>
9+
</div>
10+

src/Plugin/Block/SubsitesBannerBlock.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@
1111
* id = "localgov_subsite_banner",
1212
* admin_label = "Subsite banner",
1313
* context_definitions = {
14-
* "node" = @ContextDefinition("entity:node", label = @Translation("Current node"))
14+
* "node" = @ContextDefinition(
15+
* "entity:node",
16+
* label = @Translation("Current node"),
17+
* constraints = {
18+
* "Bundle" = {
19+
* "localgov_subsites_overview",
20+
* "localgov_subsites_page"
21+
* },
22+
* }
23+
* )
1524
* }
1625
* )
1726
*/

src/Plugin/Block/SubsitesNavigationBlock.php

+16
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ public function build() {
4040
$items = [];
4141

4242
$subsite_entity = $this->getContextValue('node');
43+
// In some cases, this block might be rendered on a /node/add page. It
44+
// seems that in this instancem the $subsite_entity still exists but will
45+
// not have an id, so we will check first, and return nothing in the absnce
46+
// of an id.
47+
if (!$subsite_entity->id()) {
48+
return;
49+
}
4350
$cache = (new CacheableMetadata())->addCacheableDependency($subsite_entity);
4451
$storage = $this->getNestedSetStorage('localgov_subsites');
4552
$node = $this->getNestedSetNodeKeyFactory()->fromEntity($subsite_entity);
@@ -71,6 +78,12 @@ public function build() {
7178
return $build;
7279
}
7380

81+
/**
82+
* Get nested set tree of links for the menu.
83+
*
84+
* @return array
85+
* Returns and array of nested items.
86+
*/
7487
protected function nestTree($tree, $ancestors, $entities, &$index = 0, $depth = 0) {
7588
$items = $item = [];
7689
do {
@@ -97,6 +110,9 @@ protected function nestTree($tree, $ancestors, $entities, &$index = 0, $depth =
97110
return $items;
98111
}
99112

113+
/**
114+
* {@inheritdoc}
115+
*/
100116
protected function formatItem(EntityInterface $entity, $in_active_trail) {
101117
$link = [];
102118
$link['title'] = $entity->label();

src/Subsite.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ public function getSubsite($node) {
5656
if ($node instanceof NodeInterface) {
5757
if ($node->bundle() === 'localgov_subsites_overview') {
5858
$entity = $node;
59-
} elseif ($id = $this->getRootId($node)) {
59+
}
60+
elseif ($id = $this->getRootId($node)) {
6061
$entity = $this->entityTypeManager->getStorage('node')->load($id);
6162
}
6263
}
6364

6465
return $entity;
6566
}
67+
6668
}

0 commit comments

Comments
 (0)