registerArgument('month', 'int', 'The month to link to'); $this->registerArgument('year', 'int', 'The year to link to', true); } public function render(): string { $request = $this->renderingContext->getAttribute(ServerRequestInterface::class); $year = (int)$this->arguments['year']; $month = (int)$this->arguments['month']; // @todo migrate to site settings $pageUid = (int)($request->getAttribute('frontend.typoscript') ->getSetupTree() ->getChildByName('plugin') ?->getChildByName('tx_ewbloggy') ?->getChildByName('settings') ?->getChildByName('archiveUid') ?->getValue() ?? 0); $arguments = [ 'year' => $year ]; if ($month > 0) { $arguments['month'] = $month; } $this->uriBuilder->reset() ->setRequest($request) ->setTargetPageUid($pageUid); $uri = $this->uriBuilder->uriFor('listPostsByDate', $arguments, 'Post', 'EwBloggy', 'Archive'); $linkText = $this->renderChildren() ?? implode('-', $arguments); if ($uri !== '') { $this->tag->addAttribute('href', $uri); $this->tag->setContent((string)$linkText); $result = $this->tag->render(); } else { $result = $linkText; } return (string)$result; } }