snipPath(...)), new TwigFunction('snipLink', $this->snipLink(...), [ 'is_safe' => ['html'], ]), new TwigFunction('snipsByTag', $this->snipsByTag(...)), ]; } private function snipPath(int $id): string { return $this->router->generate('snip_single', [ 'snip' => $id, ]); } private function snipLink(int $id): string { $snip = $this->snipRepo->find($id); if ($snip === null) { throw new \Exception(sprintf('Snip not found with id: %d', $id)); } return sprintf('%s', $this->snipPath($id), $snip); } private function snipsByTag(string $tag): array { $request = new SnipFilterRequest(SnipFilterRequest::VISIBILITY_ALL, tag: $tag); $snips = $this->snipRepo->findByRequest($this->security->getUser(), $request); return array_map(fn(Snip $snip) => [ 'id' => $snip->getId(), 'name' => $snip->getName(), ], $snips); } }