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