当前位置: 首页>>代码示例>>PHP>>正文


PHP Manager::createData方法代码示例

本文整理汇总了PHP中League\Fractal\Manager::createData方法的典型用法代码示例。如果您正苦于以下问题:PHP Manager::createData方法的具体用法?PHP Manager::createData怎么用?PHP Manager::createData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在League\Fractal\Manager的用法示例。


在下文中一共展示了Manager::createData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: respondCollection

 public function respondCollection($collection, $callback, $resource_key, $meta = [])
 {
     $resource = new Collection($collection, $callback, $resource_key);
     $data = $this->fractal->createData($resource)->toArray();
     $response = array_merge($data, $meta);
     return $this->respond($response);
 }
开发者ID:Thyoity,项目名称:phalcon-rest,代码行数:7,代码来源:FractalController.php

示例2: cursorCollection

 /**
  * @param $data
  * @param \League\Fractal\TransformerAbstract $transformer
  * @param \League\Fractal\Pagination\Cursor|int $cursor
  * @param string $resourceKey
  * @return \League\Fractal\Scope
  */
 public function cursorCollection($data, $transformer = null, $cursor = null, $resourceKey = null)
 {
     $transformer = $this->getTransformer($transformer);
     $resource = new Collection($data, $transformer, $resourceKey);
     $resource->setCursor($this->makeCursor($cursor, $data));
     return $this->manager->createData($resource);
 }
开发者ID:creativify,项目名称:kraken,代码行数:14,代码来源:FractalTransformerManager.php

示例3: __invoke

 /**
  * @param array $input
  * @return PayloadInterface
  */
 public function __invoke(array $input)
 {
     $employee = $this->userRepository->getOneById($input['id']);
     $shifts = $this->shiftRepository->getByEmployee($employee);
     $shiftsCollection = new Collection($shifts, new ShiftTransformer());
     return $this->payload->withStatus(PayloadInterface::OK)->withOutput($this->fractal->createData($shiftsCollection)->toArray());
 }
开发者ID:elevenone,项目名称:rest-scheduler-api,代码行数:11,代码来源:GetUserShifts.php

示例4: convertResource

 /**
  * @param mixed $resource
  * @param null|string|array $includes
  * @return array
  */
 private function convertResource($resource, $includes = null)
 {
     if ($includes !== null) {
         $this->manager->parseIncludes($includes);
     }
     return $this->manager->createData($resource)->toArray();
 }
开发者ID:bburnichon,项目名称:rest-bundle,代码行数:12,代码来源:ArrayTransformer.php

示例5: lessons

 /**
  * Returns only the lessons from the
  * current feed from Laracasts in JSON.
  */
 public function lessons()
 {
     $lessons = $this->lissandra->getLessons();
     $resource = new Collection($lessons, new LessonTransformer($lessons));
     $data = $this->fractal->createData($resource)->toArray()['data'];
     return $this->respondWithCORS($data);
 }
开发者ID:laravelista,项目名称:lissandra,代码行数:11,代码来源:FeedController.php

示例6: createCollectionResponse

 protected function createCollectionResponse($collection, $transformer, $resourceKey, $meta = null)
 {
     $resource = new Collection($collection, $transformer, $resourceKey);
     $data = $this->fractal->createData($resource)->toArray();
     $response = array_merge($data, $meta ? $meta : []);
     return $this->createResponse($response);
 }
开发者ID:huzhaer,项目名称:phalcon-rest,代码行数:7,代码来源:Fractal.php

示例7: respondWithCollection

 /**
  * @param $collection
  * @param $callback
  * @param array|string|null $includes
  *
  * @return \Illuminate\Http\JsonResponse
  */
 protected function respondWithCollection($collection, $callback, $includes = null)
 {
     $resource = new Collection($collection, $callback);
     $this->addParseIncludes($includes);
     $rootScope = $this->fractal->createData($resource);
     return $this->respondWithArray($rootScope->toArray());
 }
开发者ID:sctape,项目名称:scheduler,代码行数:14,代码来源:ResponseHelpers.php

示例8: paginatedCollection

 public function paginatedCollection(Paginator $paginator, $transformer = null, $resourceKey = null)
 {
     $paginator->appends(\Request::query());
     $resource = new Collection($paginator->getCollection(), $this->getTransformer($transformer), $resourceKey);
     $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
     return $this->manager->createData($resource)->toArray();
 }
开发者ID:huglester,项目名称:larasponse,代码行数:7,代码来源:Fractal.php

