CustomOperationButton erstellen und anderen Button deaktivieren
Hi,
ich möchte gerne einen Button in die Button-Reihe eines Datensatzes einfügen. Ist erstmal egal ob in der TreeView oder ParentView.
Ich habe im DataContainer folgende Methode gefunden:
PHP-Code:
/**
* Compile buttons from the table configuration array and return them as HTML
*
* @param array $arrRow
* @param string $strTable
* @param array $arrRootIds
* @param boolean $blnCircularReference
* @param array $arrChildRecordIds
* @param string $strPrevious
* @param string $strNext
*
* @return DataContainerOperationsBuilder
*/
protected function generateButtons($arrRow, $strTable, $arrRootIds=array(), $blnCircularReference=false, $arrChildRecordIds=null, $strPrevious=null, $strNext=null)
{
return System::getContainer()->get('contao.data_container.operations_builder')->initializeWithButtons(
$strTable,
$arrRow,
$this,
function (DataContainerOperation $config) use ($arrRow, $strTable, $arrRootIds, $arrChildRecordIds, $blnCircularReference, $strPrevious, $strNext) {
trigger_deprecation('contao/core-bundle', '5.5', 'Using a button_callback without DataContainerOperation object is deprecated and will no longer work in Contao 6.');
if (\is_array($config['button_callback'] ?? null))
{
$callback = System::importStatic($config['button_callback'][0]);
$config->setHtml($callback->{$config['button_callback'][1]}($arrRow, $config['href'] ?? null, $config['label'], $config['title'], $config['icon'] ?? null, $config['attributes'], $strTable, $arrRootIds, $arrChildRecordIds, $blnCircularReference, $strPrevious, $strNext, $this));
}
elseif (\is_callable($config['button_callback'] ?? null))
{
$config->setHtml($config['button_callback']($arrRow, $config['href'] ?? null, $config['label'], $config['title'], $config['icon'] ?? null, $config['attributes'], $strTable, $arrRootIds, $arrChildRecordIds, $blnCircularReference, $strPrevious, $strNext, $this));
}
}
);
}
Da wird nun darauf hingewiesen das nur Array-Config deprecated ist.
Ich wollte mal fragen wie ich eine DataContainerOperation programmieren muss. Ich habe mir im Core schon sämtliche Operation-Klassen angesehen, aber ich finde nicht so recht den Anfang. Ich dachte man muss im DCA die einfach ein Operation-Array konfigurieren. Hier habe ich ein Beispiel was ich gerade benutze, aber das verursacht bei tl_page leider einen Bug.
PHP-Code:
$GLOBALS['TL_DCA'][$ptable]['list']['operations']['children']['primary'] = true;
$GLOBALS['TL_DCA'][$ptable]['list']['operations']['children']['attributes'] = 'data-contao--deeplink-target="primary"';
$GLOBALS['TL_DCA'][$ptable]['list']['operations']['children']['icon'] = 'system/themes/flexible/icons/children.svg';
$GLOBALS['TL_DCA'][$ptable]['list']['operations']['children']['label'] = ['Inhalte', 'Inhalt bearbeiten'];
$GLOBALS['TL_DCA'][$ptable]['list']['operations']['children']['button_callback'] = ['Bits\FlyUxBundle\Operation\Children', 'contentShowButton'];
Bei allen Tables funktioniert es nur bei tl_page führt es dazu das die anderen Buttons verschwinden.
Wie soll denn in Contao 6 das Vorgehen zu Buttons sein, also wo erfolgt die Konfiguration der Parameter für die generateButtons und wo kann ich dann steuern welche Buttons angezeigt oder deaktiviert werden sollen?
Bin das Problem umgangen