1 | <?php |
||
32 | class SourceSubscribingHandler implements SubscribingHandlerInterface |
||
33 | { |
||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | private $sourceDeSerClass; |
||
38 | |||
39 | /** |
||
40 | * @param string $sourceDeSerClass |
||
41 | */ |
||
42 | 11 | function __construct($sourceDeSerClass) |
|
46 | |||
47 | /** |
||
48 | * Return format: |
||
49 | * |
||
50 | * array( |
||
51 | * array( |
||
52 | * 'direction' => GraphNavigator::DIRECTION_SERIALIZATION, |
||
53 | * 'format' => 'json', |
||
54 | * 'type' => 'DateTime', |
||
55 | * 'method' => 'serializeDateTimeToJson', |
||
56 | * ), |
||
57 | * ) |
||
58 | * |
||
59 | * The direction and method keys can be omitted. |
||
60 | * |
||
61 | * @return array |
||
62 | */ |
||
63 | 11 | public static function getSubscribingMethods() |
|
64 | { |
||
65 | return array( |
||
66 | array( |
||
67 | 11 | 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION, |
|
68 | 11 | 'format' => 'json', |
|
69 | 11 | 'type' => 'ElastificationSource', |
|
70 | 11 | 'method' => 'serializeElastificationSource', |
|
71 | 11 | ), |
|
72 | 11 | ); |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * @param JsonDeserializationVisitor $visitor |
||
77 | * @param $data |
||
78 | * @param array $type |
||
79 | * @param Context $context |
||
80 | * |
||
81 | * @return mixed |
||
82 | * @author Mario Mueller |
||
83 | */ |
||
84 | 1 | public function serializeElastificationSource( |
|
85 | JsonDeserializationVisitor $visitor, |
||
86 | $data, |
||
87 | array $type, |
||
88 | Context $context |
||
89 | ) { |
||
90 | 1 | $this->sourceDeSerClass = empty($this->sourceDeSerClass) ? $type['name'] : $this->sourceDeSerClass; |
|
91 | |||
92 | 1 | return $visitor->getNavigator()->accept($data, ['name' => $this->sourceDeSerClass], $context); |
|
93 | } |
||
94 | |||
95 | /** |
||
96 | * @return string |
||
97 | * @author Mario Mueller (autogenerated code) |
||
98 | */ |
||
99 | 1 | public function getSourceDeSerClass() |
|
103 | |||
104 | /** |
||
105 | * @param string $sourceDeSerClass |
||
106 | * |
||
107 | * @return void |
||
108 | * @author Mario Mueller (autogenerated code) |
||
109 | */ |
||
110 | 5 | public function setSourceDeSerClass($sourceDeSerClass) |
|
114 | } |
||
115 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.