-
Notifications
You must be signed in to change notification settings - Fork 39
/
NodeLandingPage.php
56 lines (46 loc) · 1.59 KB
/
NodeLandingPage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace Drupal\server_general\Plugin\EntityViewBuilder;
use Drupal\node\NodeInterface;
use Drupal\server_general\EntityViewBuilder\NodeViewBuilderAbstract;
use Drupal\server_general\TitleAndLabelsTrait;
/**
* The "Node Landing Page" plugin.
*
* @EntityViewBuilder(
* id = "node.landing_page",
* label = @Translation("Node - Landing Page"),
* description = "Node view builder for Landing Page bundle."
* )
*/
class NodeLandingPage extends NodeViewBuilderAbstract {
use TitleAndLabelsTrait;
/**
* Build full view mode.
*
* @param array $build
* The existing build.
* @param \Drupal\node\NodeInterface $entity
* The entity.
*
* @return array
* Render array.
*/
public function buildFull(array $build, NodeInterface $entity) {
$elements = [];
// Show the page title, unless it was set to be hidden.
if (!$this->getBooleanFieldValue($entity, 'field_is_title_hidden')) {
$element = $this->buildPageTitle($entity->label());
$elements[] = $this->wrapContainerWide($element);
}
/** @var \Drupal\Core\Field\EntityReferenceFieldItemListInterface $paragraphs */
$paragraphs = $entity->get('field_paragraphs');
// Paragraphs.
$element = $this->buildReferencedEntities($paragraphs);
$elements[] = $this->wrapContainerVerticalSpacingBig($element);
$elements = $this->wrapContainerVerticalSpacingBig($elements);
// Add bottom padding, so there's some padding between all the paragraphs
// and the footer.
$build[] = $this->wrapConditionalContainerBottomPadding($elements, $paragraphs);
return $build;
}
}