Skip to content
Snippets Groups Projects
Commit 093afddc authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

[BUGFIX] Fix metadata for author related pages

parent 5a5e18d4
No related branches found
Tags 2.0.9
No related merge requests found
......@@ -26,15 +26,16 @@ namespace SGalinski\SgNews\Controller;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use SGalinski\SgNews\Domain\Model\Author;
use SGalinski\SgNews\Domain\Model\Category;
use SGalinski\SgNews\Domain\Model\News;
use SGalinski\SgNews\Domain\Repository\AuthorRepository;
use SGalinski\SgNews\Domain\Repository\CategoryRepository;
use SGalinski\SgNews\Domain\Repository\NewsRepository;
use SGalinski\SgNews\Service\HeaderMetaDataService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Controller that handles the news single view page
* News Author List Controller
*/
class NewsByAuthorController extends AbstractController {
/**
......@@ -45,7 +46,7 @@ class NewsByAuthorController extends AbstractController {
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public function listAction($authorId = 0) {
public function listAction($authorId = 0): void {
if ($authorId) {
$newsAuthorsIds[] = $authorId;
} else {
......@@ -58,11 +59,17 @@ class NewsByAuthorController extends AbstractController {
$authors = [];
$authorRepository = $this->objectManager->get(AuthorRepository::class);
foreach ($newsAuthorsIds as $newsAuthorsId) {
/** @var Author $author */
$author = $authorRepository->findByUid($newsAuthorsId);
if (!$author) {
continue;
}
$GLOBALS['TSFE']->page['titlebyextension'] = $author->getName();
$GLOBALS['TSFE']->page['description'] = \strip_tags(\substr($author->getDescription(), 0, 200));
$GLOBALS['TSFE']->page['extensionArgumentsForCanonicalAndHrefLang'] =
'&tx_sgnews_newsbyauthor[authorId]=' . $author->getUid();
$authors[] = $author;
}
......@@ -88,6 +95,7 @@ class NewsByAuthorController extends AbstractController {
$categoryId = $newsEntry->getPid();
if (!isset($categories[$categoryId])) {
/** @var Category $category */
$category = $categoryRepository->findByUid($categoryId);
if (!$category) {
continue;
......@@ -100,7 +108,6 @@ class NewsByAuthorController extends AbstractController {
}
}
$this->view->assign('newsMetaData', $newsMetaData);
$this->view->assign('authors', $authors);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment