Issue #2958785 by abramm: ContextDefinition isSatisfiedBy() check fails for context using inherited class

8.6.x
Alex Pott 2018-04-06 09:33:57 +01:00
parent 44b9b25c47
commit e817928144
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
3 changed files with 21 additions and 1 deletions

View File

@ -273,7 +273,7 @@ class ContextDefinition implements ContextDefinitionInterface {
if ($context->hasContextValue()) {
$values = [$context->getContextData()];
}
elseif ($definition instanceof static) {
elseif ($definition instanceof self) {
$values = $definition->getSampleValues();
}
else {

View File

@ -17,6 +17,7 @@ use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\TypedData\TypedDataManager;
use Drupal\Core\Validation\ConstraintManager;
use Drupal\Tests\Core\Plugin\Fixtures\InheritedContextDefinition;
use Drupal\Tests\UnitTestCase;
use Prophecy\Argument;
@ -196,6 +197,13 @@ class ContextDefinitionIsSatisfiedTest extends UnitTestCase {
new ContextDefinition('entity:test_config'),
];
// Inherited context definition class.
$data['both any, inherited context requirement definition'] = [
TRUE,
new InheritedContextDefinition('any'),
new ContextDefinition('any'),
];
return $data;
}

View File

@ -0,0 +1,12 @@
<?php
namespace Drupal\Tests\Core\Plugin\Fixtures;
use Drupal\Core\Plugin\Context\ContextDefinition;
/**
* Inherited class used for testing.
*
* @see \Drupal\Tests\Core\Plugin\Context\ContextDefinitionIsSatisfiedTest
*/
class InheritedContextDefinition extends ContextDefinition {}