private function createLinks($object, $classes = '') { return array_map(function (Link $link) use($object, $classes) { $action = $this->actions->getAction($link->actionId()); $url = $this->baseUrl->appended($link->actionId())->withParameters(new Map($link->parameters($object))); $attributes = ['class' => $classes, 'href' => $url]; if ($link->confirm() !== null) { $attributes['onclick'] = "return confirm('{$link->confirm()}');"; } $description = $action->description(); if (!is_null($description)) { $attributes['title'] = str_replace('"', "'", strip_tags($this->parser->shorten($description))); } return new Element('a', $attributes, [$action->caption()]); }, $this->links->getLinks($object)); }
private function createLinks($object, $classes = '') { return array_map(function (Link $link) use($object, $classes) { $action = $this->actions->getAction($link->actionId()); $parameters = $link->parameters($object); if ($action->isModifying() && $this->token) { $parameters[ExecutionResource::TOKEN_ARG] = $this->token->generate($link->actionId()); } $url = (string) Url::relative($link->actionId(), $parameters); $attributes = ['class' => $classes, 'href' => $url]; if ($link->confirm() !== null) { $attributes['onclick'] = "return confirm('{$link->confirm()}');"; } $description = $action->description(); if (!is_null($description)) { $attributes['title'] = str_replace('"', "'", strip_tags($this->parser->shorten($description))); } return new Element('a', $attributes, [$action->caption()]); }, $this->links->getLinks($object)); }