title: Api Platform 2.5: execute collectionOperations only when the current entity is nested
body: <p>I started using API Platform after having a good documentation and watching a professionnel tutoriel, and now I encountered a problem.</p>
  
  <p>I have two entities User &amp; Role, the Role is nested in User.
  I want to disable direct operations on Role, I want only when I post a User with Role, the post operation works but when I post directly on Role /api/roles, the post operation have to be disabled.</p>
  
  <h1>User:</h1>
  
  <pre><code>/**
   * @ApiResource(
   *      normalizationContext={
   *        "groups"={"get"}
   *      },
   *     itemOperations={
   *          "get"={
   *              "security"="is_granted('IS_AUTHENTICATED_ANONYMOUSLY')",
   *               "normalization_context"={
   *                  "groups"={"get"}
   *              }
   *          },
   *          "put"= {
   *              "security"="is_granted('IS_AUTHENTICATED_ANONYMOUSLY') or is_granted('IS_AUTHENTICATED_FULLY') and object.getAuthor() == user",
   *              "denormalization_context"={
   *                  "groups"={"put"}
   *              }
   *          }
   *     },
   *     collectionOperations={
   *          "get"={
   *              "security"="is_granted('IS_AUTHENTICATED_ANONYMOUSLY')"
   *          },
   *          "post"={
   *              "security"="is_granted('IS_AUTHENTICATED_ANONYMOUSLY')",
   *              "denormalization_context"={
   *                  "groups"={"user:post"}
   *              }
   *          }
   *      }
   * )
   * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
   *
   * @UniqueEntity(fields={"username","email"})
   */
  class  User implements UserInterface
  {
      /**
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type="integer")
       *
       * @Groups({"get","get_comment_with_author","get_post_with_comments"})
       */
      private $id;
  
      /**
       * @ORM\Column(type="string", length=255)
       *
       * @Groups({"get","user:post","get_comment_with_author","get_post_with_comments"})
       */
      private $username;
  
      /**
       * @ORM\Column(type="string", length=255)
       *
       * @Groups({"put","user:post","get_comment_with_author","get-to-admin"})
       */
      private $email;
  
      /**
       * @ORM\ManyToMany(targetEntity="Role", fetch="EAGER")
       * @Groups({"put","user:post"})
       */
      private $rolesCollection;
  </code></pre>
  
  <h1>Role:</h1>
  
  <pre><code>/**
   * @ApiResource()
   * @ORM\Entity(repositoryClass="App\Repository\RoleRepository")
   */
  class Role
  {
      /**
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type="integer")
       * @Groups({"user:post"})
       */
      private $id;
  
      /**
       * @ORM\Column(type="string", length=255)
       */
      private $label;
  </code></pre>