Skip to content

[Workflow] Added DefinitionInterface #20441

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

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion src/Symfony/Component/Workflow/Definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @author Fabien Potencier <fabien@symfony.com>
* @author Grégoire Pineau <lyrixx@lyrixx.info>
*/
class Definition
class Definition implements DefinitionInterface
{
private $places = array();
private $transitions = array();
Expand Down
37 changes: 37 additions & 0 deletions src/Symfony/Component/Workflow/DefinitionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Workflow;

/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
interface DefinitionInterface
{
/**
* Get the initial place.
*
* @return string
*/
public function getInitialPlace();

/**
* Get all the places.
*
* @return string[]
*/
public function getPlaces();

/**
* @return Transition[]
*/
public function getTransitions();
}
10 changes: 5 additions & 5 deletions src/Symfony/Component/Workflow/Dumper/DumperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\Workflow\Dumper;

use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\DefinitionInterface;
use Symfony\Component\Workflow\Marking;

/**
Expand All @@ -25,11 +25,11 @@ interface DumperInterface
/**
* Dumps a workflow definition.
*
* @param Definition $definition A Definition instance
* @param Marking|null $marking A Marking instance
* @param array $options An array of options
* @param DefinitionInterface $definition A Definition instance
* @param Marking|null $marking A Marking instance
* @param array $options An array of options
*
* @return string The representation of the workflow
*/
public function dump(Definition $definition, Marking $marking = null, array $options = array());
public function dump(DefinitionInterface $definition, Marking $marking = null, array $options = array());
}
10 changes: 5 additions & 5 deletions src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\Workflow\Dumper;

use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\DefinitionInterface;
use Symfony\Component\Workflow\Marking;

/**
Expand Down Expand Up @@ -43,7 +43,7 @@ class GraphvizDumper implements DumperInterface
* * node: The default options for nodes (places + transitions)
* * edge: The default options for edges
*/
public function dump(Definition $definition, Marking $marking = null, array $options = array())
public function dump(DefinitionInterface $definition, Marking $marking = null, array $options = array())
{
$places = $this->findPlaces($definition, $marking);
$transitions = $this->findTransitions($definition);
Expand All @@ -58,7 +58,7 @@ public function dump(Definition $definition, Marking $marking = null, array $opt
.$this->endDot();
}

private function findPlaces(Definition $definition, Marking $marking = null)
private function findPlaces(DefinitionInterface $definition, Marking $marking = null)
{
$places = array();

Expand All @@ -79,7 +79,7 @@ private function findPlaces(Definition $definition, Marking $marking = null)
return $places;
}

private function findTransitions(Definition $definition)
private function findTransitions(DefinitionInterface $definition)
{
$transitions = array();

Expand Down Expand Up @@ -123,7 +123,7 @@ private function addTransitions(array $transitions)
return $code;
}

private function findEdges(Definition $definition)
private function findEdges(DefinitionInterface $definition)
{
$dotEdges = array();

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Workflow/StateMachine.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class StateMachine extends Workflow
{
public function __construct(Definition $definition, MarkingStoreInterface $markingStore = null, EventDispatcherInterface $dispatcher = null, $name = 'unnamed')
public function __construct(DefinitionInterface $definition, MarkingStoreInterface $markingStore = null, EventDispatcherInterface $dispatcher = null, $name = 'unnamed')
{
parent::__construct($definition, $markingStore ?: new ScalarMarkingStore(), $dispatcher, $name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Workflow\Validator;

use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\DefinitionInterface;
use Symfony\Component\Workflow\Exception\InvalidDefinitionException;

/**
Expand All @@ -20,12 +21,12 @@
interface DefinitionValidatorInterface
{
/**
* @param Definition $definition
* @param string $name
* @param DefinitionInterface $definition
* @param string $name
*
* @return bool
*
* @throws InvalidDefinitionException on invalid definition
*/
public function validate(Definition $definition, $name);
public function validate(DefinitionInterface $definition, $name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\Workflow\Validator;

use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\DefinitionInterface;
use Symfony\Component\Workflow\Exception\InvalidDefinitionException;

/**
Expand All @@ -21,7 +21,7 @@
*/
class SinglePlaceWorkflowValidator extends WorkflowValidator
{
public function validate(Definition $definition, $name)
public function validate(DefinitionInterface $definition, $name)
{
foreach ($definition->getTransitions() as $transition) {
if (1 < count($transition->getTos())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

namespace Symfony\Component\Workflow\Validator;

use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\DefinitionInterface;
use Symfony\Component\Workflow\Exception\InvalidDefinitionException;

/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class StateMachineValidator implements DefinitionValidatorInterface
{
public function validate(Definition $definition, $name)
public function validate(DefinitionInterface $definition, $name)
{
$transitionFromNames = array();
foreach ($definition->getTransitions() as $transition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

namespace Symfony\Component\Workflow\Validator;

use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\DefinitionInterface;

/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class WorkflowValidator implements DefinitionValidatorInterface
{
public function validate(Definition $definition, $name)
public function validate(DefinitionInterface $definition, $name)
{
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Workflow/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Workflow
private $dispatcher;
private $name;

public function __construct(Definition $definition, MarkingStoreInterface $markingStore = null, EventDispatcherInterface $dispatcher = null, $name = 'unnamed')
public function __construct(DefinitionInterface $definition, MarkingStoreInterface $markingStore = null, EventDispatcherInterface $dispatcher = null, $name = 'unnamed')
{
$this->definition = $definition;
$this->markingStore = $markingStore ?: new PropertyAccessorMarkingStore();
Expand Down