diff --git a/.php_cs.dist b/.php-cs-fixer.dist.php similarity index 92% rename from .php_cs.dist rename to .php-cs-fixer.dist.php index 5eb98da..f69a1be 100644 --- a/.php_cs.dist +++ b/.php-cs-fixer.dist.php @@ -12,7 +12,7 @@ ]) ; -return PhpCsFixer\Config::create() +return (new PhpCsFixer\Config()) ->setRules([ '@Symfony' => true, '@Symfony:risky' => true, @@ -29,9 +29,11 @@ 'escape_implicit_backslashes' => true, 'fully_qualified_strict_types' => true, 'general_phpdoc_annotation_remove' => [ - 'author', - 'expectedException', - 'expectedExceptionMessage', + 'annotations' => [ + 'author', + 'expectedException', + 'expectedExceptionMessage', + ], ], 'header_comment' => ['header' => $header], 'heredoc_to_nowdoc' => true, diff --git a/composer.json b/composer.json index c3818c2..890d9b7 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ ], "require":{ "php": ">=7.1", - "contao/core-bundle": "^4.4" + "contao/core-bundle": "^4.9" }, "require-dev": { "contao/manager-plugin": "^2.0" diff --git a/src/Resources/contao/dca/tl_news.php b/src/Resources/contao/dca/tl_news.php index 34ec459..dc54bac 100644 --- a/src/Resources/contao/dca/tl_news.php +++ b/src/Resources/contao/dca/tl_news.php @@ -8,15 +8,25 @@ * (c) fritzmg */ -$GLOBALS['TL_DCA']['tl_news']['palettes']['default'] .= ';{related_news_legend:hide},relatedNews'; +use Contao\CoreBundle\DataContainer\PaletteManipulator; $GLOBALS['TL_DCA']['tl_news']['fields']['relatedNews'] = [ - 'label' => &$GLOBALS['TL_LANG']['tl_news']['relatedNews'], 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => ['contao_newsrelated.listener.news', 'relatedNewsOptionsCallback'], - 'foreignKey' => 'tl_news.headline', - 'eval' => ['multiple' => true, 'chosen' => true, 'tl_style' => 'height:auto', 'tl_class' => 'clr'], - 'relation' => ['type' => 'belongsToMany', 'load' => 'lazy'], - 'sql' => 'blob NULL', + 'inputType' => 'picker', + 'eval' => ['multiple' => true, 'fieldType' => 'checkbox', 'tl_class' => 'clr'], + 'relation' => ['type' => 'belongsToMany', 'load' => 'lazy', 'table' => 'tl_news'], + 'sql' => ['type' => 'blob', 'length' => 65535, 'notnull' => false], ]; + +$pm = PaletteManipulator::create() + ->addLegend('related_news_legend', null, PaletteManipulator::POSITION_AFTER, true) + ->addField('relatedNews', 'related_news_legend', PaletteManipulator::POSITION_APPEND) +; + +foreach ($GLOBALS['TL_DCA']['tl_news']['palettes'] as $name => $palette) { + if (!\is_string($palette)) { + continue; + } + + $pm->applyToPalette($name, 'tl_news'); +}