本文整理汇总了PHP中Tobscure\JsonApi\Document::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Document::toArray方法的具体用法?PHP Document::toArray怎么用?PHP Document::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tobscure\JsonApi\Document
的用法示例。
在下文中一共展示了Document::toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: found
protected function found(Request $request, Found $payload)
{
$serializer = new AuthSessionSerializer();
$resource = new Resource($payload->getModel(), $serializer);
$document = new Document($resource);
return new JsonResponse($document->toArray(), 200);
}
示例2: testToArrayIncludesTheResourcesRepresentation
public function testToArrayIncludesTheResourcesRepresentation()
{
$post = (object) ['id' => 1, 'foo' => 'bar'];
$resource = new Resource($post, new PostSerializer2());
$document = new Document($resource);
$this->assertEquals(['data' => $resource->toArray()], $document->toArray());
}
示例3: success
protected function success(Request $request, Success $payload)
{
$serializer = new AuthSessionSerializer();
$resource = new Resource($payload->get('session'), $serializer);
$document = new Document($resource);
return new JsonResponse($document->toArray(), 201);
}
示例4: testToArrayIncludesTheResourcesRepresentation
public function testToArrayIncludesTheResourcesRepresentation()
{
$resource = new Resource('post', 1);
$document = new Document();
$document->setData($resource);
$this->assertEquals(['data' => $resource->toArray()], $document->toArray());
}
示例5: created
/**
* @param Request $request
* @param Created $payload
*/
public function created(Request $request, Created $payload)
{
$serializer = PerformanceStatistic::getSerializer();
$resource = new Resource($payload->getModel(), $serializer);
$document = new Document($resource);
return new JsonResponse($document->toArray(), 201, ['Location' => $resource->getLinks()['self']]);
}
示例6: toArray
public function toArray()
{
// We resolve the root element
if ($this->data instanceof ElementPromise && null !== ($promise = $this->data->getPromise())) {
$promise->wait();
}
return parent::toArray();
}
示例7: found
/**
* @param Request $request
* @param Found $payload
*/
public function found(Request $request, Found $payload)
{
$params = new Parameters($request->query->all());
$serializer = Judge::getSerializer();
$resource = new Resource($payload->getModel(), $serializer);
$resource = $resource->with($params->getInclude(['startgroup', 'user', 'performance-score']));
$resource = $resource->fields($params->getFields(['judge' => Judge::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields(), 'user' => User::getSerializer()->getFields(), 'performance-score' => PerformanceScore::getSerializer()->getFields()]));
$document = new Document($resource);
return new JsonResponse($document->toArray(), 200);
}
示例8: found
/**
* @param Request $request
* @param Found $payload
*/
public function found(Request $request, Found $payload)
{
$params = new Parameters($request->query->all());
$serializer = RegionType::getSerializer();
$resource = new Resource($payload->getModel(), $serializer);
$resource = $resource->with($params->getInclude(['countries', 'subdivisions', 'area']));
$resource = $resource->fields($params->getFields(['region-type' => RegionType::getSerializer()->getFields(), 'country' => Country::getSerializer()->getFields(), 'subdivision' => Subdivision::getSerializer()->getFields(), 'area' => RegionArea::getSerializer()->getFields()]));
$document = new Document($resource);
return new JsonResponse($document->toArray(), 200);
}
示例9: found
/**
* @param Request $request
* @param Found $payload
*/
public function found(Request $request, Found $payload)
{
$params = new Parameters($request->query->all());
$serializer = Object::getSerializer();
$resource = new Resource($payload->getModel(), $serializer);
$resource = $resource->with($params->getInclude(['sport', 'skills', 'skills.variations', 'skills.variationOf', 'skills.multiples', 'sport.objects']));
$resource = $resource->fields($params->getFields(['object' => Object::getSerializer()->getFields(), 'sport' => Sport::getSerializer()->getFields(), 'skill' => Skill::getSerializer()->getFields()]));
$document = new Document($resource);
return new JsonResponse($document->toArray(), 200);
}
示例10: found
/**
* @param Request $request
* @param Found $payload
*/
public function found(Request $request, Found $payload)
{
$params = new Parameters($request->query->all());
$serializer = FunctionPhase::getSerializer();
$resource = new Resource($payload->getModel(), $serializer);
$resource = $resource->with($params->getInclude(['root-skills', 'skill']));
$resource = $resource->fields($params->getFields(['function-phase' => FunctionPhase::getSerializer()->getFields(), 'root-skill' => Skill::getSerializer()->getFields(), 'skill' => Skill::getSerializer()->getFields()]));
$document = new Document($resource);
return new JsonResponse($document->toArray(), 200);
}
示例11: found
/**
* @param Request $request
* @param Found $payload
*/
public function found(Request $request, Found $payload)
{
$params = new Parameters($request->query->all());
$serializer = Competition::getSerializer();
$resource = new Resource($payload->getModel(), $serializer);
$resource = $resource->with($params->getInclude(['startgroups']));
$resource = $resource->fields($params->getFields(['competition' => Competition::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields()]));
$document = new Document($resource);
return new JsonResponse($document->toArray(), 200);
}
示例12: updated
/**
* @param Request $request
* @param Updated $payload
*/
public function updated(Request $request, Updated $payload)
{
$params = new Parameters($request->query->all());
$serializer = Localization::getSerializer();
$resource = new Resource($payload->getModel(), $serializer);
$resource = $resource->with($params->getInclude(['localizations', 'parent', 'language', 'ext-lang', 'script', 'language-variants', 'application-uris']));
$resource = $resource->fields($params->getFields(['localization' => Localization::getSerializer()->getFields(), 'parent' => Localization::getSerializer()->getFields(), 'language' => Language::getSerializer()->getFields(), 'ext-lang' => Language::getSerializer()->getFields(), 'script' => LanguageScript::getSerializer()->getFields(), 'language-variant' => LanguageVariant::getSerializer()->getFields(), 'application-uri' => ApplicationUri::getSerializer()->getFields()]));
$document = new Document($resource);
return new JsonResponse($document->toArray(), 200);
}
示例13: found
/**
* @param Request $request
* @param Found $payload
*/
public function found(Request $request, Found $payload)
{
$params = new Parameters($request->query->all());
$serializer = PerformanceStatistic::getSerializer();
$resource = new Resource($payload->getModel(), $serializer);
$resource = $resource->with($params->getInclude(['events', 'startgroups', 'routine']));
$resource = $resource->fields($params->getFields(['performance-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'event' => Event::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields(), 'routine' => Routine::getSerializer()->getFields()]));
$document = new Document($resource);
return new JsonResponse($document->toArray(), 200);
}
示例14: updated
/**
* @param Request $request
* @param Updated $payload
*/
public function updated(Request $request, Updated $payload)
{
$params = new Parameters($request->query->all());
$serializer = User::getSerializer();
$resource = new Resource($payload->getModel(), $serializer);
$resource = $resource->with($params->getInclude(['sessions', 'groups', 'activities']));
$resource = $resource->fields($params->getFields(['user' => User::getSerializer()->getFields(), 'session' => Session::getSerializer()->getFields(), 'group' => Group::getSerializer()->getFields(), 'activity' => Activity::getSerializer()->getFields()]));
$document = new Document($resource);
return new JsonResponse($document->toArray(), 200);
}
示例15: found
/**
* @param Request $request
* @param Found $payload
*/
public function found(Request $request, Found $payload)
{
$params = new Parameters($request->query->all());
$serializer = Action::getSerializer();
$resource = new Resource($payload->getModel(), $serializer);
$resource = $resource->with($params->getInclude(['module', 'groups', 'apis']));
$resource = $resource->fields($params->getFields(['action' => Action::getSerializer()->getFields(), 'module' => Module::getSerializer()->getFields(), 'group' => Group::getSerializer()->getFields(), 'api' => Api::getSerializer()->getFields()]));
$document = new Document($resource);
return new JsonResponse($document->toArray(), 200);
}