protected function addActions(CompiledResourceDefinitionInterface $resourceDefinition, array $which, $instance = null) { if ($this->context->wantsMetadata() === false) { return; } $actions = $resourceDefinition->getActions(); $links = []; $this->data['_actions'] = []; foreach ($actions as $action) { if ($action->getType() === ActionDefinition::TYPE_COLLECTION) { $this->addFiltersToLink('self', $action); } if (in_array($action->getType(), $which) === false || $action->isAffordanceAvailable($this->resource, $instance) === false) { continue; } $links = array_merge($links, $this->addAction($resourceDefinition, $action, $instance)); } foreach ($links as $rel => $routeName) { $this->addRestedLink($rel, $routeName); } }
public function __construct(RestedServiceInterface $restedService, UrlGeneratorInterface $urlGenerator, ResourceInterface $resource, ContextInterface $context, $uri = null, array $data = []) { parent::__construct($uri, $data); $this->context = $context; $this->resource = $resource; $this->restedService = $restedService; $this->urlGenerator = $urlGenerator; if ($context->wantsMetadata() === false) { $uri = null; } $this->addLink('self', $uri); }