title: Api Platform: Conditionally adding group to serialization context based on requested resource item
body: <p>I am using API Platform 2.0 with Symfony 3.1.</p>
  
  <p>I followed the WIP documentation to add groups to serialisation context conditionally. For that I decorated the ContextBuilder.</p>
  
  <p>This works well to set some groups based on currently logged in user.
  But now I additionally want to add some groups depending on the requested resource item - so I need that to be available as Object, already fetched from persistence layer.</p>
  
  <p>Something like this:</p>
  
  <pre><code>public function createFromRequest(Request $request, bool $normalization, array $extractedAttributes = null) : array {
      /* @var $currentUser User */
      $currentUser = $this-&gt;tokenStorage-&gt;getToken()-&gt;getUser();
  
      /* @var $requestedProduct Product */
      $requestedProduct = $this-&gt;getRequestedItem();
  
      if ($product-&gt;getAuthoringOrganization() === $currentUser-&gt;getOrganization() {
          $context['groups'][] = 'api_products_get_item_current_user_is_owner';
      }
  
      return $context;
  }
  </code></pre>
  
  <p>I am afraid i cant get the requested item / collection in ContextBuilder. If so, i would be really happy to get some advice where to build my serialisation groups.</p>
  
  <p>In EventListener i can do that to get what i called "$requestedProduct" here:</p>
  
  <pre><code>$subject = $event-&gt;getControllerResult()) 
  </code></pre>
  
  <p>Thanks a lot for your help.</p>
  
  <p>Cheers Ben</p>