Skip to content

Commit

Permalink
Merge pull request schmittjoh#780 from bblue/patch-1
Browse files Browse the repository at this point in the history
Updated documentation related to PR schmittjoh#778
  • Loading branch information
goetas authored May 24, 2017
2 parents e3b2c36 + d96dac5 commit 3a41588
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions doc/cookbook/exclusion_strategies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,22 @@ To enable this feature you have to set the Expression Evaluator when initializin
->build();
.. _symfony expression language: https://github.com/symfony/expression-language

By default the serializer exposes three variables (`object`, `context` and `property_metadata` for use in an expression. This enables you to create custom exclusion strategies similar to i.e. the [GroupExclusionStrategy](https://github.com/schmittjoh/serializer/blob/master/src/Exclusion/GroupsExclusionStrategy.php). In the below example, `someMethod` would receive all three variables.

.. code-block :: php
<?php
class MyObject
{
/**
* @Exclude(if="someMethod(object, context, property_metadata)")
*/
private $name;
/**
* @Exclude(if="someMethod(object, context, property_metadata)")
*/
private $name2;
}

0 comments on commit 3a41588

Please sign in to comment.