feat: add Contao 5.7 pinboard bundle
This commit is contained in:
54
src/Controller/FrontendModule/PinboardController.php
Normal file
54
src/Controller/FrontendModule/PinboardController.php
Normal 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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user