Unverified Commit 4b08fbad authored by alexpott's avatar alexpott

Issue #3160629 by raman.b, tim.plunkett, Berdir: BlockPluginTrait cannot call...

Issue #3160629 by raman.b, tim.plunkett, Berdir: BlockPluginTrait cannot call ::addContextAssignmentElement() itself
parent bd882e9b
......@@ -2,6 +2,7 @@
namespace Drupal\Core\Block;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait;
use Drupal\Core\Plugin\ContextAwarePluginInterface;
use Drupal\Core\Plugin\ContextAwarePluginTrait;
......@@ -20,8 +21,23 @@
*/
abstract class BlockBase extends PluginBase implements BlockPluginInterface, PluginWithFormsInterface, PreviewFallbackInterface, ContextAwarePluginInterface {
use BlockPluginTrait;
use BlockPluginTrait {
buildConfigurationForm as traitBuildConfigurationForm;
}
use ContextAwarePluginTrait;
use ContextAwarePluginAssignmentTrait;
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = $this->traitBuildConfigurationForm($form, $form_state);
// Add context mapping UI form elements.
$contexts = $form_state->getTemporaryValue('gathered_contexts') ?: [];
$form['context_mapping'] = $this->addContextAssignmentElement($this, $contexts);
return $form;
}
}
......@@ -177,9 +177,6 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
'#return_value' => BlockPluginInterface::BLOCK_LABEL_VISIBLE,
];
// Add context mapping UI form elements.
$contexts = $form_state->getTemporaryValue('gathered_contexts') ?: [];
$form['context_mapping'] = $this->addContextAssignmentElement($this, $contexts);
// Add plugin-specific settings for this block type.
$form += $this->blockForm($form, $form_state);
return $form;
......
......@@ -388,7 +388,11 @@ public function testRouteProtection() {
public function testBrokenBlockVisibility() {
$assert_session = $this->assertSession();
$this->drupalPlaceBlock('broken');
$block = $this->drupalPlaceBlock('broken');
// Ensure that broken block configuration can be accessed.
$this->drupalGet('admin/structure/block/manage/' . $block->id());
$assert_session->statusCodeEquals(200);
// Login as an admin user to the site.
$this->drupalLogin($this->adminUser);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment