title: Symfony workflow::can passes through workflow guard event listener
body: <p>I don't now if a lot of you have already tested the <code>symfony workflow</code> component but I hope some of you have :)</p>
  
  <p>So, I am using this component on <strong>two objects</strong> and I want the <strong>first object</strong> to <strong>update</strong> the <strong>second one</strong> depending on the <code>transition</code> it is applying.</p>
  
  <p>To do so, I am using the <code>workflow guard listener</code> on my <strong>first object</strong> and try to do a <code>workflow::apply</code> on my <strong>second object (using the second workflow ...)</strong>.</p>
  
  <p>The problem is that, when I make a <code>workflow::can</code>, the event is <strong>dispatched</strong> and it tries to <strong>apply</strong> a new status on my <strong>second object</strong> ... This is quite not normal as I am just asking <strong>if I can apply</strong> some transition and <strong>not</strong> asking to <strong>actually apply</strong> it on my <strong>first object</strong>.</p>
  
  <h2>config</h2>
  
  <pre><code>framework:
      workflows:
          request_for_operation:
              type: 'state_machine'
              marking_store:
                  type: 'single_state'
                  arguments:
                      - 'status'
              supports:
                  - AppBundle\Entity\RequestForOperation
              places:
                  - draft
                  - pending_for_management
                  - in_progress
                  - finished
                  - canceled
              transitions:
                  request_for_operations:
                      from: draft
                      to:   pending_for_management
                  start_rfop_management:
                      from: pending_for_management
                      to:   in_progress
                  close:
                      from: in_progress
                      to:   finished
                  cancel:
                      from: [pending_for_management, in_progress]
                      to:   canceled
          operation:
              type: 'state_machine'
              marking_store:
                  type: 'single_state'
                  arguments:
                      - 'status'
              supports:
                  - AppBundle\Entity\Operation
              places:
                  - draft
                  - pending_for_management
                  - in_progress
                  - finished
                  - canceled
              transitions:
                  validate_operation:
                      from: draft
                      to:   pending_for_management
                  start_tracking:
                      from: pending_for_management
                      to:   in_progress
                  close:
                      from: in_progress
                      to:   finished
                  cancel:
                      from: [pending_for_management, in_progress]
                      to:   canceled
  </code></pre>
  
  <h2>Subscriber</h2>
  
  <pre><code>class RequestForOperationListener implements EventSubscriberInterface
  {
      public function __construct(
          OperationManager $operationManager,
          UserNotifier $userNotifier
      ) {
          $this-&gt;operationManager = $operationManager;
          $this-&gt;userNotifier = $userNotifier;
      }
  
      public static function getSubscribedEvents()
      {
          return [
              'workflow.request_for_operation.guard.request_for_operations' =&gt; ['onRequestForOperations'],
              'workflow.request_for_operation.guard.start_rfop_management' =&gt; ['onStartRfopManagement'],
              'workflow.request_for_operation.guard.close' =&gt; ['onClose'],
              'workflow.request_for_operation.guard.cancel' =&gt; ['onCancel'],
          ];
      }
  
      public function onRequestForOperations(GuardEvent $event)
      {
          /** @var RequestForOperation $rfop */
          $rfop = $event-&gt;getSubject();
  
          //get all the operations linked to the rfop
          $operations = $rfop-&gt;getOperations();
          foreach ($operations as $operation) {
              //set the status of the operation to 'pending_for_management'
              $this-&gt;operationManager-&gt;applyTransition($operation, 'validate_operation');
              //set the status of the sub-operations to 'pending_for_management'
              foreach ($operation-&gt;getChildren() as $subOperation) {
                  $this-&gt;operationManager-&gt;applyTransition($subOperation, 'validate_operation');
              }
  
              //get the users (i.e: managers) linked to the operation and notify them (by mail or whatever)
              $this-&gt;notifyAssignedUsers($operation-&gt;getUsers(), $operation);
          }
      }
  }
  </code></pre>