public function SocialContentBlockLandingPageContentBuilder::build in Open Social 8.9
Same name and namespace in other branches
- 10.3.x modules/social_features/social_content_block/modules/social_content_block_landing_page/src/Service/SocialContentBlockLandingPageContentBuilder.php \Drupal\social_content_block_landing_page\Service\SocialContentBlockLandingPageContentBuilder::build()
- 10.0.x modules/social_features/social_content_block/modules/social_content_block_landing_page/src/Service/SocialContentBlockLandingPageContentBuilder.php \Drupal\social_content_block_landing_page\Service\SocialContentBlockLandingPageContentBuilder::build()
- 10.1.x modules/social_features/social_content_block/modules/social_content_block_landing_page/src/Service/SocialContentBlockLandingPageContentBuilder.php \Drupal\social_content_block_landing_page\Service\SocialContentBlockLandingPageContentBuilder::build()
- 10.2.x modules/social_features/social_content_block/modules/social_content_block_landing_page/src/Service/SocialContentBlockLandingPageContentBuilder.php \Drupal\social_content_block_landing_page\Service\SocialContentBlockLandingPageContentBuilder::build()
Lazy builder callback for displaying a content blocks.
Parameters
int $entity_id: Entity ID.
string $entity_type_id: Entity type id.
string $entity_bundle: The bundle of the entity.
Return value
array A render array for the action link, empty if the user does not have access.
Overrides ContentBuilder::build
File
- modules/
social_features/ social_content_block/ modules/ social_content_block_landing_page/ src/ Service/ SocialContentBlockLandingPageContentBuilder.php, line 19
Class
- SocialContentBlockLandingPageContentBuilder
- Class SocialContentBlockLandingPageContentBuilder.
Namespace
Drupal\social_content_block_landing_page\ServiceCode
public function build($entity_id, $entity_type_id, $entity_bundle) : array {
$build = parent::build($entity_id, $entity_type_id, $entity_bundle);
if (!$build) {
return $build;
}
$weight = 1;
foreach (Element::children($build['content']) as $key) {
$build['content'][$key]['#weight'] = $weight++;
}
$build['content']['title'] = [
'#type' => 'html_tag',
'#tag' => 'h2',
'#attributes' => [
'class' => [
'title',
],
],
'#value' => $this->entityTypeManager
->getStorage($entity_type_id)
->load($entity_id)->field_subtitle->value,
'#weight' => 0,
];
if (!isset($build['content']['entities']['#markup']) && !isset($build['content']['entities']['#lazy_builder'])) {
$build['content']['entities']['#prefix'] = str_replace('content-list__items', 'field--name-field-featured-items', $build['content']['entities']['#prefix']);
}
return $build;
}