-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A new class is added which will add meta tags for dates and events. The class has an interface which allows it to be replaced via DI to alter behaviour. Refactor import regarding data handler. We now also need to add a new column "keywords". We use the new DataHandler approach. But that approach only covered relations so far. We therefore refactor that area to be more generic and use that one for new keywords column. Relates: #10642
- Loading branch information
1 parent
275dc3f
commit 1e98df6
Showing
24 changed files
with
706 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
Classes/Frontend/MetaInformation/DateMetaInformationInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright (C) 2023 Daniel Siepmann <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
* 02110-1301, USA. | ||
*/ | ||
|
||
namespace Wrm\Events\Frontend\MetaInformation; | ||
|
||
use Wrm\Events\Domain\Model\Date; | ||
|
||
interface DateMetaInformationInterface | ||
{ | ||
public function setDate(Date $date): void; | ||
} |
84 changes: 84 additions & 0 deletions
84
Classes/Frontend/MetaInformation/DateMetaInformationService.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright (C) 2023 Daniel Siepmann <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
* 02110-1301, USA. | ||
*/ | ||
|
||
namespace Wrm\Events\Frontend\MetaInformation; | ||
|
||
use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry; | ||
use Wrm\Events\Domain\Model\Date; | ||
|
||
/** | ||
* TYPO3 has many different APIs to set meta information like: Page Title, Meta Tags, OpenGraph Tags, etc. | ||
* Those are combined here for Date detail view. | ||
* That way there is a single place to connect the details to TYPO3 APIs. | ||
*/ | ||
final class DateMetaInformationService implements DateMetaInformationInterface | ||
{ | ||
/** | ||
* @var MetaTagManagerRegistry | ||
*/ | ||
private $metaTagManagerRegistry; | ||
|
||
public function __construct( | ||
MetaTagManagerRegistry $metaTagManagerRegistry | ||
) { | ||
$this->metaTagManagerRegistry = $metaTagManagerRegistry; | ||
} | ||
|
||
public function setDate(Date $date): void | ||
{ | ||
$this->setDescription($date); | ||
$this->setKeywords($date); | ||
} | ||
|
||
private function setDescription(Date $date): void | ||
{ | ||
$description = ''; | ||
if ($date->getEvent() !== null) { | ||
$description = $date->getEvent()->getTeaser(); | ||
} | ||
if ($description === '') { | ||
return; | ||
} | ||
|
||
$this->metaTagManagerRegistry | ||
->getManagerForProperty('description') | ||
->addProperty('description', $description) | ||
; | ||
} | ||
|
||
private function setKeywords(Date $date): void | ||
{ | ||
$keywords = ''; | ||
if ($date->getEvent() !== null) { | ||
$keywords = $date->getEvent()->getKeywords(); | ||
} | ||
if ($keywords === '') { | ||
return; | ||
} | ||
|
||
$this->metaTagManagerRegistry | ||
->getManagerForProperty('keywords') | ||
->addProperty('keywords', $keywords) | ||
; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Classes/Frontend/MetaInformation/EventMetaInformationInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright (C) 2023 Daniel Siepmann <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
* 02110-1301, USA. | ||
*/ | ||
|
||
namespace Wrm\Events\Frontend\MetaInformation; | ||
|
||
use Wrm\Events\Domain\Model\Event; | ||
|
||
interface EventMetaInformationInterface | ||
{ | ||
public function setEvent(Event $event): void; | ||
} |
78 changes: 78 additions & 0 deletions
78
Classes/Frontend/MetaInformation/EventMetaInformationService.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright (C) 2023 Daniel Siepmann <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
* 02110-1301, USA. | ||
*/ | ||
|
||
namespace Wrm\Events\Frontend\MetaInformation; | ||
|
||
use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry; | ||
use Wrm\Events\Domain\Model\Event; | ||
|
||
/** | ||
* TYPO3 has many different APIs to set meta information like: Page Title, Meta Tags, OpenGraph Tags, etc. | ||
* Those are combined here for Event detail view. | ||
* That way there is a single place to connect the details to TYPO3 APIs. | ||
*/ | ||
final class EventMetaInformationService implements EventMetaInformationInterface | ||
{ | ||
/** | ||
* @var MetaTagManagerRegistry | ||
*/ | ||
private $metaTagManagerRegistry; | ||
|
||
public function __construct( | ||
MetaTagManagerRegistry $metaTagManagerRegistry | ||
) { | ||
$this->metaTagManagerRegistry = $metaTagManagerRegistry; | ||
} | ||
|
||
public function setEvent(Event $event): void | ||
{ | ||
$this->setDescription($event); | ||
$this->setKeywords($event); | ||
} | ||
|
||
private function setDescription(Event $event): void | ||
{ | ||
$description = $event->getTeaser(); | ||
if ($description === '') { | ||
return; | ||
} | ||
|
||
$this->metaTagManagerRegistry | ||
->getManagerForProperty('description') | ||
->addProperty('description', $description) | ||
; | ||
} | ||
|
||
private function setKeywords(Event $event): void | ||
{ | ||
$keywords = $event->getKeywords(); | ||
if ($keywords === '') { | ||
return; | ||
} | ||
|
||
$this->metaTagManagerRegistry | ||
->getManagerForProperty('keywords') | ||
->addProperty('keywords', $keywords) | ||
; | ||
} | ||
} |
Oops, something went wrong.