Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Workfow] Rename current MarkingStore #20462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,9 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
->defaultValue('workflow')
->end()
->arrayNode('marking_store')
->isRequired()
->children()
->enumNode('type')
->values(array('property_accessor', 'scalar'))
->values(array('multiple_state', 'single_state'))
->end()
->arrayNode('arguments')
->beforeNormalization()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<argument /> <!-- name -->
</service>

<service id="workflow.marking_store.property_accessor" class="Symfony\Component\Workflow\MarkingStore\PropertyAccessorMarkingStore" abstract="true" />
<service id="workflow.marking_store.scalar" class="Symfony\Component\Workflow\MarkingStore\ScalarMarkingStore" abstract="true" />
<service id="workflow.marking_store.multiple_state" class="Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore" abstract="true" />
<service id="workflow.marking_store.single_state" class="Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore" abstract="true" />

<service id="workflow.registry" class="Symfony\Component\Workflow\Registry" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'workflows' => array(
'my_workflow' => array(
'marking_store' => array(
'type' => 'property_accessor',
'type' => 'multiple_state',
),
'supports' => array(
FrameworkExtensionTest::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<framework:workflows>
<framework:workflow name="my_workflow">
<framework:marking-store>
<framework:type>property_accessor</framework:type>
<framework:type>multiple_state</framework:type>
<framework:arguments>a</framework:arguments>
<framework:arguments>a</framework:arguments>
</framework:marking-store>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ framework:
workflows:
my_workflow:
marking_store:
type: property_accessor
type: multiple_state
supports:
- Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
places:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
use Symfony\Component\Workflow\Marking;

/**
* MarkingStoreInterface.
* MarkingStoreInterface is the interface between the Workflow Component and a
* plain old PHP object: the subject.
*
* It converts the Marking into something understandable by the subject and vice
* versa.
*
* @author Grégoire Pineau <[email protected]>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@
use Symfony\Component\Workflow\Marking;

/**
* PropertyAccessorMarkingStore.
* MultipleStateMarkingStore stores the marking into a property of the
* subject.
*
* This store deals with a "multiple state" Marking. It means a subject can be
* in many state at the same time.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

states

*
* @author Grégoire Pineau <[email protected]>
*/
class PropertyAccessorMarkingStore implements MarkingStoreInterface
class MultipleStateMarkingStore implements MarkingStoreInterface
{
private $property;
private $propertyAccessor;

/**
* PropertyAccessorMarkingStore constructor.
* MultipleStateMarkingStore constructor.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't add any value.

*
* @param string $property
* @param PropertyAccessorInterface|null $propertyAccessor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@
use Symfony\Component\Workflow\Marking;

/**
* ScalarMarkingStore.
* SingleStateMarkingStore stores the marking into a property of the subject.
*
* This store deals with a "single state" Marking. It means a subject can be in
* one and only state at the same time.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] and only one state [...]

*
* @author Grégoire Pineau <[email protected]>
*/
class ScalarMarkingStore implements MarkingStoreInterface
class SingleStateMarkingStore implements MarkingStoreInterface
{
private $property;
private $propertyAccessor;

/**
* ScalarMarkingStore constructor.
* SingleStateMarkingStore constructor.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

*
* @param string $property
* @param PropertyAccessorInterface|null $propertyAccessor
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Workflow/StateMachine.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface;
use Symfony\Component\Workflow\MarkingStore\ScalarMarkingStore;
use Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore;

/**
* @author Tobias Nyholm <[email protected]>
Expand All @@ -13,6 +13,6 @@ class StateMachine extends Workflow
{
public function __construct(Definition $definition, MarkingStoreInterface $markingStore = null, EventDispatcherInterface $dispatcher = null, $name = 'unnamed')
{
parent::__construct($definition, $markingStore ?: new ScalarMarkingStore(), $dispatcher, $name);
parent::__construct($definition, $markingStore ?: new SingleStateMarkingStore(), $dispatcher, $name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\EventListener\AuditTrailListener;
use Symfony\Component\Workflow\MarkingStore\PropertyAccessorMarkingStore;
use Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore;
use Symfony\Component\Workflow\Transition;
use Symfony\Component\Workflow\Workflow;

Expand All @@ -29,7 +29,7 @@ public function testItWorks()
$ed = new EventDispatcher();
$ed->addSubscriber(new AuditTrailListener($logger));

$workflow = new Workflow($definition, new PropertyAccessorMarkingStore(), $ed);
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $ed);

$workflow->apply($object, 't1');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
namespace Symfony\Component\Workflow\Tests\MarkingStore;

use Symfony\Component\Workflow\Marking;
use Symfony\Component\Workflow\MarkingStore\PropertyAccessorMarkingStore;
use Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore;

class PropertyAccessorMarkingStoreTest extends \PHPUnit_Framework_TestCase
class MultipleStateMarkingStoreTest extends \PHPUnit_Framework_TestCase
{
public function testGetSetMarking()
{
$subject = new \stdClass();
$subject->myMarks = null;

$markingStore = new PropertyAccessorMarkingStore('myMarks');
$markingStore = new MultipleStateMarkingStore('myMarks');

$marking = $markingStore->getMarking($subject);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
namespace Symfony\Component\Workflow\Tests\MarkingStore;

use Symfony\Component\Workflow\Marking;
use Symfony\Component\Workflow\MarkingStore\ScalarMarkingStore;
use Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore;

class ScalarMarkingStoreTest extends \PHPUnit_Framework_TestCase
class SingleStateMarkingStoreTest extends \PHPUnit_Framework_TestCase
{
public function testGetSetMarking()
{
$subject = new \stdClass();
$subject->myMarks = null;

$markingStore = new ScalarMarkingStore('myMarks');
$markingStore = new SingleStateMarkingStore('myMarks');

$marking = $markingStore->getMarking($subject);

Expand Down
24 changes: 12 additions & 12 deletions src/Symfony/Component/Workflow/Tests/WorkflowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\Workflow\Event\GuardEvent;
use Symfony\Component\Workflow\Marking;
use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface;
use Symfony\Component\Workflow\MarkingStore\PropertyAccessorMarkingStore;
use Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore;
use Symfony\Component\Workflow\Transition;
use Symfony\Component\Workflow\Workflow;

Expand All @@ -35,7 +35,7 @@ public function testGetMarkingWithEmptyDefinition()
{
$subject = new \stdClass();
$subject->marking = null;
$workflow = new Workflow(new Definition(array(), array()), new PropertyAccessorMarkingStore());
$workflow = new Workflow(new Definition(array(), array()), new MultipleStateMarkingStore());

$workflow->getMarking($subject);
}
Expand All @@ -49,7 +49,7 @@ public function testGetMarkingWithImpossiblePlace()
$subject = new \stdClass();
$subject->marking = null;
$subject->marking = array('nope' => true);
$workflow = new Workflow(new Definition(array(), array()), new PropertyAccessorMarkingStore());
$workflow = new Workflow(new Definition(array(), array()), new MultipleStateMarkingStore());

$workflow->getMarking($subject);
}
Expand All @@ -59,7 +59,7 @@ public function testGetMarkingWithEmptyInitialMarking()
$definition = $this->createComplexWorkflow();
$subject = new \stdClass();
$subject->marking = null;
$workflow = new Workflow($definition, new PropertyAccessorMarkingStore());
$workflow = new Workflow($definition, new MultipleStateMarkingStore());

$marking = $workflow->getMarking($subject);

Expand All @@ -74,7 +74,7 @@ public function testGetMarkingWithExistingMarking()
$subject = new \stdClass();
$subject->marking = null;
$subject->marking = array('b' => 1, 'c' => 1);
$workflow = new Workflow($definition, new PropertyAccessorMarkingStore());
$workflow = new Workflow($definition, new MultipleStateMarkingStore());

$marking = $workflow->getMarking($subject);

Expand All @@ -92,7 +92,7 @@ public function testCanWithUnexistingTransition()
$definition = $this->createComplexWorkflow();
$subject = new \stdClass();
$subject->marking = null;
$workflow = new Workflow($definition, new PropertyAccessorMarkingStore());
$workflow = new Workflow($definition, new MultipleStateMarkingStore());

$workflow->can($subject, 'foobar');
}
Expand All @@ -102,7 +102,7 @@ public function testCan()
$definition = $this->createComplexWorkflow();
$subject = new \stdClass();
$subject->marking = null;
$workflow = new Workflow($definition, new PropertyAccessorMarkingStore());
$workflow = new Workflow($definition, new MultipleStateMarkingStore());

$this->assertTrue($workflow->can($subject, 't1'));
$this->assertFalse($workflow->can($subject, 't2'));
Expand All @@ -117,7 +117,7 @@ public function testCanWithGuard()
$eventDispatcher->addListener('workflow.workflow_name.guard.t1', function (GuardEvent $event) {
$event->setBlocked(true);
});
$workflow = new Workflow($definition, new PropertyAccessorMarkingStore(), $eventDispatcher, 'workflow_name');
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');

$this->assertFalse($workflow->can($subject, 't1'));
}
Expand All @@ -131,7 +131,7 @@ public function testApplyWithImpossibleTransition()
$definition = $this->createComplexWorkflow();
$subject = new \stdClass();
$subject->marking = null;
$workflow = new Workflow($definition, new PropertyAccessorMarkingStore());
$workflow = new Workflow($definition, new MultipleStateMarkingStore());

$workflow->apply($subject, 't2');
}
Expand All @@ -141,7 +141,7 @@ public function testApply()
$definition = $this->createComplexWorkflow();
$subject = new \stdClass();
$subject->marking = null;
$workflow = new Workflow($definition, new PropertyAccessorMarkingStore());
$workflow = new Workflow($definition, new MultipleStateMarkingStore());

$marking = $workflow->apply($subject, 't1');

Expand All @@ -157,7 +157,7 @@ public function testApplyWithEventDispatcher()
$subject = new \stdClass();
$subject->marking = null;
$eventDispatcher = new EventDispatcherMock();
$workflow = new Workflow($definition, new PropertyAccessorMarkingStore(), $eventDispatcher, 'workflow_name');
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');

$eventNameExpected = array(
'workflow.guard',
Expand Down Expand Up @@ -194,7 +194,7 @@ public function testGetEnabledTransitions()
$eventDispatcher->addListener('workflow.workflow_name.guard.t1', function (GuardEvent $event) {
$event->setBlocked(true);
});
$workflow = new Workflow($definition, new PropertyAccessorMarkingStore(), $eventDispatcher, 'workflow_name');
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');

$this->assertEmpty($workflow->getEnabledTransitions($subject));

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Workflow/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\Workflow\Event\GuardEvent;
use Symfony\Component\Workflow\Exception\LogicException;
use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface;
use Symfony\Component\Workflow\MarkingStore\PropertyAccessorMarkingStore;
use Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore;

/**
* @author Fabien Potencier <[email protected]>
Expand All @@ -33,7 +33,7 @@ class Workflow
public function __construct(Definition $definition, MarkingStoreInterface $markingStore = null, EventDispatcherInterface $dispatcher = null, $name = 'unnamed')
{
$this->definition = $definition;
$this->markingStore = $markingStore ?: new PropertyAccessorMarkingStore();
$this->markingStore = $markingStore ?: new MultipleStateMarkingStore();
$this->dispatcher = $dispatcher;
$this->name = $name;
}
Expand Down