示例9: respondWithPaginate

 protected function respondWithPaginate($paginator, $callback)
 {
     $collection = $paginator->getCollection();
     $resource = new Collection($collection, $callback);
     $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
     $rootScope = $this->fractal->createData($resource);
     return $this->respondWithArray($rootScope->toArray());
 }
开发者ID:udinkecil,项目名称:tracerstudy,代码行数:8,代码来源:ApiController.php

示例10: transform

 public function transform(Recipe $recipe)
 {
     $fractal = new Manager();
     $ingredients = $recipe->ingredients;
     $categories = $recipe->categories;
     $instructions = $recipe->instructions;
     return ['id' => $recipe->id, 'type' => 'recipe', 'attributes' => ['title' => $recipe->title, 'preparationTime' => $recipe->preparationTime, 'cookingTime' => $recipe->cookingTime], 'relationships' => ['categories' => $fractal->createData($this->collection($categories, new CategoryTransformer()))->toArray(), 'ingredients' => $fractal->createData($this->collection($ingredients, new IngredientTransformer()))->toArray(), 'instructions' => $fractal->createData($this->collection($instructions, new InstructionTransformer()))->toArray()]];
 }
开发者ID:mariofriz,项目名称:speakingchef-api,代码行数:8,代码来源:RecipeTransformer.php

示例11: present

 /**
  * @param $data
  *
  * @return array
  */
 public function present($data)
 {
     if ($data instanceof EloquentCollection) {
         $this->resource = $this->transformCollection($data);
     } elseif ($data instanceof AbstractPaginator) {
         $this->resource = $this->transformPaginator($data);
     } else {
         $this->resource = $this->transformItem($data);
     }
     return $this->fractal->createData($this->resource)->toArray();
 }
开发者ID:killtw,项目名称:repository,代码行数:16,代码来源:FractalPresenter.php

示例12: find

 /**
  * @param Request $request
  * @param array $params
  * @return JsonResponse\Ok
  */
 public function find(Request $request, array $params)
 {
     $post = $this->getPost($params["id"]);
     // if the post is empty, return a 404
     if (empty($post)) {
         return new JsonResponse\NoContent();
     }
     //
     $post = new Item($this->getPost($params["id"]), new PostTransformer(), "posts");
     return new JsonResponse\Ok($this->fractal->createData($post)->toArray());
 }
开发者ID:kkeiper1103,项目名称:WpJsonApi,代码行数:16,代码来源:PostController.php

示例13: handle

 public function handle($request, Closure $next)
 {
     $response = $next($request);
     if (!isset($response->original)) {
         return $response;
     }
     if (!is_callable($response)) {
         return $response;
     }
     $response->setContent($this->fractal->createData($response())->toJson());
     return $response;
 }
开发者ID:jraymundoyrockdev,项目名称:api-gfccm-systems,代码行数:12,代码来源:RespondWithResource.php

示例14: __invoke

 /**
  * Handle domain logic for an action.
  *
  * @param  array $input
  * @return PayloadInterface
  */
 public function __invoke(array $input)
 {
     //Check that user is authorized to edit this resource
     $this->authorizeUser($input[AuthHandler::TOKEN_ATTRIBUTE]->getMetadata('entity'), 'edit', 'shifts');
     //Validate input
     $inputValidator = v::key('break', v::floatVal())->key('start_time', v::stringType())->key('end_time', v::stringType())->key('id', v::intVal());
     $inputValidator->assert($input);
     //Update shift data
     $shift = $this->commandBus->handle(new UpdateShiftCommand($input['id'], $input['break'], $input['start_time'], $input['end_time']));
     $shiftItem = new Item($shift, new ShiftTransformer());
     return $this->payload->withStatus(PayloadInterface::OK)->withOutput($this->fractal->createData($shiftItem)->toArray());
 }
开发者ID:sctape,项目名称:rest-scheduler-api,代码行数:18,代码来源:UpdateShift.php

示例15: make

 /**
  * Create Ember Data friendly response
  *
  * @param $data
  * @param $model
  * @param array $includes
  * @return array
  * @throws Exceptions\SerializerTranslatorException
  */
 public function make($data, $model, $includes = [])
 {
     if (!$data || empty($data)) {
         return [];
     }
     $transformer = app($this->translator->toTranslatorHandler($model));
     $resource = $this->createResource($data, $transformer, $model);
     if (!empty($includes)) {
         $this->manager->parseIncludes($includes);
     }
     return $this->manager->createData($resource)->toArray();
 }
开发者ID:neophene,项目名称:ember-eloquent,代码行数:21,代码来源:SerializerManager.php


注:本文中的League\Fractal\Manager::createData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。