vendor/winzou/state-machine-bundle/Callback/ContainerAwareCallbackFactory.php line 26

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the StateMachine package.
  4.  *
  5.  * (c) Alexandre Bacco
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace winzou\Bundle\StateMachineBundle\Callback;
  11. use SM\SMException;
  12. use SM\Callback\CallbackFactory;
  13. use SM\Callback\CallbackInterface;
  14. use Symfony\Component\DependencyInjection\ContainerInterface;
  15. class ContainerAwareCallbackFactory extends CallbackFactory
  16. {
  17.     /**
  18.      * @var ContainerInterface
  19.      */
  20.     protected $container;
  21.     public function __construct($classContainerInterface $container)
  22.     {
  23.         parent::__construct($class);
  24.         $this->container $container;
  25.     }
  26.     /**
  27.      * {@inheritDoc}
  28.      */
  29.     public function get(array $specs): CallbackInterface
  30.     {
  31.         if (!isset($specs['do'])) {
  32.             throw new SMException(sprintf(
  33.                'CallbackFactory::get needs the index "do" to be able to build a callback, array %s given.',
  34.                 json_encode($specs)
  35.             ));
  36.         }
  37.         $class $this->class;
  38.         return new $class($specs$specs['do'], $this->container);
  39.     }
  40. }