Skip to content

Commit

Permalink
Rename CommentsConditionalFields to AddCommentFields
Browse files Browse the repository at this point in the history
  • Loading branch information
zoglo committed Jan 3, 2024
1 parent 93b0127 commit f72fbad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions comments-bundle/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
- '@contao.framework'
- '@?monolog.logger.contao.cron'

contao_comments.listener.data_container.comments_conditional_fields:
class: Contao\CommentsBundle\EventListener\DataContainer\CommentsConditionalFieldsListener
contao_comments.listener.data_container.add_comment_fields:
class: Contao\CommentsBundle\EventListener\DataContainer\AddCommentFieldsListener
arguments:
- '%kernel.bundles%'
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;

#[AsHook('loadDataContainer')]
class CommentsConditionalFieldsListener
class AddCommentFieldsListener
{
public function __construct(private readonly array $bundles)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
namespace Contao\CommentsBundle\Tests\EventListener\DataContainer;

use Contao\CalendarBundle\ContaoCalendarBundle;
use Contao\CommentsBundle\EventListener\DataContainer\CommentsConditionalFieldsListener;
use Contao\CommentsBundle\EventListener\DataContainer\AddCommentFieldsListener;
use Contao\CoreBundle\HttpKernel\Bundle\ContaoModuleBundle;
use Contao\FaqBundle\ContaoFaqBundle;
use Contao\NewsBundle\ContaoNewsBundle;
use Contao\TestCase\ContaoTestCase;

class CommentsConditionalFieldsListenerTest extends ContaoTestCase
class AddCommentFieldsListenerTest extends ContaoTestCase
{
protected function tearDown(): void
{
Expand All @@ -36,7 +36,7 @@ public function testTableIsNotSet(): void
];

// Test will fail if tl_module is set due to palettes not existing
$listener = new CommentsConditionalFieldsListener(['ContaoNewsBundle' => ContaoNewsBundle::class]);
$listener = new AddCommentFieldsListener(['ContaoNewsBundle' => ContaoNewsBundle::class]);
$listener('tl_module');

$this->assertArrayNotHasKey('tl_module', $GLOBALS['TL_DCA']);
Expand All @@ -55,7 +55,7 @@ public function testAppliesModuleFields(): void
'eventreader' => $palettes,
];

$listener = new CommentsConditionalFieldsListener([
$listener = new AddCommentFieldsListener([
'ContaoNewsBundle' => ContaoNewsBundle::class,
'ContaoCalendarBundle' => ContaoCalendarBundle::class,
'ContaoFaqBundle' => ContaoFaqBundle::class,
Expand All @@ -75,7 +75,7 @@ public function testIgnoresModuleFields(): void
/** @phpstan-var array $GLOBALS (signals PHPStan that the array shape may change) */
$GLOBALS['TL_DCA']['tl_module']['palettes']['fooreader'] = $palettes;

$listener = new CommentsConditionalFieldsListener(['FooBundle' => ContaoModuleBundle::class]);
$listener = new AddCommentFieldsListener(['FooBundle' => ContaoModuleBundle::class]);
$listener('tl_module');

$this->assertSame($palettes, $GLOBALS['TL_DCA']['tl_module']['palettes']['fooreader']);
Expand Down Expand Up @@ -127,7 +127,7 @@ private function testAppliesParentFields(array $bundles, string $table): void
'fields' => [],
];

$listener = new CommentsConditionalFieldsListener($bundles);
$listener = new AddCommentFieldsListener($bundles);
$listener($table);

$this->assertSame($expected, $GLOBALS['TL_DCA'][$table]['palettes']['default']);
Expand Down Expand Up @@ -159,7 +159,7 @@ private function testAppliesChildrenFields(array $bundles, string $table, bool $
$GLOBALS['TL_DCA'][$table]['palettes']['external'] = $palettes;
}

$listener = new CommentsConditionalFieldsListener($bundles);
$listener = new AddCommentFieldsListener($bundles);
$listener($table);

$this->assertContains('allowComments', $GLOBALS['TL_DCA'][$table]['list']['sorting']['headerFields']);
Expand Down

0 comments on commit f72fbad

Please sign in to comment.