DCA Anpassungen machst du im Ordner contao/dca/
Ja das geht...
Ich dachte app/Resoures/contao/dca - das geht nämlich auch. (komisch)
nun nochmal zum callback.
Den hab ich nun so gebaut:
src/EventListener/DataContainer/ProductFieldListener.php
PHP-Code:
<?php
namespace App\EventListener\DataContainer;
use Contao\CoreBundle\ServiceAnnotation\Callback;
use Contao\DataContainer;
class ProductFieldListener{
/**
* Extract the YouTube ID from an URL
*
* @Callback(table="tl_iso_product", target="fields.youtube.save")
*
* @param mixed $varValue
* @param DataContainer $dc
*
* @return mixed
*/
public function extractYouTubeId($varValue, DataContainer $dc)
{
if ($dc->activeRecord->youtube != $varValue)
{
$matches = array();
if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $varValue, $matches))
{
$varValue = $matches[1];
}
}
return $varValue;
}
}
keine Fehler... aber auch keine Funktion.
Wenn ich am Ende ein return "foo"; mache funktioniert das zwar aber ich will ja die YouTube ID aus der url.
Daher dachte ich, es wär sinnvoller code aus tl_content.php wiederzuverwenden anstatt zu duplizieren.
(Der Editor hier ist irgendwie eine Zumutung...)
Lesezeichen