title: Doctrine event subscriber registered only for website
body: <p>In my Symfony project I have both a website and several Symfony Commands which run in CLI.</p>
  
  <p>Actually I created a simple Doctrine event subscriber:</p>
  
  <pre><code>  doctrine.event_subscriber.web_sync:
        class: WebUiBundle\EventSubscriber\WebSyncSubscriber
        tags:
          - { name: doctrine.event_subscriber, connection: default }
  </code></pre>
  
  <p>All works as expected but the point is I need this subscriber to be called only if an event (postUpdate, postPersist, etc..) comes from website and not from some CLI command.</p>
  
  <p>So actually in every callback I check if request doesn't come from CLI with the following function:</p>
  
  <pre><code>function isCli() {
      return (!isset($_SERVER['SERVER_SOFTWARE']) &amp;&amp; (php_sapi_name() == 'cli' || (is_numeric($_SERVER['argc']) &amp;&amp; $_SERVER['argc'] &gt; 0)));
  }
  </code></pre>
  
  <p>but I wonder if there's a way to directly register and use this subscriber only if Doctrine events come from website (so basically <code>HttpKernel</code>).</p>
  
  <p>Any idea?</p>