本文整理汇总了PHP中League\Fractal\Manager::parseExcludes方法的典型用法代码示例。如果您正苦于以下问题:PHP Manager::parseExcludes方法的具体用法?PHP Manager::parseExcludes怎么用?PHP Manager::parseExcludes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Fractal\Manager
的用法示例。
在下文中一共展示了Manager::parseExcludes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$source_config = __DIR__ . '/../../config/fractal.php';
$this->mergeConfigFrom($source_config, 'fractal');
$this->app->singleton('fractal', function ($app) {
// retrieves configurations
$autoload = $app['config']->get('fractal.autoload');
$input_key = $app['config']->get('fractal.input_key');
$exclude_key = $app['config']->get('fractal.exclude_key');
$serializer = $app['config']->get('fractal.serializer');
// creating fractal manager instance
$manager = new Manager();
$factalNamespace = 'League\\Fractal\\Serializer\\';
$loadSerializer = class_exists($factalNamespace . $serializer) ? $factalNamespace . $serializer : $serializer;
$manager->setSerializer(new $loadSerializer());
if ($autoload === true and $includes = $app['request']->input($input_key)) {
$manager->parseIncludes($includes);
}
if ($app['request']->has($exclude_key)) {
$manager->parseExcludes($app['request']->input($exclude_key));
}
return new FractalServices($manager, $app['app']);
});
$this->app->alias('fractal', FractalServices::class);
// register our command here
$this->app['command.transformer.generate'] = $this->app->share(function ($app) {
return new TransformerGeneratorCommand($app['config'], $app['view'], $app['files'], $app);
});
$this->commands('command.transformer.generate');
}
示例2: excludes
/**
* excludes sub level from data transformer.
*
* @param string|array $excludes
*
* @return $this
*/
public function excludes($excludes)
{
if (is_string($excludes)) {
$excludes = explode(',', $excludes);
}
// when autoload is enable, we need to merge user requested includes with the predefined includes.
if ($this->autoload and $this->request->get($this->exclude_key)) {
$excludes = array_merge($excludes, explode(',', $this->request->get($this->exclude_key)));
}
$this->manager->parseExcludes($excludes);
return $this;
}
示例3: createData
/**
* Create fractal data.
*
* @return \League\Fractal\Scope
*
* @throws \Spatie\Fractal\Exceptions\InvalidTransformation
* @throws \Spatie\Fractal\Exceptions\NoTransformerSpecified
*/
public function createData()
{
if (is_null($this->transformer)) {
throw new NoTransformerSpecified();
}
if (!is_null($this->serializer)) {
$this->manager->setSerializer($this->serializer);
}
if (!is_null($this->includes)) {
$this->manager->parseIncludes($this->includes);
}
if (!is_null($this->excludes)) {
$this->manager->parseExcludes($this->excludes);
}
return $this->manager->createData($this->getResource());
}