/** * {@inheritdoc} */ protected function getEmbedValue(TransformInterface $transform, CompiledTransformMappingInterface $transformMapping, Embed $embed, $instance) { if ($this->isEloquentModel($instance) === true) { $userData = $embed->getUserData(); if (array_key_exists('rel', $userData) === true) { return $instance->getAttribute($embed->getUserData()['rel']); } } return parent::getEmbedValue($transform, $transformMapping, $embed, $instance); }
public function __construct(array $roles, $name, $routeName, $userData) { parent::__construct($name, $routeName, $userData); $this->roles = $roles; }
protected function getEmbedValue(TransformInterface $transform, CompiledTransformMappingInterface $transformMapping, Embed $embed, $instance) { $userData = $embed->getUserData(); if (array_key_exists('method', $userData) === true) { return $instance->{$userData['method']}(); } return null; }
/** * {@inheritdoc} */ public function rolesForEmbed(Embed $embed, $pathPrefix) { $roles = [$this->roleName($pathPrefix, 'embed', $embed->getName()), $this->roleName($pathPrefix, 'embed', 'all')]; return $this->makeRoles($roles); }