title: Include simple fields based on context in Fractal
body: <p>I am using the <a href="http://fractal.thephpleague.com/" rel="nofollow">Fractal library</a> to transform a <code>Book</code> object into JSON by using a simple transformer:</p>
  
  <pre><code>class BookTransformer extends \League\Fractal\TransformerAbstract
  {
      public function transform(Book $book)
      {
          return [
              'name' =&gt; $book-&gt;getName()
              // ...
          ];
      }
  }
  </code></pre>
  
  <p>And I am performing the transformation as follows.</p>
  
  <pre><code>$book = new Book('My Awesome Book');
  $resource = new \League\Fractal\Resource\Item($book, new BookTransformer());
  
  $fractal = new \League\Fractal\Manager();
  $fractal-&gt;setSerializer(new \League\Fractal\Serializer\ArraySerializer());
  
  $json = $fractal-&gt;createData($resource)-&gt;toJson();
  </code></pre>
  
  <p>This works great. However, I have certain fields on my <code>Book</code> object that should not always be included, because this depends on the context the transformation is done in. In my particular use case, the JSON returned to AJAX requests from my public website should not include sensitive information, while this should be the case when the data is requested from an admin backend.</p>
  
  <p>So, let's say that a book has a <code>topSecretValue</code> field, which is a string. This field should not be included in one transformation, but should be included in another. I took a look at <a href="http://fractal.thephpleague.com/transformers/" rel="nofollow">transformer includes</a>, and played around with it, but this only works with <em>resources</em>. In my case, I need to somehow include different <em>fields</em> (not resources) for different contexts. I have been digging around and could not find anything in the Fractal library that could help me, but maybe I am missing something?</p>
  
  <p>I came up with a working solution, but it is not the prettiest the world has ever seen. By having a <code>BaseBookTransformer</code> that transforms fields that should always be included, I can extend this transformer to add fields for other contexts, e.g. <code>AdminBookTransformer</code> or <code>TopSecretValueBookTransformer</code>, something like the below.</p>
  
  <pre><code>class AdminBookTransformer extends BookTransformer
  {
      public function transform(Book $book)
      {
          $arr = parent::transform($book);
          $arr['author'] = $book-&gt;getTopSecretValue();
  
          return $arr;
      }
  }
  </code></pre>
  
  <p>This works fine, although it is not as "clean" as using includes (if it were possible), because I have to actually use a different transformer.</p>
  
  <p>So the question is: is there anything in Fractal that enables me to accomplish this in a simpler/cleaner way, or is there a better way to do it, be it the Fractal way or not?</p>