Commit 41cc353c authored by catch's avatar catch
Browse files

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 4839e850
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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 {
+1 −1
Original line number Diff line number Diff line
@@ -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" = {} }
 *     ),
 *   }
 * )
+1 −0
Original line number Diff line number Diff line
@@ -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());
  }

}