Skip to content

Commit bad2d66

Browse files
bugfix(CMS-499): Create module to serialize out data story references (#1721)
1 parent ae2593d commit bad2d66

File tree

3 files changed

+69
-2
lines changed

3 files changed

+69
-2
lines changed

web/modules/custom/sfgov_api/src/Plugin/SfgApi/Node/ResourceCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public function setCustomData($entity) {
2929
'description' => $entity->get('field_description')->value,
3030
'data_dashboard' => $this->getReferencedData($entity->get('field_data_dashboard')->referencedEntities()),
3131
'introductory_text' => $this->getReferencedData($entity->get('field_introductory_text')->referencedEntities()),
32-
// 'documents' => $this->getReferencedData($entity->get('field_paragraphs')->referencedEntities()), // needs to be created in wagtail
33-
// 'custom_section' => $this->getReferencedData($entity->get('field_content_bottom')->referencedEntities()), // needs to be updated in wagtail
32+
'documents' => $this->getReferencedData($entity->get('field_paragraphs')->referencedEntities()), // needs to be created in wagtail
33+
'custom_section' => $this->getReferencedData($entity->get('field_content_bottom')->referencedEntities()), // needs to be updated in wagtail
3434
'related_agencies' => $this->getReferencedEntity($entity->get('field_departments')->referencedEntities()),
3535
'related_topics' => $this->getReferencedEntity($entity->get('field_topics')->referencedEntities()),
3636
];
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Drupal\sfgov_api\Plugin\SfgApi\Paragraph;
4+
5+
use Drupal\sfgov_api\Plugin\SfgApi\ApiFieldHelperTrait;
6+
7+
/**
8+
* Plugin implementation of the sfgov_api.
9+
*
10+
* @SfgApi(
11+
* id = "paragraph_data_story_reference_section",
12+
* title = @Translation("Paragraph data_story_reference_section"),
13+
* bundle = "data_story_reference_section",
14+
* wag_bundle = "data_story_reference_section",
15+
* entity_id = {},
16+
* langcode = {},
17+
* shape = {},
18+
* )
19+
*/
20+
class DataStoryReferenceSection extends SfgApiParagraphBase {
21+
22+
use ApiFieldHelperTrait;
23+
24+
/**
25+
* {@inheritDoc}
26+
*/
27+
public function setCustomData($entity) {
28+
return [
29+
'content' => $this->getReferencedData($entity->get('field_content')->referencedEntities()),
30+
];
31+
}
32+
33+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Drupal\sfgov_api\Plugin\SfgApi\Paragraph;
4+
5+
use Drupal\sfgov_api\Plugin\SfgApi\ApiFieldHelperTrait;
6+
7+
/**
8+
* Plugin implementation of the sfgov_api.
9+
*
10+
* @SfgApi(
11+
* id = "paragraph_data_story_reference_subsection",
12+
* title = @Translation("Paragraph data_story_reference_subsection"),
13+
* bundle = "data_story_reference_subsection",
14+
* wag_bundle = "data_story_reference_subsection",
15+
* entity_id = {},
16+
* langcode = {},
17+
* shape = {},
18+
* )
19+
*/
20+
class DataStoryReferenceSubSection extends SfgApiParagraphBase {
21+
22+
use ApiFieldHelperTrait;
23+
24+
/**
25+
* {@inheritDoc}
26+
*/
27+
public function setCustomData($entity) {
28+
return [
29+
'resources' => $this->getReferencedData($entity->get('field_data_story')->referencedEntities()),
30+
'title' => $entity->get('field_title')->value,
31+
];
32+
}
33+
34+
}

0 commit comments

Comments
 (0)