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


PHP Collection::setCursor方法代码示例

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


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

示例1: respondWithCursor

 /**
  *
  * Returns a JSON Array along with a cursor for pagination.
  *
  * @param $collection
  * @param $callback
  * @param CursorInterface $cursor
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function respondWithCursor($collection, $callback, CursorInterface $cursor)
 {
     $resource = new Collection($collection, $callback);
     $resource->setCursor($cursor);
     $rootScope = $this->fractal->createData($resource);
     return $this->respondWithArray($rootScope->toArray());
 }
开发者ID:jasonb8293,项目名称:fox-api,代码行数:16,代码来源:ApiController.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: withCollection

 /**
  * Create a new collection resource with the given tranformer.
  *
  * @param  array|object  $collection
  * @param  object  $transformer
  * @param  \League\Fractal\Pagination\CursorInterface  $cursor
  * @param  string  $key
  * @return \Illuminate\Http\Response
  */
 public function withCollection($collection, $transformer, FractalCursorInterface $cursor = null, $key = null)
 {
     $resource = new FractalCollection($collection, $transformer, $key);
     if (!is_null($cursor)) {
         $resource->setCursor($cursor);
     }
     return $this->build($resource);
 }
开发者ID:iwillhappy1314,项目名称:laravel-admin,代码行数:17,代码来源:ResponseBuilder.php

示例4: collection

 public function collection($rootname, $items, TransformerAbstract $transformer, $options = array())
 {
     $resources = new Collection($items, $transformer, $rootname);
     if (isset($options['meta'])) {
         foreach ($options['meta'] as $metaKey => $metaItem) {
             $resources->setMetaValue($metaKey, $metaItem);
         }
     }
     if (array_key_exists('cursor', $options)) {
         $resources->setCursor($options['cursor']);
     }
     if (array_key_exists('callback', $options)) {
         call_user_func($options['callback'], $resources);
     }
     if ($items instanceof IlluminatePaginator) {
         $paginatorInterface = array_key_exists('paginatorInterface', $options) ? $options['paginatorInterface'] : null;
         $this->paginateCollection($resources, $items, $paginatorInterface);
     }
     return isset($options['raw']) ? $resources : $this->buildResponse($resources);
 }
开发者ID:arthurnumen,项目名称:json-serializer-laravel,代码行数:20,代码来源:JsonSerializer.php

示例5: withCollection

 /**
  * Response for collection of items
  *
  * @param $data
  * @param callable|\League\Fractal\TransformerAbstract $transformer
  * @param string $resourceKey
  * @param Cursor $cursor
  * @param array $meta
  * @return mixed
  */
 public function withCollection($data, $transformer, $resourceKey = null, Cursor $cursor = null, $meta = [])
 {
     $resource = new Collection($data, $transformer, $resourceKey);
     foreach ($meta as $metaKey => $metaValue) {
         $resource->setMetaValue($metaKey, $metaValue);
     }
     if (!is_null($cursor)) {
         $resource->setCursor($cursor);
     }
     $rootScope = $this->manager->createData($resource);
     return $this->withArray($rootScope->toArray());
 }
开发者ID:ryanmcoble,项目名称:remedy,代码行数:22,代码来源:AbstractResponse.php

示例6: respondWithCollection

 /**
  * Respond with a given collection.
  *
  * @param $collection
  * @param int $skip
  * @param int $limit
  *
  * @return mixed
  */
 protected function respondWithCollection($collection, $skip = 0, $limit = 0)
 {
     $resource = new Collection($collection, $this->transformer, $this->resourceKeyPlural);
     if ($limit) {
         $cursor = new Cursor($skip, $skip + $limit, $collection->count());
         $resource->setCursor($cursor);
     }
     $rootScope = $this->prepareRootScope($resource);
     return $this->respond($rootScope->toArray());
 }
开发者ID:gpasztor87,项目名称:oc-api-plugin,代码行数:19,代码来源:ApiController.php

示例7: testCursorOutput

 public function testCursorOutput()
 {
     $manager = new Manager();
     $inputData = array(array('foo' => 'bar', 'baz' => 'ban'));
     $collection = new Collection($inputData, function (array $data) {
         return $data;
     });
     $cursor = new Cursor(0, 'ban', 'ban', 2);
     $collection->setCursor($cursor);
     $rootScope = $manager->createData($collection);
     $expectedOutput = array('meta' => array('cursor' => array('current' => 0, 'prev' => 'ban', 'next' => 'ban', 'count' => 2)), 'data' => $inputData);
     $this->assertEquals($expectedOutput, $rootScope->toArray());
 }
开发者ID:iwillhappy1314,项目名称:laravel-admin,代码行数:13,代码来源:ScopeTest.php

示例8: respondWithCursor

 /**
  * @param $paginator
  * @param $callback
  * @return JsonResponse
  */
 protected function respondWithCursor($paginator, $callback)
 {
     $pagination = $paginator->getPaginate();
     $resource = new Collection($pagination->items, $callback);
     $cursor = new Cursor($pagination->current, $pagination->before, $pagination->next, $pagination->total_items);
     $resource->setCursor($cursor);
     $rootScope = $this->fractal->createData($resource);
     return $this->respondWithArray($rootScope->toArray());
 }
开发者ID:duythien,项目名称:phalcon-api,代码行数:14,代码来源:ControllerBase.php


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