layout_builder_extra_field_test.module

Same filename in other branches
  1. 10 core/modules/layout_builder/tests/modules/layout_builder_extra_field_test/layout_builder_extra_field_test.module
  2. 11.x core/modules/layout_builder/tests/modules/layout_builder_extra_field_test/layout_builder_extra_field_test.module

Provides hook implementations for Layout Builder tests.

File

core/modules/layout_builder/tests/modules/layout_builder_extra_field_test/layout_builder_extra_field_test.module

View source
<?php


/**
 * @file
 * Provides hook implementations for Layout Builder tests.
 */
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;

/**
 * Implements hook_entity_extra_field_info().
 */
function layout_builder_extra_field_test_entity_extra_field_info() {
    $extra['node']['bundle_with_section_field']['display']['layout_builder_extra_field_test'] = [
        'label' => t('New Extra Field'),
        'description' => t('New Extra Field description'),
        'weight' => 0,
    ];
    return $extra;
}

/**
 * Implements hook_entity_node_view().
 */
function layout_builder_extra_field_test_node_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
    if ($display->getComponent('layout_builder_extra_field_test')) {
        $build['layout_builder_extra_field_test'] = [
            '#markup' => 'A new extra field.',
        ];
    }
}

Functions

Title Deprecated Summary
layout_builder_extra_field_test_entity_extra_field_info Implements hook_entity_extra_field_info().
layout_builder_extra_field_test_node_view Implements hook_entity_node_view().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.