當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Manager::parseIncludes方法代碼示例

本文整理匯總了PHP中League\Fractal\Manager::parseIncludes方法的典型用法代碼示例。如果您正苦於以下問題:PHP Manager::parseIncludes方法的具體用法?PHP Manager::parseIncludes怎麽用?PHP Manager::parseIncludes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在League\Fractal\Manager的用法示例。


在下文中一共展示了Manager::parseIncludes方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: includeRelated

 /**
  * Include the selected relationships in the Fractal Transformer
  *
  * @param  string
  * @return $this
  */
 public function includeRelated($includes)
 {
     if ($includes != null) {
         $this->fractal->parseIncludes($includes);
     }
     return $this;
 }
開發者ID:lykegenes,項目名稱:laravel-api-response,代碼行數:13,代碼來源:ItemStrategy.php

示例3: includes

 /**
  * includes sub level data transformer.
  * @param array $includes
  * @return $this
  */
 public function includes(array $includes)
 {
     // when autoload is enable, we need to merge user requested includes with the predefined includes.
     if ($this->autoload and $this->request->get($this->input_key)) {
         $includes = array_merge($includes, explode(',', $this->request->get($this->input_key)));
     }
     $this->manager->parseIncludes($includes);
     return $this;
 }
開發者ID:jayantakundu,項目名稱:laravel-rest-api,代碼行數:14,代碼來源:FractalServices.php

示例4: parseIncludes

 /**
  * @return $this
  */
 protected function parseIncludes()
 {
     $request = app('Illuminate\\Http\\Request');
     $paramIncludes = config('warehouse.fractal.params.include', 'include');
     if ($request->has($paramIncludes)) {
         $this->fractal->parseIncludes($request->get($paramIncludes));
     }
     return $this;
 }
開發者ID:osvaldino,項目名稱:warehouse,代碼行數:12,代碼來源:FractalPresenter.php

示例5: parseIncludes

 /**
  * @return $this
  */
 protected function parseIncludes()
 {
     $request = $this->application->make('Illuminate\\Http\\Request');
     $paramIncludes = Config::get('reloquent.fractal.params.include', 'include');
     if ($request->has($paramIncludes)) {
         $this->fractal->parseIncludes($request->get($paramIncludes));
     }
     return $this;
 }
開發者ID:mayconbordin,項目名稱:reloquent,代碼行數:12,代碼來源:FractalPresenter.php

示例6:

 function __construct(Manager $fractal)
 {
     // Need to do Authentication HERE!
     $this->beforeFilter('auth');
     // Check if the request is from allowable hosts
     $this->checkAllowables();
     $this->fractal = $fractal;
     if (Request::has('include')) {
         $this->fractal->parseIncludes(Request::get('include'));
     }
 }
開發者ID:ratiw,項目名稱:api,代碼行數:11,代碼來源:ApiController.php

示例7: __construct

 /**
  * Constructor.
  *
  * @param Request $request
  */
 public function __construct(Request $request)
 {
     $this->model = $this->model();
     $this->transformer = $this->transformer();
     $this->fractal = new Manager();
     $this->request = $request;
     $this->fractal->setSerializer($this->serializer());
     if ($this->request->has('include')) {
         $this->fractal->parseIncludes(camel_case($this->request->input('include')));
     }
 }
開發者ID:NewwayLibs,項目名稱:laravel-api-generator,代碼行數:16,代碼來源:BaseController.php

示例8: 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

示例9: __invoke

 /**
  * Handle domain logic for an action.
  *
  * @param  array $input
  * @return PayloadInterface
  */
 public function __invoke(array $input)
 {
     //Authorize user to be able to view shifts
     $this->authorizeUser($input[AuthHandler::TOKEN_ATTRIBUTE]->getMetaData('entity'), 'view', 'shifts');
     //Validate input
     $inputValidator = v::key('startDateTime', v::stringType())->key('endDateTime', v::stringType());
     $inputValidator->assert($input);
     //Retrieve shifts between in time period
     $shifts = $this->shiftRepository->getShiftsBetween(Carbon::parse($input['startDateTime']), Carbon::parse($input['endDateTime']));
     $this->collection->setData($shifts)->setTransformer($this->shiftTransformer);
     return $this->payload->withStatus(PayloadInterface::OK)->withOutput($this->fractal->parseIncludes(['manager', 'employee'])->createData($this->collection)->toArray());
 }
