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();
  }
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();
  }
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 ( ) ; }
Function to replace the AN homepage Block.

@param \Drupal\block_content\Entity\BlockContent $block
The block.
@param array $data
The data.
Function to replace the AN homepage Block .