當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。