Fehler im Backend - DCA-Fehler: The arguments array must contain 1 items, 0 given
Hallo,
ich habe einen Fork von https://github.com/cliffparnitzky/BirthdayMailer erstellt, um das nach 5.3 zu portieren. Das Ganze ist im Moment nur auf github unter: https://github.com/arminfrey/contao-gbm-bundle
DCA tl_geburtstagsmail:
#
PHP-Code:
<?php
use Contao\Backend;
use Contao\DataContainer;
use Contao\DC_Table;
use Contao\Image;
use Contao\Input;
$GLOBALS['TL_DCA']['tl_geburtstagsmail'] = array(
// Config
'config' => array(
'dataContainer' => DC_Table::class,
'enableVersioning' => true,
'sql' => array(
'keys' => array(
'id' => 'primary'
)
)
),
// List
'list' => array(
'sorting' => array(
'mode' => DataContainer::MODE_SORTABLE,
'fields' => array('id'),
'panelLayout' => 'filter;sort,search,limit'
)
),
'label' => array(
'fields' => array('memberGroup:tl_member_group.name', 'priority'),
'label_callback' => array('tl_geburtstagsmail', 'addIcon'),
'showColumns' => true
),
'global_operations' => array(
'sendBirthdayMail' => array(
'label' => &$GLOBALS['TL_LANG']['tl_geburtstagsmail']['sendBirthdayMail'],
'href' => 'key=sendBirthdayMail',
'attributes' => 'onclick="Backend.getScrollOffset();" style="background: url(src//assets/sendBirthdayMail.png) no-repeat scroll left center transparent; margin-left: 15px; padding: 2px 0 3px 20px;"'
),
'all' => array(
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
'href' => 'act=select',
'class' => 'header_edit_all',
'attributes' => 'onclick="Backend.getScrollOffset();"'
)
),
'operations' => array(
'edit' => array(
'label' => &$GLOBALS['TL_LANG']['tl_geburtstagsmail']['edit'],
'href' => 'act=edit',
'icon' => 'edit.svg'
),
'copy' => array(
'label' => &$GLOBALS['TL_LANG']['tl_geburtstagsmail']['copy'],
'href' => 'act=copy',
'icon' => 'copy.svg'
),
'delete' => array(
'label' => &$GLOBALS['TL_LANG']['tl_geburtstagsmail']['delete'],
'href' => 'act=delete',
'icon' => 'delete.svg',
'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset()"'
),
'show' => array(
'label' => &$GLOBALS['TL_LANG']['tl_geburtstagsmail']['show'],
'href' => 'act=show',
'icon' => 'show.svg',
'attributes' => 'style="margin-right:3px"'
)
),
// Palettes
'palettes' => array(
'__selector__' => array('mailUseCustomText'),
'default' => '{config_legend},memberGroup,priority;{email_legend},sender,senderName,mailCopy,mailBlindCopy,mailUseCustomText'
),
// Subpalettes
'subpalettes' => array('mailUseCustomText' => 'mailTextKey'),
// Fields
'fields' => array(
'id' => array(
'sql' => "int(10) unsigned NOT NULL auto_increment"
),
'tstamp' => array(
'sql' => "int(10) unsigned NOT NULL default '0'"
),
'memberGroup' => array(
'label' => &$GLOBALS['TL_LANG']['tl_geburtstagsmail']['memberGroup'],
'exclude' => true,
'inputType' => 'select',
'foreignKey' => 'tl_member_group.name',
'filter' => true,
'eval' => array('mandatory'=>true, 'unique'=>true, 'includeBlankOption'=>true, 'tl_class'=>'w50'),
'sql' => "int(10) unsigned NOT NULL default '0'",
//'relation' => ['type' => 'belongsTo', 'load' => 'lazy']
),
'priority' => array(
'label' => &$GLOBALS['TL_LANG']['tl_geburtstagsmail']['priority'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('rgxp' => 'digit','maxlength'=>10, 'tl_class'=>'w50'),
'sql' => "int(10) unsigned NOT NULL default '0'"
),
'sender' => array(
'label' => &$GLOBALS['TL_LANG']['tl_geburtstagsmail']['sender'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('mandatory'=>true, 'rgxp' => 'email','maxlength'=>128, 'tl_class'=>'w50'),
'sql' => "varchar(128) NOT NULL default '0'"
),
'senderName' => array(
'label' => &$GLOBALS['TL_LANG']['tl_geburtstagsmail']['senderName'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('rgxp' => 'extnd','maxlength'=>128, 'tl_class'=>'w50'),
'sql' => "varchar(128) NOT NULL default '0'"
),
'mailCopy' => array(
'label' => &$GLOBALS['TL_LANG']['tl_geburtstagsmail']['mailCopy'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('rgxp' => 'emails','maxlength'=>255, 'tl_class'=>'w50'),
'sql' => "varchar(255) NOT NULL default '0'"
),
'mailBlindCopy' => array(
'label' => &$GLOBALS['TL_LANG']['tl_geburtstagsmail']['mailBlindCopy'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('rgxp' => 'emails','maxlength'=>255, 'tl_class'=>'w50'),
'sql' => "varchar(255) NOT NULL default '0'"
),
'mailUseCustomText' => array(
'label' => &$GLOBALS['TL_LANG']['tl_geburtstagsmail']['mailUseCustomText'],
'exclude' => true,
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50', 'submitOnChange'=>true),
'sql' => "char(1) NOT NULL default '0'"
),
'mailTextKey' => array(
'label' => &$GLOBALS['TL_LANG']['tl_geburtstagsmail']['mailTextKey'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('mandatory'=>true, 'maxlength'=>20, 'spaceToUnderscore'=>true, 'tl_class'=>'w50'),
'sql' => "varchar(20) NOT NULL default '0'"
)
)
);
class tl_geburtstagsmail extends Backend
{
public function addIcon($row, $label)
{
var_dump("addicon");
if (empty($row)) {
\Contao\Log::add('Row data is empty for icon generation.', 'ContaoGbmBundle addIcon()', TL_ERROR);
}
// Check that row has necessary keys
if (!isset($row['memberGroup'], $row['start'], $row['stop'], $row['disable'])) {
return $label; // Or handle appropriately
}
$image = 'mgroup';
$disabled = ($row['start'] !== '' && $row['start'] > time()) || ($row['stop'] !== '' && $row['stop'] <= time());
if ($disabled || $row['disable']) {
$image .= '--disabled';
}
return sprintf('<div class="list_icon" style="background-image:url(\'%s\')" data-icon="%s" data-icon-disabled="%s">%s</div>',
Image::getUrl($image),
Image::getUrl($image),
Image::getUrl($image . '--disabled'),
$label
);
}
}
Beim Erstellen einer neuen Konfiguration für automatische Mails, bekomme ich den Fehler : The arguments array must contain 1 items, 0 given
Er legt noch eine ID auf der Datenbank an beim Anzeigen des Fehlers. Ich komme leider nicht weiter.
Stacktrace:
Code:
Symfony Exception
Symfony Docs
ErrorException
HTTP 500 Internal Server Error
Warning: Trying to access array offset on null
ErrorException
ErrorException:
Warning: Trying to access array offset on null
at vendor/contao/core-bundle/contao/classes/DataContainer.php:1669
at Contao\DataContainer->generateRecordLabel()
(vendor/contao/core-bundle/src/EventListener/DataContainer/FallbackRecordLabelListener.php:57)
at Contao\CoreBundle\EventListener\DataContainer\FallbackRecordLabelListener->__invoke()
(vendor/symfony/event-dispatcher/Debug/WrappedListener.php:116)
at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke()
(vendor/symfony/event-dispatcher/EventDispatcher.php:220)
at Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
(vendor/symfony/event-dispatcher/EventDispatcher.php:56)
at Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
(vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:139)
at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch()
(vendor/contao/core-bundle/src/DataContainer/RecordLabeler.php:28)
at Contao\CoreBundle\DataContainer\RecordLabeler->getLabel()
(vendor/contao/core-bundle/src/DataContainer/DcaUrlAnalyzer.php:111)
at Contao\CoreBundle\DataContainer\DcaUrlAnalyzer->getTrail()
(vendor/contao/core-bundle/contao/classes/Backend.php:410)
at Contao\Backend->getBackendModule()
(vendor/contao/core-bundle/contao/controllers/BackendMain.php:144)
at Contao\BackendMain->run()
(vendor/contao/core-bundle/src/Controller/BackendController.php:44)
at Contao\CoreBundle\Controller\BackendController->mainAction()
(vendor/symfony/http-kernel/HttpKernel.php:181)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
(vendor/symfony/http-kernel/HttpKernel.php:76)
at Symfony\Component\HttpKernel\HttpKernel->handle()
(vendor/symfony/http-kernel/Kernel.php:197)
at Symfony\Component\HttpKernel\Kernel->handle()
(public/index.php:42)
Contao 5.3.21, PHP 8.3.15
Ich weiß, es ist im DCA versteckt, ich habe aber alles durchgeschaut. Fehlt die memberGroup, weil er die Tabelle nicht findet? Leider kann ich dazwischen kein var_dump() oder print_f() schreiben.
Eilt nicht, aber es wäre schön, wenn mir jemand helfen könnte.
Vielen Dank.
Grüße Armin