private function DemoSystem::replaceAnBlock in Open Social 8.4
Same name and namespace in other branches
- 8.9 modules/custom/social_demo/src/DemoSystem.php \Drupal\social_demo\DemoSystem::replaceAnBlock()
- 8 modules/custom/social_demo/src/DemoSystem.php \Drupal\social_demo\DemoSystem::replaceAnBlock()
- 8.2 modules/custom/social_demo/src/DemoSystem.php \Drupal\social_demo\DemoSystem::replaceAnBlock()
- 8.3 modules/custom/social_demo/src/DemoSystem.php \Drupal\social_demo\DemoSystem::replaceAnBlock()
- 8.5 modules/custom/social_demo/src/DemoSystem.php \Drupal\social_demo\DemoSystem::replaceAnBlock()
- 8.6 modules/custom/social_demo/src/DemoSystem.php \Drupal\social_demo\DemoSystem::replaceAnBlock()
- 8.7 modules/custom/social_demo/src/DemoSystem.php \Drupal\social_demo\DemoSystem::replaceAnBlock()
- 8.8 modules/custom/social_demo/src/DemoSystem.php \Drupal\social_demo\DemoSystem::replaceAnBlock()
- 10.3.x modules/custom/social_demo/src/DemoSystem.php \Drupal\social_demo\DemoSystem::replaceAnBlock()
- 10.0.x modules/custom/social_demo/src/DemoSystem.php \Drupal\social_demo\DemoSystem::replaceAnBlock()
- 10.1.x modules/custom/social_demo/src/DemoSystem.php \Drupal\social_demo\DemoSystem::replaceAnBlock()
- 10.2.x modules/custom/social_demo/src/DemoSystem.php \Drupal\social_demo\DemoSystem::replaceAnBlock()
Function to replace the AN homepage Block.
Parameters
\Drupal\block_content\Entity\BlockContent $block: The block.
array $data: The data.
1 call to DemoSystem::replaceAnBlock()
- DemoSystem::createContent in modules/
custom/ social_demo/ src/ DemoSystem.php - Creates content.
File
- modules/
custom/ social_demo/ src/ DemoSystem.php, line 297
Class
- DemoSystem
- Class DemoSystem.
Namespace
Drupal\social_demoCode
private function replaceAnBlock(BlockContent $block, array $data) {
$block->field_text_block = [
'value' => $data['textblock'],
'format' => 'full_html',
];
/* @var \Drupal\file\Entity\File $file */
$block_image = $this
->prepareImage($data['image'], 'Anonymous front page image homepage');
// Insert is in the hero image field.
$block->field_hero_image = $block_image;
// Set the links.
$action_links = [
[
'uri' => 'internal:' . $data['cta1']['url'],
'title' => $data['cta1']['text'],
],
[
'uri' => 'internal:' . $data['cta2']['url'],
'title' => $data['cta2']['text'],
],
];
$itemList = new FieldItemList($block->field_call_to_action_link
->getFieldDefinition());
$itemList
->setValue($action_links);
$block->field_call_to_action_link = $itemList;
$block
->save();
}