You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/nonStandardExtensions/filter.rst
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -283,14 +283,14 @@ You can implement custom filter and use them in your schema files. You must add
283
283
->addFilter(new UppercaseFilter())
284
284
);
285
285
286
-
Your filter must implement the interface **PHPModelGenerator\\PropertyProcessor\\Filter\\FilterInterface**. Make sure the given callable array returned by **getFilter** is accessible as well during the generation process as during code execution using the generated model.
286
+
Your filter must implement the interface **PHPModelGenerator\\Filter\\FilterInterface**. Make sure the given callable array returned by **getFilter** is accessible as well during the generation process as during code execution using the generated model.
287
287
The callable filter method must be a static method. Internally it will be called via *call_user_func_array*. A custom filter may look like:
288
288
289
289
.. code-block:: php
290
290
291
291
namespace MyApp\Model\Generator\Filter;
292
292
293
-
use PHPModelGenerator\PropertyProcessor\Filter\FilterInterface;
293
+
use PHPModelGenerator\Filter\FilterInterface;
294
294
295
295
class UppercaseFilter implements FilterInterface
296
296
{
@@ -391,7 +391,7 @@ The option will be available if your JSON-Schema uses the object-notation for th
391
391
Custom transforming filter
392
392
^^^^^^^^^^^^^^^^^^^^^^^^^^
393
393
394
-
If you want to provide a custom filter which transforms a value (eg. redirect data into a manually written model, transforming between data types [eg. accepting values as an integer but handle them internally as binary strings]) you must implement the **PHPModelGenerator\\PropertyProcessor\\Filter\\TransformingFilterInterface**. This interface adds the **getSerializer** method to your filter. The method is similar to the **getFilter** method. It must return a callable which is available during the render process as well as during code execution. The returned callable must return null or a string and undo a transformation (eg. the serializer method of the builtin **dateTime** filter transforms a DateTime object back into a formatted string). The serializer method will be called with the current value of the property as the first argument and with the (optionally provided) additional options of the filter as the second argument. Your custom transforming filter might look like:
394
+
If you want to provide a custom filter which transforms a value (eg. redirect data into a manually written model, transforming between data types [eg. accepting values as an integer but handle them internally as binary strings]) you must implement the **PHPModelGenerator\\Filter\\TransformingFilterInterface**. This interface adds the **getSerializer** method to your filter. The method is similar to the **getFilter** method. It must return a callable which is available during the render process as well as during code execution. The returned callable must return null or a string and undo a transformation (eg. the serializer method of the builtin **dateTime** filter transforms a DateTime object back into a formatted string). The serializer method will be called with the current value of the property as the first argument and with the (optionally provided) additional options of the filter as the second argument. Your custom transforming filter might look like:
395
395
396
396
The custom serializer method will be called if the model utilizing the custom filter is generated with `serialization methods <../gettingStarted.html#serialization-methods>`__ and *toArray* or *toJSON* is called.
397
397
@@ -400,7 +400,7 @@ The custom serializer method will be called if the model utilizing the custom fi
400
400
namespace MyApp\Model\Generator\Filter;
401
401
402
402
use MyApp\Model\ManuallyWrittenModels\Customer;
403
-
use PHPModelGenerator\PropertyProcessor\Filter\TransformingFilterInterface;
403
+
use PHPModelGenerator\Filter\TransformingFilterInterface;
404
404
405
405
class CustomerFilter implements TransformingFilterInterface
0 commit comments