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


PHP Manager::getRequestedIncludes方法代码示例

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


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

示例1: transform

 /**
  * Transform a response with a transformer.
  *
  * @param mixed                          $response
  * @param object                         $transformer
  * @param \Dingo\Api\Transformer\Binding $binding
  * @param \Dingo\Api\Http\Request        $request
  *
  * @return array
  */
 public function transform($response, $transformer, Binding $binding, Request $request)
 {
     $this->parseFractalIncludes($request);
     $resource = $this->createResource($response, $transformer, $binding->getParameters());
     // If the response is a paginator then we'll create a new paginator
     // adapter for Laravel and set the paginator instance on our
     // collection resource.
     if ($response instanceof IlluminatePaginator) {
         $paginator = $this->createPaginatorAdapter($response);
         $resource->setPaginator($paginator);
     }
     if ($this->shouldEagerLoad($response)) {
         $eagerLoads = $this->mergeEagerLoads($transformer, $this->fractal->getRequestedIncludes());
         $response->load($eagerLoads);
     }
     foreach ($binding->getMeta() as $key => $value) {
         $resource->setMetaValue($key, $value);
     }
     $binding->fireCallback($resource, $this->fractal);
     $scopeIdentifier = null;
     if (array_key_exists('scopeIdentifier', $binding->getParameters())) {
         $scopeIdentifier = $binding->getParameters()['scopeIdentifier'];
     }
     return $this->fractal->createData($resource, $scopeIdentifier)->toArray();
 }
开发者ID:theHarvester,项目名称:api,代码行数:35,代码来源:Fractal.php

示例2: testRecursionLimiting

 public function testRecursionLimiting()
 {
     $manager = new Manager();
     // Should limit to 10 by default
     $manager->parseIncludes('a.b.c.d.e.f.g.h.i.j.NEVER');
     $this->assertEquals(array('a', 'a.b', 'a.b.c', 'a.b.c.d', 'a.b.c.d.e', 'a.b.c.d.e.f', 'a.b.c.d.e.f.g', 'a.b.c.d.e.f.g.h', 'a.b.c.d.e.f.g.h.i', 'a.b.c.d.e.f.g.h.i.j'), $manager->getRequestedIncludes());
     // Try setting to 3 and see what happens
     $manager->setRecursionLimit(3);
     $manager->parseIncludes('a.b.c.NEVER');
     $this->assertEquals(array('a', 'a.b', 'a.b.c'), $manager->getRequestedIncludes());
 }
开发者ID:iwillhappy1314,项目名称:laravel-admin,代码行数:11,代码来源:ManagerTest.php

示例3: getResource

 /**
  * Get the Fractal resource instance.
  *
  * @return \League\Fractal\Resource\ResourceInterface
  */
 public function getResource() : ResourceInterface
 {
     $this->manager->parseIncludes($this->relations);
     $transformer = $this->resource->getTransformer();
     if ($transformer instanceof Transformer && $transformer->allRelationsAllowed()) {
         $this->resource->setTransformer($transformer->setRelations($this->manager->getRequestedIncludes()));
     }
     return $this->resource->setMeta($this->meta);
 }
开发者ID:flugger,项目名称:laravel-responder,代码行数:14,代码来源:SuccessResponseBuilder.php

示例4: isRequested

 /**
  * Is Requested.
  *
  * Check if - in relation to the current scope - this specific segment is allowed.
  * That means, if a.b.c is requested and the current scope is a.b, then c is allowed. If the current
  * scope is a then c is not allowed, even if it is there and potentially transformable.
  *
  * @internal
  *
  * @param string $checkScopeSegment
  *
  * @return bool Returns the new number of elements in the array.
  */
 public function isRequested($checkScopeSegment)
 {
     if ($this->parentScopes) {
         $scopeArray = array_slice($this->parentScopes, 1);
         array_push($scopeArray, $this->scopeIdentifier, $checkScopeSegment);
     } else {
         $scopeArray = [$checkScopeSegment];
     }
     $scopeString = implode('.', (array) $scopeArray);
     return in_array($scopeString, $this->manager->getRequestedIncludes());
 }
开发者ID:laerciobernardo,项目名称:CodeDelivery,代码行数:24,代码来源:Scope.php

示例5: get

 /**
  * Get a list of objects
  *
  * @param  Request  $request Request object
  * @return ResponseInterface Response for request
  */
 public function get(Request $request, Fractal $fractal, FractalCollection $collection)
 {
     $this->beforeRequest($request, func_get_args());
     $transformer = $this->getTransformer();
     $includes = $request->input('include', '');
     $filter = $request->input('filter', false);
     $items = $this->getRepository();
     if ($filter && is_string($filter)) {
         $filter = json_decode($filter, true);
     }
     $queryFilter = [];
     if (!empty($filter)) {
         $queryFilter = new QueryFilter($filter, $items->model(), $this->getTransformer());
     }
     $fractal->parseIncludes($includes);
     $resource = $collection->setTransformer($transformer)->setResourceKey($this->getResourceKey());
     $paginator = $items->paginate($queryFilter, $transformer->getSafeEagerLoad($fractal->getRequestedIncludes()), app('context'));
     $itemCollection = $paginator->getCollection();
     $resource->setData($itemCollection);
     $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
     return $this->respondWithCollection($fractal->createData($resource));
 }
开发者ID:psesd,项目名称:chms-common,代码行数:28,代码来源:GetIndexTrait.php


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