oveleon / contao-component-style-manager

This extension is for the Contao CMS and allows you to easily manage and provide custom categories and groups for CSS classes.
MIT License
23 stars 6 forks source link

v3.6.0: Error when saving a new css class #106

Closed jaynoe closed 3 months ago

jaynoe commented 3 months ago

Prerequisites

Please select the topic(s) that most closely match your concern

Backend (PHP/CSS)

Description

When trying to add a new css class to an element, an error in the dca listener "StyleManagerListener.php" occurs. I´m using Contao 5.3 LTS

Error message

Contao\CoreBundle\Slug\Slug::generate(): Argument #2 ($options) must be of type Traversable|array|int, string given, called in /html/contao5/vendor/oveleon/contao-component-style-manager/src/EventListener/DataContainer/StyleManagerListener.php on line 88

Relevant log output

TypeError:
Contao\CoreBundle\Slug\Slug::generate(): Argument #2 ($options) must be of type Traversable|array|int, string given, called in /html/contao5/vendor/oveleon/contao-component-style-manager/src/EventListener/DataContainer/StyleManagerListener.php on line 88

  at vendor/contao/core-bundle/src/Slug/Slug.php:36
  at Contao\CoreBundle\Slug\Slug->generate('Texte', '12', object(Closure))
     (vendor/oveleon/contao-component-style-manager/src/EventListener/DataContainer/StyleManagerListener.php:88)
  at Oveleon\ContaoComponentStyleManager\EventListener\DataContainer\StyleManagerListener->generateAlias('', object(DC_Table))
     (vendor/contao/core-bundle/contao/drivers/DC_Table.php:3319)
  at Contao\DC_Table->save('')
     (vendor/contao/core-bundle/contao/classes/DataContainer.php:522)
  at Contao\DataContainer->row()
     (vendor/contao/core-bundle/contao/drivers/DC_Table.php:2145)
  at Contao\DC_Table->edit()
     (vendor/contao/core-bundle/contao/classes/Backend.php:546)
  at Contao\Backend->getBackendModule('style_manager', null)
     (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(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:76)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:197)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:42)
jaynoe commented 3 months ago

If i change the row 88 in the listener to

$varValue = System::getContainer()->get('contao.slug')->generate((string) $dc->activeRecord->title, (int) $dc->id, $aliasExists);

the error is fixed

fritzmg commented 3 months ago

@jaynoe using $dc->id is wrong - see #107.