Open berecont opened 1 month ago
Das sollte jetzt in der Version 2.0.1 nicht mehr auftreten.
neuer Fehler taucht auf
Warning: Undefined array key "day"
ErrorException:
Warning: Undefined array key "day"
at C:\laragon\www\dev5x\vendor\contao-themes-shop\vacancy-calendar\contao\templates\mod_vacancy_calendar.html5:69
at include('C:\\laragon\\www\\dev5x\\vendor\\contao-themes-shop\\vacancy-calendar\\contao\\templates\\mod_vacancy_calendar.html5')
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\library\Contao\TemplateInheritance.php:109)
at Contao\Template->inherit()
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\library\Contao\Template.php:315)
at Contao\Template->parse()
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\classes\FrontendTemplate.php:43)
at Contao\FrontendTemplate->parse()
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\classes\FrontendTemplate.php:89)
at Contao\FrontendTemplate->compile()
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\classes\FrontendTemplate.php:69)
at Contao\FrontendTemplate->getResponse()
(C:\laragon\www\dev5x\vendor\contao\core-bundle\src\Controller\AbstractFragmentController.php:103)
at Contao\CoreBundle\Controller\AbstractFragmentController->Contao\CoreBundle\Controller\{closure}(object(FragmentTemplate), null)
(C:\laragon\www\dev5x\vendor\contao\core-bundle\src\Twig\FragmentTemplate.php:130)
at Contao\CoreBundle\Twig\FragmentTemplate->getResponse()
(C:\laragon\www\dev5x\vendor\contao-themes-shop\vacancy-calendar\src\Controller\FrontendModule\VacancyCalendarController.php:55)
at ContaoThemesShop\VacancyCalendar\Controller\FrontendModule\VacancyCalendarController->getResponse(object(FragmentTemplate), object(ModuleModel), object(Request))
(C:\laragon\www\dev5x\vendor\contao\core-bundle\src\Controller\FrontendModule\AbstractFrontendModuleController.php:43)
at Contao\CoreBundle\Controller\FrontendModule\AbstractFrontendModuleController->__invoke(object(Request), object(ModuleModel), 'main', null)
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\HttpKernel.php:181)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 2)
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\HttpKernel.php:76)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 2, false)
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\HttpCache\SubRequestHandler.php:86)
at Symfony\Component\HttpKernel\HttpCache\SubRequestHandler::handle(object(HttpKernel), object(Request), 2, false)
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\Fragment\InlineFragmentRenderer.php:78)
at Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer->render('/_fragment?_path=_format%3Dhtml%26_locale%3Dde%26_controller%3Dcontao.frontend_module.vacancy_calendar', object(Request), array('ignore_errors' => false))
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\Fragment\FragmentHandler.php:83)
at Symfony\Component\HttpKernel\Fragment\FragmentHandler->render(object(FrontendModuleReference), 'forward', array('ignore_errors' => false))
(C:\laragon\www\dev5x\vendor\contao\core-bundle\src\Fragment\FragmentHandler.php:66)
at Contao\CoreBundle\Fragment\FragmentHandler->render(object(FrontendModuleReference))
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\modules\ModuleProxy.php:60)
at Contao\ModuleProxy->generate()
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\library\Contao\Controller.php:405)
at Contao\Controller::getFrontendModule(object(ModuleModel), 'main')
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\elements\ContentModule.php:59)
at Contao\ContentModule->generate()
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\library\Contao\Controller.php:601)
at Contao\Controller::getContentElement(object(ContentModel), 'main')
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\modules\ModuleArticle.php:189)
at Contao\ModuleArticle->compile()
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\modules\Module.php:213)
at Contao\Module->generate()
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\modules\ModuleArticle.php:69)
at Contao\ModuleArticle->generate(false)
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\library\Contao\Controller.php:490)
at Contao\Controller::getArticle(object(ArticleModel), false, false, 'main')
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\library\Contao\Controller.php:356)
at Contao\Controller::getFrontendModule('0', 'main')
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\pages\PageRegular.php:177)
at Contao\PageRegular->prepare(object(PageModel))
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\pages\PageRegular.php:47)
at Contao\PageRegular->getResponse(object(PageModel), true)
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\controllers\FrontendIndex.php:65)
at Contao\FrontendIndex->renderPage(object(PageModel))
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\HttpKernel.php:181)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\HttpKernel.php:76)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\Kernel.php:197)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
(C:\laragon\www\dev5x\public\index.php:42)
und zusätzlich habe ich nun eine neue Belegung für August eingegeben. Danach anderer Stack Trace:
ErrorException:
Warning: Undefined array key 20240810
at C:\laragon\www\dev5x\vendor\contao-themes-shop\vacancy-calendar\src\Generator\CalendarGenerator.php:86
at ContaoThemesShop\VacancyCalendar\Generator\CalendarGenerator->generateMonth(object(Carbon), true, true)
(C:\laragon\www\dev5x\vendor\contao-themes-shop\vacancy-calendar\src\Controller\FrontendModule\VacancyCalendarController.php:46)
at ContaoThemesShop\VacancyCalendar\Controller\FrontendModule\VacancyCalendarController->getResponse(object(FragmentTemplate), object(ModuleModel), object(Request))
(C:\laragon\www\dev5x\vendor\contao\core-bundle\src\Controller\FrontendModule\AbstractFrontendModuleController.php:43)
at Contao\CoreBundle\Controller\FrontendModule\AbstractFrontendModuleController->__invoke(object(Request), object(ModuleModel), 'main', null)
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\HttpKernel.php:181)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 2)
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\HttpKernel.php:76)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 2, false)
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\HttpCache\SubRequestHandler.php:86)
at Symfony\Component\HttpKernel\HttpCache\SubRequestHandler::handle(object(HttpKernel), object(Request), 2, false)
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\Fragment\InlineFragmentRenderer.php:78)
at Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer->render('/_fragment?_path=_format%3Dhtml%26_locale%3Dde%26_controller%3Dcontao.frontend_module.vacancy_calendar', object(Request), array('ignore_errors' => false))
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\Fragment\FragmentHandler.php:83)
at Symfony\Component\HttpKernel\Fragment\FragmentHandler->render(object(FrontendModuleReference), 'forward', array('ignore_errors' => false))
(C:\laragon\www\dev5x\vendor\contao\core-bundle\src\Fragment\FragmentHandler.php:66)
at Contao\CoreBundle\Fragment\FragmentHandler->render(object(FrontendModuleReference))
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\modules\ModuleProxy.php:60)
at Contao\ModuleProxy->generate()
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\library\Contao\Controller.php:405)
at Contao\Controller::getFrontendModule(object(ModuleModel), 'main')
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\elements\ContentModule.php:59)
at Contao\ContentModule->generate()
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\library\Contao\Controller.php:601)
at Contao\Controller::getContentElement(object(ContentModel), 'main')
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\modules\ModuleArticle.php:189)
at Contao\ModuleArticle->compile()
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\modules\Module.php:213)
at Contao\Module->generate()
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\modules\ModuleArticle.php:69)
at Contao\ModuleArticle->generate(false)
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\library\Contao\Controller.php:490)
at Contao\Controller::getArticle(object(ArticleModel), false, false, 'main')
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\library\Contao\Controller.php:356)
at Contao\Controller::getFrontendModule('0', 'main')
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\pages\PageRegular.php:177)
at Contao\PageRegular->prepare(object(PageModel))
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\pages\PageRegular.php:47)
at Contao\PageRegular->getResponse(object(PageModel), true)
(C:\laragon\www\dev5x\vendor\contao\core-bundle\contao\controllers\FrontendIndex.php:65)
at Contao\FrontendIndex->renderPage(object(PageModel))
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\HttpKernel.php:181)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\HttpKernel.php:76)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
(C:\laragon\www\dev5x\vendor\symfony\http-kernel\Kernel.php:197)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
(C:\laragon\www\dev5x\public\index.php:42)
mögliche Anpassungen in der CalendarGenerator.php:
<?php
declare(strict_types=1);
namespace ContaoThemesShop\VacancyCalendar\Generator;
use Carbon\Carbon;
use Contao\Model\Collection;
use ContaoThemesShop\VacancyCalendar\Model\ReservationModel;
use Symfony\Contracts\Translation\TranslatorInterface;
use function array_key_exists;
use function count;
use function is_array;
use function ksort;
use function sprintf;
/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
final class CalendarGenerator
{
private const DATE_FORMAT = 'Ymd';
/** @var mixed[][] */
private array $reservations = [];
public function __construct(private readonly TranslatorInterface $translator)
{
}
/** @return mixed[] */
public function generateMonth(int $month, bool $monthShort, bool $dayShort): array
{
$currentMonth = (new Carbon())->month;
$month = Carbon::createFromDate(null, $currentMonth + $month, 1);
$monthLabelKey = $monthShort ? 'MONTHS_SHORT' : 'MONTHS';
$dayLabelKey = $dayShort ? 'DAYS_SHORT' : 'DAYS';
$data = [];
$data['label']['month'] = $this->translator->trans(
sprintf('%s.%s', $monthLabelKey, $month->month - 1),
[],
'contao_default',
);
$data['label']['year'] = $month->year;
for ($i = 1; $i <= 7; ++$i) {
if ($i === 7) {
$data['days'][] = $this->translator->trans(
sprintf('%s.%s', $dayLabelKey, 0),
[],
'contao_default',
);
continue;
}
$data['days'][] = $this->translator->trans(
sprintf('%s.%s', $dayLabelKey, $i),
[],
'contao_default',
);
}
$week = 1;
for ($i = 1; $i < ($month->dayOfWeek === 0 ? 7 : $month->dayOfWeek); ++$i) {
$data['weeks'][$week][] = ['class' => 'empty', 'day' => ''];
}
$day = clone $month;
do {
$dayBefore = (clone $day)->subDay();
$dayAfter = (clone $day)->addDay();
$class = '';
$currentDate = $day->format(self::DATE_FORMAT);
$prevDate = $dayBefore->format(self::DATE_FORMAT);
$nextDate = $dayAfter->format(self::DATE_FORMAT);
if (!isset($this->reservations[$currentDate]) || !is_array($this->reservations[$currentDate])) {
$class = 'vacant';
} else {
$currentReservation = $this->reservations[$currentDate];
if ($currentReservation['state'] === 1) {
if (!isset($this->reservations[$prevDate]) || $this->reservations[$prevDate]['state'] <= 1) {
$class = 'begin';
} elseif (!isset($this->reservations[$nextDate]) || $this->reservations[$nextDate]['state'] < 2) {
$class = 'end';
} else {
$class = 'full';
}
} elseif ($currentReservation['state'] > 1) {
$class = 'full';
if ($currentReservation['isOption'] === true && (!isset($this->reservations[$prevDate]) || $this->reservations[$prevDate]['isOption'] === false)) {
$class = 'regular-option';
}
if ($currentReservation['isOption'] === false && (isset($this->reservations[$prevDate]) && $this->reservations[$prevDate]['isOption'] === true)) {
$class = 'option-regular';
}
}
if ($currentReservation['isOption'] === true) {
$class .= ' is-option';
}
}
$data['weeks'][$week][] = ['class' => $class, 'day' => $day->day];
if (count($data['weeks'][$week]) === 7) {
++$week;
$data['weeks'][$week] = [];
}
$day->addDay();
} while ($day->lte($month->endOfMonth()));
$remainingDays = count($data['weeks'][$week]);
if ($remainingDays < 7 && $remainingDays > 0) {
for ($i = 1; $i <= 7 - $remainingDays; ++$i) {
$data['weeks'][$week][] = ['class' => 'empty', 'day' => ''];
}
}
return $data;
}
public function addReservations(Collection|null $reservations): void
{
foreach ($reservations ?? [] as $reservation) {
$this->addReservation($reservation);
}
ksort($this->reservations);
}
public function addReservation(ReservationModel $reservationModel): void
{
$begin = Carbon::createFromTimestamp((int) $reservationModel->begin);
$end = Carbon::createFromTimestamp((int) $reservationModel->end);
if ($begin->eq($end)) {
$this->addToReservations($begin->format(self::DATE_FORMAT), 2, $reservationModel);
return;
}
$this->addToReservations(
$begin->format(self::DATE_FORMAT),
(array_key_exists($begin->format(self::DATE_FORMAT), $this->reservations) ? 2 : 1),
$reservationModel,
);
$this->addToReservations(
$end->format(self::DATE_FORMAT),
1,
$reservationModel,
);
$day = clone $begin;
$lastDay = clone $end->subDay();
do {
$day->addDay();
$this->addToReservations(
$day->format(self::DATE_FORMAT),
2,
$reservationModel,
);
} while ($day->lt($lastDay));
}
private function addToReservations(string $date, int $state, ReservationModel $reservationModel): void
{
$this->reservations[$date] = [
'state' => $state,
'isOption' => (bool) $reservationModel->isOption,
];
}
}
Das sollte in der 2.0.2 jetzt behoben sein :-)
Contao 5.3.11 Version 2.0.0
im dev-mode bekomme ich folgende Warnung, beim Aufruf des Frontends: Warning: Undefined array key 20240701