-
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.
That way it is possible to alter the TYPO3 page title when showing a date or event. Relates: #10640
- Loading branch information
1 parent
d978cc2
commit 6b2c96e
Showing
13 changed files
with
311 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright (C) 2023 Daniel Siepmann <coding@daniel-siepmann.de> | ||
* | ||
* 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\PageTitleProvider; | ||
|
||
use Wrm\Events\Domain\Model\Date; | ||
|
||
final class DateTitleProvider implements DateTitleProviderInterface | ||
{ | ||
/** | ||
* @var null|Date | ||
*/ | ||
private $date = null; | ||
|
||
public function setDate(Date $date): void | ||
{ | ||
$this->date = $date; | ||
} | ||
|
||
public function getTitle(): string | ||
{ | ||
if ($this->date === null || $this->date->getEvent() === null) { | ||
return ''; | ||
} | ||
|
||
return implode(' ', [ | ||
$this->date->getEvent()->getTitle(), | ||
$this->date->getStart()->format('d.m.Y H:i'), | ||
]); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
Classes/Frontend/PageTitleProvider/DateTitleProviderInterface.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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright (C) 2023 Daniel Siepmann <coding@daniel-siepmann.de> | ||
* | ||
* 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\PageTitleProvider; | ||
|
||
use TYPO3\CMS\Core\PageTitle\PageTitleProviderInterface; | ||
use TYPO3\CMS\Core\SingletonInterface; | ||
use Wrm\Events\Domain\Model\Date; | ||
|
||
interface DateTitleProviderInterface extends PageTitleProviderInterface, SingletonInterface | ||
{ | ||
public function setDate(Date $date): void; | ||
} |
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,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright (C) 2023 Daniel Siepmann <coding@daniel-siepmann.de> | ||
* | ||
* 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\PageTitleProvider; | ||
|
||
use Wrm\Events\Domain\Model\Event; | ||
|
||
final class EventTitleProvider implements EventTitleProviderInterface | ||
{ | ||
/** | ||
* @var null|Event | ||
*/ | ||
private $event = null; | ||
|
||
public function setEvent(Event $event): void | ||
{ | ||
$this->event = $event; | ||
} | ||
|
||
public function getTitle(): string | ||
{ | ||
if ($this->event === null) { | ||
return ''; | ||
} | ||
|
||
return $this->event->getTitle(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
Classes/Frontend/PageTitleProvider/EventTitleProviderInterface.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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright (C) 2023 Daniel Siepmann <coding@daniel-siepmann.de> | ||
* | ||
* 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\PageTitleProvider; | ||
|
||
use TYPO3\CMS\Core\PageTitle\PageTitleProviderInterface; | ||
use TYPO3\CMS\Core\SingletonInterface; | ||
use Wrm\Events\Domain\Model\Event; | ||
|
||
interface EventTitleProviderInterface extends PageTitleProviderInterface, SingletonInterface | ||
{ | ||
public function setEvent(Event $event): void; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.. index:: single: page title | ||
.. _pageTitle: | ||
|
||
Page Title | ||
========== | ||
|
||
The extension comes with default implementations for PageTitleProvider. | ||
|
||
The default implementation can be exchanged by leveraging TYPO3 Dependency Injection. | ||
|
||
Further resources: | ||
|
||
* https://docs.typo3.org/m/typo3/reference-coreapi/12.4/en-us/ApiOverview/Seo/PageTitleApi.html | ||
|
||
* https://docs.typo3.org/m/typo3/reference-coreapi/12.4/en-us/ApiOverview/DependencyInjection/Index.html |
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
32 changes: 32 additions & 0 deletions
32
Tests/Functional/Frontend/DatesTestFixtures/DatePageTitle.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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
return [ | ||
'tt_content' => [ | ||
0 => [ | ||
'uid' => '1', | ||
'pid' => '1', | ||
'CType' => 'list', | ||
'list_type' => 'events_dateshow', | ||
'header' => 'Singleview', | ||
], | ||
], | ||
'tx_events_domain_model_event' => [ | ||
0 => [ | ||
'uid' => '1', | ||
'pid' => '2', | ||
'title' => 'Title of Event', | ||
'hidden' => '0', | ||
], | ||
], | ||
'tx_events_domain_model_date' => [ | ||
0 => [ | ||
'uid' => '1', | ||
'pid' => '2', | ||
'event' => '1', | ||
'start' => '1676419200', | ||
'end' => '1676484000', | ||
], | ||
], | ||
]; |
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
23 changes: 23 additions & 0 deletions
23
Tests/Functional/Frontend/EventsTestFixtures/EventPageTitle.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,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
return [ | ||
'tt_content' => [ | ||
0 => [ | ||
'uid' => '1', | ||
'pid' => '1', | ||
'CType' => 'list', | ||
'list_type' => 'events_eventshow', | ||
'header' => 'Singleview', | ||
], | ||
], | ||
'tx_events_domain_model_event' => [ | ||
0 => [ | ||
'uid' => '1', | ||
'pid' => '2', | ||
'title' => 'Title of Event', | ||
'hidden' => '0', | ||
], | ||
], | ||
]; |
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