本文整理汇总了PHP中League\Fractal\Manager::getSerializer方法的典型用法代码示例。如果您正苦于以下问题:PHP Manager::getSerializer方法的具体用法?PHP Manager::getSerializer怎么用?PHP Manager::getSerializer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Fractal\Manager
的用法示例。
在下文中一共展示了Manager::getSerializer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fireTransformer
/**
* Fire the main transformer.
*
* @internal
*
* @param TransformerAbstract|callable $transformer
* @param mixed $data
*
* @return array
*/
protected function fireTransformer($transformer, $data)
{
$includedData = array();
if (is_callable($transformer)) {
$transformedData = call_user_func($transformer, $data);
} else {
$transformedData = $transformer->transform($data);
}
if ($this->transformerHasIncludes($transformer)) {
$includedData = $this->fireIncludedTransformers($transformer, $data);
$transformedData = $this->manager->getSerializer()->mergeIncludes($transformedData, $includedData);
}
return array($transformedData, $includedData);
}
示例2: fireTransformer
/**
* Fire the main transformer.
*
* @internal
*
* @param TransformerAbstract|callable $transformer
* @param mixed $data
*
* @return array
*/
protected function fireTransformer($transformer, $data)
{
$includedData = array();
if (is_callable($transformer)) {
$transformedData = call_user_func($transformer, $data);
} else {
$transformedData = $transformer->transform($data);
}
if ($this->transformerHasIncludes($transformer)) {
$includedData = $this->fireIncludedTransformers($transformer, $data);
// If the serializer does not want the includes to be side-loaded then
// the included data must be merged with the transformed data.
if (!$this->manager->getSerializer()->sideloadIncludes()) {
$transformedData = array_merge($transformedData, $includedData);
}
}
return array($transformedData, $includedData);
}
示例3: getResourceKey
/**
* Calculate the resourceKey.
* If configured serializer is not an instance of JsonApiSerializer
* the resourceKey is useless and null will be returned
*
* @param string $resourceKey
* @return string|null
*/
private function getResourceKey($resourceKey)
{
return $this->fractal->getSerializer() instanceof JsonApiSerializer ? $resourceKey : null;
}