| @@ 14-46 (lines=33) @@ | ||
| 11 | * |
|
| 12 | * @package Mikemirten\Bundle\JsonApiBundle\Response |
|
| 13 | */ |
|
| 14 | class JsonApiDocumentView extends AbstractJsonApiView |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * Json API document |
|
| 18 | * |
|
| 19 | * @var AbstractDocument |
|
| 20 | */ |
|
| 21 | protected $document; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * JsonApiDocumentResponse constructor. |
|
| 25 | * |
|
| 26 | * @param AbstractDocument $document |
|
| 27 | * @param int $status |
|
| 28 | * @param array $headers |
|
| 29 | */ |
|
| 30 | public function __construct(AbstractDocument $document, int $status = 200, array $headers = []) |
|
| 31 | { |
|
| 32 | $this->document = $document; |
|
| 33 | $this->status = $status; |
|
| 34 | $this->headers = $headers; |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Get document |
|
| 39 | * |
|
| 40 | * @return AbstractDocument |
|
| 41 | */ |
|
| 42 | public function getDocument(): AbstractDocument |
|
| 43 | { |
|
| 44 | return $this->document; |
|
| 45 | } |
|
| 46 | } |
|
| @@ 12-44 (lines=33) @@ | ||
| 9 | * |
|
| 10 | * @package Mikemirten\Bundle\JsonApiBundle\Response |
|
| 11 | */ |
|
| 12 | class JsonApiObjectView extends AbstractJsonApiView |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * Object supposed to be handled |
|
| 16 | * |
|
| 17 | * @var mixed |
|
| 18 | */ |
|
| 19 | protected $object; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * JsonApiObjectView constructor. |
|
| 23 | * |
|
| 24 | * @param mixed $object |
|
| 25 | * @param int $status |
|
| 26 | * @param array $headers |
|
| 27 | */ |
|
| 28 | public function __construct($object, int $status = 200, array $headers = []) |
|
| 29 | { |
|
| 30 | $this->object = $object; |
|
| 31 | $this->status = $status; |
|
| 32 | $this->headers = $headers; |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * Get object passed to handling |
|
| 37 | * |
|
| 38 | * @return mixed |
|
| 39 | */ |
|
| 40 | public function getObject() |
|
| 41 | { |
|
| 42 | return $this->object; |
|
| 43 | } |
|
| 44 | } |
|