開發者ID:sctape,項目名稱:rest-scheduler-api,代碼行數:18,代碼來源:GetShifts.php

示例10: 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

示例11: __invoke

 /**
  * Handle domain logic for an action.
  *
  * @param  array $input
  * @return PayloadInterface
  */
 public function __invoke(array $input)
 {
     //Check that user has permission to edit this resource
     $this->authorizeUser($input[AuthHandler::TOKEN_ATTRIBUTE]->getMetaData('entity'), 'edit', 'shifts');
     //Validate input
     $inputValidator = v::key('id', v::intVal())->key('employee_id', v::intVal());
     $inputValidator->assert($input);
     //Execute command to update employee on shift
     $shift = $this->commandBus->handle(new AssignShiftCommand($input['id'], $input['employee_id']));
     $shiftItem = new Item($shift, new ShiftTransformer());
     return $this->payload->withStatus(PayloadInterface::OK)->withOutput($this->fractal->parseIncludes(['manager', 'employee'])->createData($shiftItem)->toArray());
 }
開發者ID:sctape,項目名稱:rest-scheduler-api,代碼行數:18,代碼來源:AssignShift.php

示例12: it_should_transform_item_with_includes

 /** @test */
 public function it_should_transform_item_with_includes()
 {
     $this->manager->parseIncludes('workplace');
     $userWorkplace = new UserWorkplaceEntityStub();
     $userWorkplace->setName('Doe\'s Constructions');
     $user = new UserEntityStub();
     $user->setName('John Doe');
     $user->setEmail('johndoe@example.com');
     $user->setWorkplace($userWorkplace);
     $scope = $this->transformer->transformItem($user);
     $this->assertInstanceOf(\League\Fractal\Scope::class, $scope);
     $this->assertEquals(['data' => ['name' => 'John Doe', 'email' => 'johndoe@example.com', 'workplace' => ['data' => ['name' => 'Doe\'s Constructions']]]], $scope->toArray());
 }
開發者ID:HydrefLab,項目名稱:laravel-adr,代碼行數:14,代碼來源:TransformerTest.php

示例13: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     if ($this->isLumen()) {
         require_once 'fallback.php';
     }
     $this->registerRequiredProviders();
     $this->app->bind('datatables.html', function () {
         return $this->app->make(Html\Builder::class);
     });
     $this->app->singleton('datatables.fractal', function () {
         $fractal = new Manager();
         $config = $this->app['config'];
         $request = $this->app['request'];
         $includesKey = $config->get('datatables.fractal.includes', 'include');
         if ($request->get($includesKey)) {
             $fractal->parseIncludes($request->get($includesKey));
         }
         $serializer = $config->get('datatables.fractal.serializer', DataArraySerializer::class);
         $fractal->setSerializer(new $serializer());
         return $fractal;
     });
     $this->app->singleton('datatables', function () {
         return new Datatables($this->app->make(Request::class));
     });
     $this->registerAliases();
 }
開發者ID:yajra,項目名稱:laravel-datatables-oracle,代碼行數:31,代碼來源:DatatablesServiceProvider.php

示例14: index

 public function index(Request $request, Manager $fractal)
 {
     if ($requestedEmbeds = $request->get('include')) {
         $fractal->parseIncludes($requestedEmbeds);
     }
     return $this->response->item($this->user, UserTransformer::class);
 }
開發者ID:tdtrung17693,項目名稱:Rabbitnote,代碼行數:7,代碼來源:UsersController.php

示例15: __construct

 /**
  * @param Manager $fractal
  */
 public function __construct(Manager $fractal)
 {
     $this->fractal = $fractal;
     if (isset($_GET['include'])) {
         $fractal->parseIncludes($_GET['include']);
     }
 }
開發者ID:jamieshiers,項目名稱:calendar,代碼行數:10,代碼來源:ApiController.php


注:本文中的League\Fractal\Manager::parseIncludes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。