feat: add Contao 5.7 pinboard bundle

This commit is contained in:
Jürgen Mummert
2026-03-04 15:44:07 +01:00
commit 47b5199c54
15 changed files with 619 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
namespace Eiswurm\ContaoPinboardBundle\Controller\FrontendModule;
use Contao\CoreBundle\Controller\FrontendModule\AbstractFrontendModuleController;
use Contao\FilesModel;
use Contao\ModuleModel;
use Contao\Template;
use Eiswurm\ContaoPinboardBundle\Model\PinboardModel;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
final class PinboardController extends AbstractFrontendModuleController
{
protected function getResponse(Template $template, ModuleModel $model, Request $request): Response
{
$collection = PinboardModel::findBy(
['published = ?'],
['1'],
['order' => 'hervorgehoben DESC, dateAdded DESC, id DESC']
);
$notes = [];
if (null !== $collection) {
foreach ($collection as $entry) {
$imagePath = null;
if ($entry->bild) {
$fileModel = FilesModel::findByUuid($entry->bild);
$imagePath = $fileModel?->path;
}
$notes[] = [
'id' => (int) $entry->id,
'headline' => (string) $entry->ueberschrift,
'text' => (string) $entry->text,
'link' => (string) $entry->link,
'dateAdded' => (int) $entry->dateAdded,
'dateModified' => (int) $entry->dateModified,
'imagePath' => $imagePath,
'highlighted' => '1' === $entry->hervorgehoben,
];
}
}
return $this->render('@Contao/frontend_module/pinnwand.html.twig', [
'entries' => $notes,
'module' => $model,
]);
}
}