Commit 25e88fdf authored by catch's avatar catch
Browse files

Issue #3126747 by phenaproxima, tim.plunkett, TR, Spokje:...

Issue #3126747 by phenaproxima, tim.plunkett, TR, Spokje: ContextDefinition::create() can no longer be used with an entitytype-specific datatype (like entity:user)

(cherry picked from commit 1c94be4a)
parent a6bb8521
......@@ -80,6 +80,9 @@ class ContextDefinition implements ContextDefinitionInterface {
* The created context definition object.
*/
public static function create($data_type = 'any') {
if (strpos($data_type, 'entity:') === 0) {
return new EntityContextDefinition($data_type);
}
return new static(
$data_type
);
......
......@@ -4,6 +4,7 @@
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Context\EntityContext;
use Drupal\Core\Plugin\Context\EntityContextDefinition;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\KernelTests\KernelTestBase;
......@@ -43,4 +44,11 @@ public function testEntityContextDefinitionAssert() {
new ContextDefinition('entity:entity_test');
}
/**
* @covers ::create
*/
public function testCreateWithEntityDataType() {
$this->assertInstanceOf(EntityContextDefinition::class, ContextDefinition::create('entity:user'));
}
}
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