Open
Description
The interface BindingSerializer should be implemented which converts Bindings from and to JSON. This interface can be implemented to support custom Binding classes in puli.json.
namespace Puli\Manager\Api\Discovery;
interface BindingSerializer
{
/**
* @param Binding
* @return stdClass
* @throws SerializationFailedException
*/
public function serializeBinding(Binding $binding);
/**
* @param stdClass
* @return Binding
* @throws UnserializationFailedException
*/
public function unserializeBinding(stdClass $json);
/**
* @param Binding
* @return bool
*/
public function acceptsBinding(Binding $binding);
/**
* @param stdClass
* @return bool
*/
public function acceptsJson(stdClass $json);
}
It should be possible to define serializers in puli.json:
{
"binding-serializers": [
"Vendor\\Namespace\\ServiceBindingSerializer"
]
}
Each "bindings" entry in puli.json is passed to all known serializers in order to be unserialized. On the reverse, each Binding stored in a puli.json is passed to all known serializers in order to be serialized.