for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\ResourceBundle\Controller;
use Sylius\Component\Resource\Model\ResourceInterface;
use SM\Factory\FactoryInterface;
/**
* @author Paweł Jędrzejewski <[email protected]>
class StateMachine implements StateMachineInterface
{
* @var FactoryInterface
private $stateMachineFactory;
* @param FactoryInterface $stateMachineFactory
public function __construct(FactoryInterface $stateMachineFactory)
$this->stateMachineFactory = $stateMachineFactory;
}
* {@inheritdoc}
public function apply(RequestConfiguration $configuration, ResourceInterface $resource)
if (!$configuration->hasStateMachine()) {
throw new \InvalidArgumentException('State machine must be configured to apply transition, check your routing.');
$this->stateMachineFactory->get($resource, $configuration->getStateMachineGraph())->apply($configuration->getStateMachineTransition());