コード例 #1
0
ファイル: ApiResponse.php プロジェクト: spira/api-core
 /**
  * @param $items
  * @param int $statusCode
  * @return ApiResponse
  */
 public function collection($items, $statusCode = null)
 {
     if ($this->transformer) {
         $items = $this->transformer->transformCollection($items, $this->getTransformerOptions());
     }
     if (is_null($statusCode)) {
         $statusCode = $this->getStatusCode();
     }
     if (is_null($statusCode)) {
         $statusCode = self::HTTP_OK;
     }
     return $this->header('Content-Type', 'application/json')->setContent($this->encode($items))->setStatusCode($statusCode);
 }
コード例 #2
0
 /**
  * @param TransformerInterface $transformer
  * @return mixed
  */
 public function transform(TransformerInterface $transformer)
 {
     return ['message' => $this->getMessage(), 'invalid' => $transformer->transformCollection($this->getResponse())];
 }