当前位置: 首页>>代码示例>>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;未经允许,请勿转载。