Skip to content

Commit

Permalink
Use Annotations for the Content Element
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansl committed Mar 10, 2022
1 parent 7397e7e commit 84d9022
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 83 deletions.
50 changes: 50 additions & 0 deletions src/Controller/ContentElement/ContaoClickskeksController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php


declare(strict_types=1);

/*
* This file is part of Contao Clickskeks Bundle.
*
* (c) Stefan Schulz-Lauterbach (https://clickpress.de)
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Clickpress\ContaoClickskeksBundle\Controller\ContentElement;

use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController;
use Contao\CoreBundle\ServiceAnnotation\ContentElement;
use Contao\ContentModel;
use Contao\BackendTemplate;
use Contao\PageModel;
use Contao\System;
use Contao\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
* @ContentElement(category="texts")
*/
class ContaoClickskeksController extends AbstractContentElementController
{
protected string $strDisclaimerUrl = 'https://static.clickskeks.at/%s/%s/%s/disclaimer.js';

protected function getResponse(Template $template, ContentModel $model, Request $request): ?Response
{
global $objPage;
$objRootPage = PageModel::findByPk($objPage->rootId);
$html = sprintf(
$this->strDisclaimerUrl,
substr($objRootPage->clickskeks_api_key, 0, 2),
substr($objRootPage->clickskeks_api_key, 2, 2),
$objRootPage->clickskeks_api_key
);

$template->clickskeks_disclaimer_url = $html;
dump($model);

return $template->getResponse();
}
}
57 changes: 0 additions & 57 deletions src/Elements/ContaoClickskeksElement.php

This file was deleted.

10 changes: 8 additions & 2 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
services:
Clickpress\ContaoClickskeksBundle\EventListener\ContaoClickskeksListener:
tags: ['terminal42_service_annotation']
_defaults:
autoconfigure: true

Clickpress\ContaoClickskeksBundle\EventListener\ContaoClickskeksListener:
tags: ["terminal42_service_annotation"]

Clickpress\ContaoClickskeksBundle\Controller\ContentElement\ContaoClickskeksController:
tags: ["terminal42_service_annotation"]
18 changes: 0 additions & 18 deletions src/Resources/contao/config/config.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Resources/contao/dca/tl_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
* file that was distributed with this source code.
*/

$GLOBALS['TL_DCA']['tl_content']['palettes']['clickskeks_disclaimer'] = '{type_legend},type;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,sliderCustomOptions;{invisible_legend:hide},invisible,start,stop';
$GLOBALS['TL_DCA']['tl_content']['palettes']['contao_clickskeks'] = '{type_legend},type;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests;{invisible_legend:hide},invisible,start,stop';
4 changes: 2 additions & 2 deletions src/Resources/contao/languages/de/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
* file that was distributed with this source code.
*/

$GLOBALS['TL_LANG']['CTE']['clickskeks_disclaimer'][0] = 'Clickskeks Disclaimer';
$GLOBALS['TL_LANG']['CTE']['clickskeks_disclaimer'][1] = 'Clickskeks Disclaimer';
$GLOBALS['TL_LANG']['CTE']['contao_clickskeks'][0] = 'Clickskeks Disclaimer';
$GLOBALS['TL_LANG']['CTE']['contao_clickskeks'][1] = 'Clickskeks Disclaimer';
4 changes: 2 additions & 2 deletions src/Resources/contao/languages/en/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
* file that was distributed with this source code.
*/

$GLOBALS['TL_LANG']['CTE']['clickskeks_disclaimer'][0] = 'Clickskeks Disclaimer';
$GLOBALS['TL_LANG']['CTE']['clickskeks_disclaimer'][1] = 'Clickskeks Disclaimer';
$GLOBALS['TL_LANG']['CTE']['contao_clickskeks'][0] = 'Clickskeks Disclaimer';
$GLOBALS['TL_LANG']['CTE']['contao_clickskeks'][1] = 'Clickskeks Disclaimer';
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

<script id="clickskeks-disclaimer-script" src="<?= $this->clickskeks_diclaimer_url ?>" type="application/javascript"></script>
<script id="clickskeks-disclaimer-script" src="<?= $this->clickskeks_disclaimer_url ?>" type="application/javascript"></script>

0 comments on commit 84d9022

Please sign in to comment.