Commit be286db4 authored by mglaman's avatar mglaman Committed by bojanz

Add getId() methods to Workflow and WorkflowGroup, cause getPluginId() is not intuitive.

parent 4fce22fb
......@@ -82,6 +82,13 @@ class Workflow extends PluginBase implements WorkflowInterface, ContainerFactory
);
}
/**
* {@inheritdoc}
*/
public function getId() {
return $this->pluginDefinition['id'];
}
/**
* {@inheritdoc}
*/
......
......@@ -14,6 +14,14 @@ use Drupal\Core\Entity\EntityInterface;
*/
interface WorkflowInterface {
/**
* Gets the workflow ID.
*
* @return string
* The workflow ID.
*/
public function getId();
/**
* Gets the translated label.
*
......
......@@ -14,6 +14,13 @@ use Drupal\Core\Plugin\PluginBase;
*/
class WorkflowGroup extends PluginBase implements WorkflowGroupInterface {
/**
* {@inheritdoc}
*/
public function getId() {
return $this->pluginDefinition['id'];
}
/**
* {@inheritdoc}
*/
......
......@@ -12,6 +12,14 @@ namespace Drupal\state_machine\Plugin\WorkflowGroup;
*/
interface WorkflowGroupInterface {
/**
* Gets the workflow group ID.
*
* @return string
* The workflow group ID.
*/
public function getId();
/**
* Gets the translated label.
*
......
......@@ -20,6 +20,22 @@ use Prophecy\Argument;
*/
class WorkflowTest extends UnitTestCase {
/**
* @covers ::getId
*/
public function testGetId() {
$guard_factory = $this->prophesize(GuardFactoryInterface::class);
$plugin_definition = [
'id' => 'test id',
'label' => 'test label',
'states' => [],
'transitions' => [],
];
$workflow = new Workflow([], 'test', $plugin_definition, $guard_factory->reveal());
$this->assertEquals('test id', $workflow->getId());
}
/**
* @covers ::getLabel
*/
......
......@@ -45,6 +45,13 @@ class WorkflowGroupTest extends UnitTestCase {
$this->workflowGroup = new WorkflowGroup([], 'order', $this->definition);
}
/**
* @covers ::getId
*/
public function testGetId() {
$this->assertEquals($this->definition['id'], $this->workflowGroup->getId());
}
/**
* @covers ::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