fix: replace relation to date entity with text property for code

This commit is contained in:
Björn Fromme
2024-11-08 13:04:26 +01:00
parent 72f2c9706e
commit 225b90e71b
5 changed files with 40 additions and 41 deletions
@@ -3,25 +3,41 @@
namespace EP\EpProducts\Controller;
use EP\EpProducts\Domain\Model\Travelinfo;
use EP\EpProducts\Domain\Repository\DateRepository;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class TravelinfoController extends ActionController
{
/**
* @var DateRepository
*/
private $dateRepository;
/**
* @var SiteFinder
*/
private $siteFinder;
public function __construct(DateRepository $dateRepository, SiteFinder $siteFinder)
{
$this->dateRepository = $dateRepository;
$this->siteFinder = $siteFinder;
}
public function indexAction(Travelinfo $travelinfo)
{
$today = new \DateTimeImmutable();
$date = $travelinfo->getTravelDate();
$date = $this->dateRepository->findOneByCode($travelinfo->getTravelCode());
if (null === $date || $date->getDateEnd() < $today) {
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
$site = $siteFinder->getSiteByIdentifier('ep-reisen');
$site = $this->siteFinder->getSiteByIdentifier('ep-reisen');
$rootPageId = $site->getRootPageId();
$uri = $site->getRouter()->generateUri($rootPageId);
$this->redirectToUri($uri);
}
$this->view->assign('travelinfo', $travelinfo);
$this->view->assign('date', $date);
}
}
@@ -75,9 +75,9 @@ class Travelinfo extends AbstractEntity
protected $links;
/**
* @var Date
* @var string
*/
protected $travelDate;
protected $travelCode;
public function __construct()
{
@@ -248,14 +248,16 @@ class Travelinfo extends AbstractEntity
return $this;
}
public function getTravelDate()
public function getTravelCode()
{
return $this->travelDate;
return $this->travelCode;
}
public function setTravelDate($travelDate)
public function setTravelCode($travelCode)
{
$this->travelDate = $travelDate;
$this->travelCode = $travelCode;
return $this;
}
}
@@ -27,7 +27,7 @@ return [
],
],
'palettes' => [
'basics' => ['showitem' => 'title,path_segment,--linebreak--,travel_date,--linebreak--,links,--linebreak--,teasers'],
'basics' => ['showitem' => 'title,path_segment,--linebreak--,travel_code,--linebreak--,links,--linebreak--,teasers'],
'text' => ['showitem' => 'subline,headline,--linebreak--,intro_text,--linebreak--,footer_text,--linebreak--,
self_arranged_text,--linebreak--,additional_info,--linebreak--,important_phone_numbers,--linebreak--,
important_links'],
@@ -190,32 +190,13 @@ return [
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
),
],
'travel_date' => [
'travel_code' => [
'exclude' => false,
'label' => 'Termin',
'label' => 'Reisecode des Termins',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'tx_epproducts_domain_model_date',
'minitems' => 1,
'maxitems' => 1,
'size' => 1,
'fieldControl' => [
'elementBrowser' => [
'disabled' => true,
],
],
'fieldWizard' => [
'recordsOverview' => [
'disabled' => true,
],
],
'suggestOptions' => [
'default' => [
'additionalSearchFields' => 'code,product_name,product_keywords',
'orderBy' => 'code',
],
],
'type' => 'input',
'size' => 30,
'eval' => 'trim,required'
],
],
'intro_text' => [
@@ -1370,7 +1370,7 @@ CREATE TABLE tx_epproducts_domain_model_travelinfo
footer_image int(11) DEFAULT '0' NOT NULL,
links int(11) DEFAULT '0' NOT NULL,
teasers int(11) DEFAULT '0' NOT NULL,
travel_date int(11) DEFAULT '0' NOT NULL,
travel_code varchar(255) DEFAULT '' NOT NULL,
path_segment varchar(255) DEFAULT '' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
@@ -45,7 +45,7 @@
</h1>
{travelinfo.introText -> f:format.html()}
<p>
{travelinfo.traveldate.product.name} {travelinfo.traveldate.dateStart -> f:format.date(format: 'd.m.Y')} - {travelinfo.traveldate.dateEnd -> f:format.date(format: 'd.m.Y')}
{date.product.name} {date.dateStart -> f:format.date(format: 'd.m.Y')} - {date.dateEnd -> f:format.date(format: 'd.m.Y')}
</p>
</div>
</div>
@@ -64,11 +64,11 @@
Adresse
</h3>
<p>
{travelinfo.traveldate.hotel.name}
{date.hotel.name}
<br>
{travelinfo.traveldate.hotel.address -> f:format.nl2br()}
{date.hotel.address -> f:format.nl2br()}
</p>
<f:if condition="{travelinfo.traveldate.busIncluded}">
<f:if condition="{date.busIncluded}">
<h3 class="text-white">
Bus-Zustiege
</h3>
@@ -84,7 +84,7 @@
Uhrzeit
</th>
</tr>
<f:for each="{travelinfo.traveldate.pickups}" as="pickup">
<f:for each="{date.pickups}" as="pickup">
<tr class="odd:bg-zinc-50 align-top">
<td class="border-r border-zinc-200 px-2 py-1 md:p-2">
{pickup.city}<br><span class="text-xs">{pickup.street}</span>