Skip to content
Snippets Groups Projects
Unverified Commit 52aa9a23 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2986033 by mtodor, tim.plunkett, phenaproxima: [regression] The BC...

Issue #2986033 by mtodor, tim.plunkett, phenaproxima: [regression] The BC layer for EntityContextDefinition in ContextDefinition is incomplete
parent ead36d31
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -242,6 +242,11 @@ public function setDefaultValue($default_value) {
* {@inheritdoc}
*/
public function getConstraints() {
// If the backwards compatibility layer is present, delegate to that.
if ($this->entityContextDefinition) {
return $this->entityContextDefinition->getConstraints();
}
// @todo Apply defaults.
return $this->constraints;
}
......@@ -250,6 +255,11 @@ public function getConstraints() {
* {@inheritdoc}
*/
public function getConstraint($constraint_name) {
// If the backwards compatibility layer is present, delegate to that.
if ($this->entityContextDefinition) {
return $this->entityContextDefinition->getConstraint($constraint_name);
}
$constraints = $this->getConstraints();
return isset($constraints[$constraint_name]) ? $constraints[$constraint_name] : NULL;
}
......@@ -258,6 +268,11 @@ public function getConstraint($constraint_name) {
* {@inheritdoc}
*/
public function setConstraints(array $constraints) {
// If the backwards compatibility layer is present, delegate to that.
if ($this->entityContextDefinition) {
$this->entityContextDefinition->setConstraint();
}
$this->constraints = $constraints;
return $this;
}
......@@ -266,6 +281,11 @@ public function setConstraints(array $constraints) {
* {@inheritdoc}
*/
public function addConstraint($constraint_name, $options = NULL) {
// If the backwards compatibility layer is present, delegate to that.
if ($this->entityContextDefinition) {
$this->entityContextDefinition->addConstraint($constraint_name, $options);
}
$this->constraints[$constraint_name] = $options;
return $this;
}
......@@ -408,6 +428,7 @@ private function initializeEntityContextDefinition() {
->setRequired($this->isRequired())
->setMultiple($this->isMultiple())
->setDescription($this->getDescription())
->setConstraints($this->getConstraints())
->setDefaultValue($this->getDefaultValue());
}
......
<?php
namespace Drupal\Tests\layout_builder\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
/**
* Field blocks tests for the override layout.
*
* @group layout_builder
*/
class ItemLayoutFieldBlockTest extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'node',
'layout_builder',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->drupalLogin($this->drupalCreateUser([
'configure any layout',
'administer node display',
'administer node fields',
]));
// We need more then one content type for this test.
$this->createContentType(['type' => 'bundle_with_layout_overrides']);
$this->createContentType(['type' => 'filler_bundle']);
}
/**
* Tests configuring a field block for a user field.
*/
public function testAddAjaxBlock() {
$assert_session = $this->assertSession();
$page = $this->getSession()->getPage();
// Allow overrides for the layout.
$this->drupalPostForm('admin/structure/types/manage/bundle_with_layout_overrides/display/default', ['layout[allow_custom]' => TRUE], 'Save');
// Start by creating a node of type with layout overrides.
$node = $this->createNode([
'type' => 'bundle_with_layout_overrides',
'body' => [
[
'value' => 'The node body',
],
],
]);
$node->save();
// Open single item layout page.
$this->drupalGet('node/1/layout');
// Add a new block.
$this->clickLink('Add Block');
$assert_session->assertWaitOnAjaxRequest();
// Validate that only field blocks for layouted bundle are present.
$valid_links = $page->findAll('css', 'a[href$="field_block%3Anode%3Abundle_with_layout_overrides%3Abody"]');
$this->assertCount(1, $valid_links);
$invalid_links = $page->findAll('css', 'a[href$="field_block%3Anode%3Afiller_bundle%3Abody"]');
$this->assertCount(0, $invalid_links);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment