setLayoutId example

    // \Drupal\Core\Config\Entity\ConfigEntityBase::set() that handles     // \Drupal\Core\Entity\EntityWithPluginCollectionInterface.     $layout_settings = $this->doGetLayout($layout_id$layout_settings)->getConfiguration();
    $this->setThirdPartySetting('field_layout', 'settings', $layout_settings);
    return $this;
  }

  /** * Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::setLayout(). */
  public function setLayout(LayoutInterface $layout) {
    $this->setLayoutId($layout->getPluginId()$layout->getConfiguration());
    return $this;
  }

  /** * Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::getLayout(). */
  public function getLayout() {
    return $this->doGetLayout($this->getLayoutId()$this->getLayoutSettings());
  }

  /** * Gets the layout plugin. * * @param string $layout_id * A layout plugin ID. * @param array $layout_settings * An array of settings. * * @return \Drupal\Core\Layout\LayoutInterface * The layout plugin. */
'layout_discovery',
    ];
    // A third party setting is added by the entity_test module.     $expected['third_party_settings']['entity_test'] = ['foo' => 'bar'];
    // The visible field is assigned the default region.     $expected['content']['foo']['region'] = 'content';

    $this->assertEntityValues($expected$entity_display->toArray());

    // Assign a new layout that has default settings and complex dependencies,     // but do not save yet.     $entity_display->setLayoutId('test_layout_main_and_footer');

    // The default settings were added.     $expected['third_party_settings']['field_layout'] = [
      'id' => 'test_layout_main_and_footer',
      'settings' => [
        'setting_1' => 'Default',
      ],
    ];
    // The field was moved to the default region.     $expected['content']['foo'] = [
      'type' => 'visible',
      
protected static $modules = [
    'field_layout',
  ];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->display
      ->setLayoutId('layout_twocol')
      ->save();
  }

  /** * Tests the compatibility of Layout Builder and Field Layout. */
  public function testCompatibility() {
    // Ensure that the configurable field is shown in the correct region and     // that the non-configurable field is shown outside the layout.     $expected_fields = [
      'field field--name-name field--type-string field--label-hidden field__item',
      
Home | Imprint | This part of the site doesn't use cookies.