Hallo zusammen,
bei der Erstellung von Bundles für Contao 4 bin ich immer noch am verzweifeln. Es gibt zwar inzwischen einige Tutorials. Diese beinhalten aber leider so viel neues im Vergleich zu 3.5, dass es meine mentale Kapazität sprengt. Wie eine detailliert beschriebene Autofahrt von Berlin nach München, aus der ich aber immer noch nicht in der Lage bin herzuleiten, wie ich nach Brandenburg komme. Zurzeit scheitere ich bereits dabei, Contao zur Berücksichtigung eines DCA-Containers zu bewegen. Über diesen möchte ich gerne die Tabelle "tl_cssutils" anlegen.
composer.json
src/CssUtilsBundle.phpCode:{ "name":"bohnmedia/css-utils-bundle", "description":"Generate css utilities from backend", "keywords":["contao","css","sass"], "type":"contao-bundle", "homepage":"https://github.com/bohnmedia/contao-css-utils-bundle", "license":"MIT", "authors":[ { "name":"bohn.media", "homepage":"https://bohn.media", "role":"Developer" } ], "require": { "contao/core-bundle":"~4.4", "leafo/scssphp": "^0.6 || ^0.7", "menatwork/contao-multicolumnwizard": "~3.2" }, "conflict": { "contao/core": "*", "contao/manager-plugin": "<2.0 || >=3.0" }, "extra": { "contao-manager-plugin": "BohnMedia\\CssUtilsBundle\\ContaoManager\\Plugin" }, "autoload":{ "psr-4": { "BohnMedia\\CssUtilsBundle\\": "src/" }, "classmap": [ "src/Classes/" ] } }
src/Resources/contao/dca/tl_theme.php (funktioniert)Code:<?php namespace BohnMedia\CssUtilsBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class CssUtilsBundle extends Bundle { }
src/Resources/contao/dca/tl_cssutils.php (funktioniert nicht)Code:<?php // NEW OPERATION $operations = array( 'cssUtils' => array( 'href' => 'table=tl_cssutils', 'icon' => 'bundles/cssutils/css.svg' ) ); // FIND INDEX OF CSS $cssIndex = array_search("css",array_keys($GLOBALS['TL_DCA']['tl_theme']['list']['operations'])) + 1; // INSERT AFTER CSS $GLOBALS['TL_DCA']['tl_theme']['list']['operations'] = array_merge( array_slice($GLOBALS['TL_DCA']['tl_theme']['list']['operations'], 0, $cssIndex), $operations, array_slice($GLOBALS['TL_DCA']['tl_theme']['list']['operations'], $cssIndex) ); // ADD tl_css_utils AS CHILD TABLE $GLOBALS['TL_DCA']['tl_theme']['config']['ctable'][] = 'tl_cssutils';
Die Änderungen für "tl_theme", die ich in der "tl_theme.php" definiert habe werden auch übernommen, aber die "tl_cssutils.php" im selben Ordner wird einfach ignoriert. Ich habe den Env- und Prod-Cache in den letzten 3 Stunden mehrmals gelöscht und das Bundle auch schon neu installiert, aber das Installtool meldet mir immer noch, die Datenbank sei aktuell, obwohl die Tabelle fehlt.Code:<?php $GLOBALS['TL_DCA']['tl_cssutils'] = array ( 'config' => array ( 'dataContainer' => 'Table', 'ptable' => 'tl_theme', ), 'sql' => array ( 'keys' => array ( 'id' => 'primary' ) ), 'list' => array ( 'sorting' => array ( 'mode' => 4, 'fields' => array('name'), 'panelLayout' => 'filter;sort,search,limit', 'headerFields' => array('name', 'author', 'tstamp') ), 'global_operations' => array ( 'all' => array ( 'href' => 'act=select', 'class' => 'header_edit_all', 'attributes' => 'onclick="Backend.getScrollOffset()" accesskey="e"' ) ), 'operations' => array ( 'edit' => array ( 'href' => 'act=edit', 'icon' => 'edit.svg' ), 'copy' => array ( 'href' => 'act=paste&mode=copy', 'icon' => 'copy.svg', 'attributes' => 'onclick="Backend.getScrollOffset()"' ), 'cut' => array ( 'href' => 'act=paste&mode=cut', 'icon' => 'cut.svg', 'attributes' => 'onclick="Backend.getScrollOffset()"' ), 'delete' => array ( 'href' => 'act=delete', 'icon' => 'delete.svg', 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"' ), 'show' => array ( 'href' => 'act=show', 'icon' => 'show.svg' ) ) ), 'palettes' => array( 'default' => '{title_legend},name' ), 'fields' => array ( 'id' => array ( 'sql' => "int(10) unsigned NOT NULL auto_increment" ), 'pid' => array ( 'foreignKey' => 'tl_theme.name', 'sql' => "int(10) unsigned NOT NULL default 0", 'relation' => array('type'=>'belongsTo', 'load'=>'lazy') ), 'tstamp' => array ( 'sql' => "int(10) unsigned NOT NULL default 0" ), 'name' => array ( 'exclude' => true, 'sorting' => true, 'flag' => 1, 'search' => true, 'inputType' => 'text', 'eval' => array('mandatory'=>true, 'maxlength'=>255, 'tl_class'=>'w50'), 'sql' => "varchar(255) NOT NULL default ''" ) ) );
db.png
Versuche ich nun im Backend in die Layout-Einstellungen zu gehen, erhalte ich folgende Fehlermeldung.
Diese kommt aller Wahrscheinlichkeit durch die Anpassung in der "tl_theme" (letzte Zeile). Vielleicht ist es nur eine kleine Anpassung, die für Contao 4.4 notwendig ist.An exception occurred while executing 'SELECT c.id FROM tl_cssutils c LEFT JOIN tl_theme p ON c.pid=p.id WHERE p.id IS NULL': SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test1.tl_cssutils' doesn't exist
Dank und Gruß
Dennis

Zitieren


