| @@ 66-94 (lines=29) @@ | ||
| 63 | * |
|
| 64 | * @return JsonODataV1Writer |
|
| 65 | */ |
|
| 66 | public function write($model) |
|
| 67 | { |
|
| 68 | // { "d" : |
|
| 69 | $this->_writer |
|
| 70 | ->startObjectScope() |
|
| 71 | ->writeName('d'); |
|
| 72 | ||
| 73 | if ($model instanceof ODataURL) { |
|
| 74 | $this->_writer->startObjectScope(); |
|
| 75 | $this->writeURL($model); |
|
| 76 | } elseif ($model instanceof ODataURLCollection) { |
|
| 77 | $this->_writer->startArrayScope(); |
|
| 78 | $this->writeURLCollection($model); |
|
| 79 | } elseif ($model instanceof ODataPropertyContent) { |
|
| 80 | $this->_writer->startObjectScope(); |
|
| 81 | $this->writeProperties($model); |
|
| 82 | } elseif ($model instanceof ODataFeed) { |
|
| 83 | $this->_writer->startArrayScope(); |
|
| 84 | $this->writeFeed($model); |
|
| 85 | } elseif ($model instanceof ODataEntry) { |
|
| 86 | $this->_writer->startObjectScope(); |
|
| 87 | $this->writeEntry($model); |
|
| 88 | } |
|
| 89 | ||
| 90 | $this->_writer->endScope(); |
|
| 91 | $this->_writer->endScope(); |
|
| 92 | ||
| 93 | return $this; |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * @param ODataURL $url the url to write |
|
| @@ 64-96 (lines=33) @@ | ||
| 61 | * |
|
| 62 | * @return JsonODataV1Writer |
|
| 63 | */ |
|
| 64 | public function write($model) |
|
| 65 | { |
|
| 66 | // { "d" : |
|
| 67 | $this->_writer |
|
| 68 | ->startObjectScope() |
|
| 69 | ->writeName('d') |
|
| 70 | ->startObjectScope(); |
|
| 71 | ||
| 72 | if ($model instanceof ODataURL) { |
|
| 73 | $this->writeURL($model); |
|
| 74 | } elseif ($model instanceof ODataURLCollection) { |
|
| 75 | $this->writeURLCollection($model); |
|
| 76 | } elseif ($model instanceof ODataPropertyContent) { |
|
| 77 | $this->writeProperties($model); |
|
| 78 | } elseif ($model instanceof ODataFeed) { |
|
| 79 | // Json Format V2: |
|
| 80 | // "results": |
|
| 81 | $this->writeRowCount($model->rowCount); |
|
| 82 | $this->writeNextPageLink($model->nextPageLink); |
|
| 83 | $this->_writer |
|
| 84 | ->writeName($this->dataArrayName) |
|
| 85 | ->startArrayScope(); |
|
| 86 | $this->writeFeed($model); |
|
| 87 | $this->_writer->endScope(); |
|
| 88 | } elseif ($model instanceof ODataEntry) { |
|
| 89 | $this->writeEntry($model); |
|
| 90 | } |
|
| 91 | ||
| 92 | $this->_writer->endScope(); |
|
| 93 | $this->_writer->endScope(); |
|
| 94 | ||
| 95 | return $this; |
|
| 96 | } |
|
| 97 | ||
| 98 | /** |
|
| 99 | * begin write OData links. |
|