Linux unitednationsplay.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
nginx/1.20.1
Server IP : 188.130.139.92 & Your IP : 3.14.79.153
Domains :
Cant Read [ /etc/named.conf ]
User : web
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
home /
www /
wb /
vendor /
jms /
serializer /
doc /
Delete
Unzip
Name
Size
Permission
Date
Action
cookbook
[ DIR ]
drwxrwxr-x
2022-08-24 15:26
reference
[ DIR ]
drwxrwxr-x
2022-08-24 15:26
LICENSE
15.76
KB
-rw-rw-r--
2022-08-24 15:26
conf.py
1.31
KB
-rw-rw-r--
2022-08-24 15:26
configuration.rst
4.61
KB
-rw-rw-r--
2022-08-24 15:26
cookbook.rst
65
B
-rw-rw-r--
2022-08-24 15:26
event_system.rst
2.91
KB
-rw-rw-r--
2022-08-24 15:26
handlers.rst
2.94
KB
-rw-rw-r--
2022-08-24 15:26
index.rst
1.48
KB
-rw-rw-r--
2022-08-24 15:26
logo-small.png
6.32
KB
-rw-rw-r--
2022-08-24 15:26
logo.png
52.3
KB
-rw-rw-r--
2022-08-24 15:26
reference.rst
86
B
-rw-rw-r--
2022-08-24 15:26
requirements.txt
76
B
-rw-rw-r--
2022-08-24 15:26
usage.rst
933
B
-rw-rw-r--
2022-08-24 15:26
Save
Rename
Handlers ======== Introduction ------------ Handlers allow you to change the serialization, or deserialization process for a single type/format combination. Handlers are simple callback which receive three arguments: the visitor, the data, and the type. Simple Callables ---------------- You can register simple callables on the builder object:: $builder ->configureHandlers(function(JMS\Serializer\Handler\HandlerRegistry $registry) { $registry->registerHandler('serialization', 'MyObject', 'json', function($visitor, MyObject $obj, array $type) { return $obj->getName(); } ); }) ; .. note :: Be aware that when you call `configureHandlers` default handlers (like `DateHandler`) won't be added and you will have to call `addDefaultHandlers` on the Builder Subscribing Handlers -------------------- Subscribing handlers contain the configuration themselves which makes them easier to share with other users, and easier to set-up in general:: use JMS\Serializer\Handler\SubscribingHandlerInterface; use JMS\Serializer\GraphNavigator; use JMS\Serializer\JsonSerializationVisitor; use JMS\Serializer\JsonDeserializationVisitor; use JMS\Serializer\Context; class MyHandler implements SubscribingHandlerInterface { public static function getSubscribingMethods() { return [ [ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION, 'format' => 'json', 'type' => 'DateTime', 'method' => 'serializeDateTimeToJson', ], [ 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION, 'format' => 'json', 'type' => 'DateTime', 'method' => 'deserializeDateTimeToJson', ], ]; } public function serializeDateTimeToJson(JsonSerializationVisitor $visitor, \DateTime $date, array $type, Context $context) { return $date->format($type['params'][0]); } public function deserializeDateTimeToJson(JsonDeserializationVisitor $visitor, $dateAsString, array $type, Context $context) { return new \DateTime($dateAsString); } } Also, this type of handler is registered via the builder object:: $builder ->configureHandlers(function(JMS\Serializer\Handler\HandlerRegistry $registry) { $registry->registerSubscribingHandler(new MyHandler()); }) ; Skippable Subscribing Handlers ------------------------------- In case you need to be able to fall back to the default deserialization behavior instead of using your custom handler, you can simply throw a `SkipHandlerException` from you custom handler method to do so.