Insert-Tag Hook über Annotation nur im Debug-Modus
Hallo zusammen,
ich habe zurzeit das Problem, dass meine eigenen Insert-Tags nur im Debug Modus von Contao 4.11 funktionieren.
Ich habe mich dabei an die folgende Anleitung gehalten.
https://docs.contao.org/dev/framework/insert-tags/
In der Anleitung steht dazu: "Creating this file while using the Hook service annotation within is all you have to do in Contao 4.9 and upwards."
Folgende Dateien habe ich angelegt.
PHP-Code:
// src/EventListener/ColorInsertTagListener.php
namespace App\EventListener;
use Contao\CoreBundle\ServiceAnnotation\Hook;
/**
* @Hook("replaceInsertTags")
*/
class ColorInsertTagListener
{
public const TAG = 'color';
public function __invoke(string $tag)
{
// Split tag
$chunks = explode('::', $tag, 3);
// Check if tag is valid
if (count($chunks) !== 3 || $chunks[0] !== self::TAG) return false;
// Return string
return '<span class="color-' . $chunks[1] . '">' . $chunks[2] . '</span>';
}
}
PHP-Code:
// src/EventListener/StrongInsertTagListener.php
namespace App\EventListener;
use Contao\CoreBundle\ServiceAnnotation\Hook;
/**
* @Hook("replaceInsertTags")
*/
class StrongInsertTagListener
{
public const TAG = 'strong';
public function __invoke(string $tag)
{
// Split tag
$chunks = explode('::', $tag, 2);
// Check if tag is valid
if (count($chunks) !== 2 || $chunks[0] !== self::TAG) return false;
// Return string
return '<strong>' . $chunks[1] . '</strong>';
}
}
Im Debug-Modus funktioniert es wunderbar. Leider funktioniert es im Prod-Environment nicht.
Folgendes habe ich versucht:
- Contao Manager: Prod-Cache leeren
- Contao Manager: Composer Class Loader => Datei aktualisieren
- Contao Manager: Composer-Abhängigkeiten => Installer ausführen
- Contao Manager: Composer-Cache => Cache leeren
- Contao Manager: Opcode-Cache => Cache leeren
- Contao Backend: Systemwartung => Alle Daten bereinigt
Leider werden die Insert Tags nach wie vor nur im Debug Modus ersetzt. Habe ich hier etwas übersehen?
Danke und VG
Dennis
Ich habe das gleiche Problem mit processFormData Hook (Contao 4.11.9)
Ich hänge mich jetzt einfach mal in den Thread, denn ich habe wohl das gleiche Problem.
Mein processFormData Hook mit Annotation läuft auch nur im Debug-Mode. Sonst wird er scheinbar nicht aufgerufen (bekomme dann z.B. keine Log-Messages).
PHP-Code:
<?php
/* Contao-Root/src/cje/ */
namespace App\cje;
use Contao\CoreBundle\Monolog\ContaoContext;
use Psr\Log\LogLevel;
use Contao\CoreBundle\ServiceAnnotation\Hook;
use Contao\FrontendTemplate;
use Contao\Module;
use Contao\Form;
use Contao\Database;
class FormHookListener
{
/**
* @Hook("processFormData")
*/
public function onProcessFormData(
array $submittedData,
array $formData,
?array $files,
array $labels,
Form $form
): void
{
\System::log('ProcessFormData: called (FormId: ' . $form->formID . ')', __METHOD__, TL_FORMS);
if ($form->formID == 'status') {
\System::log('ProcessFormData Passcode ' . $submittedData['passcode'], __METHOD__, TL_FORMS);
$status_response = fonti_check_status($submittedData['passcode']);
\System::log('ProcessFormData Status response: ' . $status_response, __METHOD__, TL_FORMS);
$session = \Session::getInstance();
$session->set('status_response', $status_response);
}
if ($form->formID == 'abrechnung') {
}
}
/**
* @Hook("prepareFormData")
*/
public function onPrepareFormData(
array &$submittedData,
array $labels,
array $fields,
Form $form
)
{
}
}
Was mache ich da falsch? Bin noch recht neu im Umgang mit Contao.
Die Datei habe ich unter FormHookListener.php unter [contao_root]/src/cje abgelegt.