Commit a180fe80 authored by catch's avatar catch

Issue #2916376 by rlmumford, Sweetchuck, tim.plunkett: The @ContextDefinition...

Issue #2916376 by rlmumford, Sweetchuck, tim.plunkett: The @ContextDefinition annotation always kills the label and the description

(cherry picked from commit 32f249ae)
parent e27bd859
......@@ -3,7 +3,6 @@
namespace Drupal\Core\Annotation;
use Drupal\Component\Annotation\Plugin;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* @defgroup plugin_context Annotation for context definition
......@@ -106,7 +105,7 @@ public function __construct(array $values) {
// used in the classes they pass to.
foreach (['label', 'description'] as $key) {
// @todo Remove this workaround in https://www.drupal.org/node/2362727.
if (isset($values[$key]) && $values[$key] instanceof TranslatableMarkup) {
if (isset($values[$key]) && $values[$key] instanceof Translation) {
$values[$key] = (string) $values[$key]->get();
}
else {
......
......@@ -14,7 +14,7 @@
* admin_label = @Translation("Test context-aware block"),
* context_definitions = {
* "user" = @ContextDefinition("entity:user", required = FALSE,
* constraints = { "NotNull" = {} }
* label = @Translation("User Context"), constraints = { "NotNull" = {} }
* ),
* }
* )
......
......@@ -25,6 +25,7 @@ public function testConstraints() {
$this->assertArrayHasKey('user', $definition['context_definitions']);
$this->assertInstanceOf(ContextDefinition::class, $definition['context_definitions']['user']);
$this->assertEquals(['NotNull' => []], $definition['context_definitions']['user']->getConstraints());
$this->assertEquals("User Context", $definition['context_definitions']['user']->getLabel());
}
}
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