class SocialContentBlockLandingPageContentBuilder in Open Social 10.0.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_content_block/modules/social_content_block_landing_page/src/Service/SocialContentBlockLandingPageContentBuilder.php \Drupal\social_content_block_landing_page\Service\SocialContentBlockLandingPageContentBuilder
- 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
- 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
- 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
Class SocialContentBlockLandingPageContentBuilder.
@package Drupal\social_content_block_landing_page\Service
Hierarchy
- class \Drupal\social_content_block\ContentBuilder implements TrustedCallbackInterface, ContentBuilderInterface uses StringTranslationTrait
- class \Drupal\social_content_block_landing_page\Service\SocialContentBlockLandingPageContentBuilder implements TrustedCallbackInterface
Expanded class hierarchy of SocialContentBlockLandingPageContentBuilder
1 string reference to 'SocialContentBlockLandingPageContentBuilder'
- social_content_block_landing_page.services.yml in modules/
social_features/ social_content_block/ modules/ social_content_block_landing_page/ social_content_block_landing_page.services.yml - modules/social_features/social_content_block/modules/social_content_block_landing_page/social_content_block_landing_page.services.yml
1 service uses SocialContentBlockLandingPageContentBuilder
- social_content_block_landing_page.content_builder in modules/
social_features/ social_content_block/ modules/ social_content_block_landing_page/ social_content_block_landing_page.services.yml - Drupal\social_content_block_landing_page\Service\SocialContentBlockLandingPageContentBuilder
File
- modules/
social_features/ social_content_block/ modules/ social_content_block_landing_page/ src/ Service/ SocialContentBlockLandingPageContentBuilder.php, line 15
Namespace
Drupal\social_content_block_landing_page\ServiceView source
class SocialContentBlockLandingPageContentBuilder extends ContentBuilder implements TrustedCallbackInterface {
/**
* {@inheritdoc}
*/
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;
}
/**
* {@inheritdoc}
*/
public function getEntities($block_id) {
$elements = parent::getEntities($block_id);
foreach (Element::children($elements) as $delta) {
$elements[$delta]['#custom_content_list_section'] = TRUE;
}
return $elements;
}
/**
* {@inheritdoc}
*/
protected function getLink(BlockContentInterface $block_content) : array {
if ($link = parent::getLink($block_content)) {
$link['#url']
->setOption('attributes', []);
$link = [
'#type' => 'container',
'#attributes' => [
'class' => [
'card__link',
],
],
'link' => $link,
];
}
return $link;
}
/**
* {@inheritdoc}
*/
public static function trustedCallbacks() {
return [
'build',
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContentBuilder:: |
protected | property | The current active database's master connection. | |
ContentBuilder:: |
protected | property | The content block manager. | |
ContentBuilder:: |
protected | property | The entity type manager. | |
ContentBuilder:: |
protected | property | The module handler service. | |
ContentBuilder:: |
public static | function | Process callback to insert a Custom Block form. | |
ContentBuilder:: |
protected | function | Sorting and range logic by specific case. | |
ContentBuilder:: |
public | function | Update the sorting field after a plugin choice change. | |
ContentBuilder:: |
public | function | ContentBuilder constructor. | |
SocialContentBlockLandingPageContentBuilder:: |
public | function |
Lazy builder callback for displaying a content blocks. Overrides ContentBuilder:: |
|
SocialContentBlockLandingPageContentBuilder:: |
public | function |
Function to get all the entities based on the filters. Overrides ContentBuilder:: |
|
SocialContentBlockLandingPageContentBuilder:: |
protected | function |
Function to generate the read more link. Overrides ContentBuilder:: |
|
SocialContentBlockLandingPageContentBuilder:: |
public static | function |
Lists the trusted callbacks provided by the implementing class. Overrides ContentBuilder:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
TrustedCallbackInterface:: |
constant | Untrusted callbacks throw exceptions. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger E_USER_WARNING errors. |