Skip to content

Commit

Permalink
Rename and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bytehead committed Jan 11, 2022
1 parent 6c85b7b commit 68256d2
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 47 deletions.
2 changes: 1 addition & 1 deletion core-bundle/src/Resources/config/controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ services:
tags:
- { name: contao.frontend_module, category: user }

Contao\CoreBundle\Controller\FrontendModule\RootPageDependentModuleController:
Contao\CoreBundle\Controller\FrontendModule\RootPageDependentModulesController:
tags:
- { name: contao.frontend_module, category: miscellaneous }

Expand Down
10 changes: 10 additions & 0 deletions core-bundle/src/Resources/config/listener.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ services:
arguments:
- '@database_connection'

contao.listener.data_container.root_page_dependent_select:
class: Contao\CoreBundle\EventListener\DataContainer\RootPageDependentSelectListener
arguments:
- '@database_connection'
- '@translator'
- '@contao.routing.scope_matcher'
- '@request_stack'
- '@contao.csrf.token_manager'
- '%contao.csrf_token_name%'

contao.listener.data_container.theme_templates:
class: Contao\CoreBundle\EventListener\DataContainer\ThemeTemplatesListener
arguments:
Expand Down
58 changes: 30 additions & 28 deletions core-bundle/src/Resources/contao/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
use Contao\PurgeData;
use Contao\RadioButton;
use Contao\RadioTable;
use Contao\RootPageDependentSelect;
use Contao\SectionWizard;
use Contao\SelectMenu;
use Contao\SerpPreview;
Expand Down Expand Up @@ -332,34 +333,35 @@
// Back end form fields
$GLOBALS['BE_FFL'] = array
(
'text' => TextField::class,
'password' => Password::class,
'textStore' => TextStore::class,
'textarea' => TextArea::class,
'select' => SelectMenu::class,
'checkbox' => CheckBox::class,
'checkboxWizard' => CheckBoxWizard::class,
'radio' => RadioButton::class,
'radioTable' => RadioTable::class,
'inputUnit' => InputUnit::class,
'trbl' => TrblField::class,
'chmod' => ChmodTable::class,
'picker' => Picker::class,
'pageTree' => PageTree::class,
'pageSelector' => PageSelector::class,
'fileTree' => FileTree::class,
'fileSelector' => FileSelector::class,
'fileUpload' => Upload::class,
'tableWizard' => TableWizard::class,
'listWizard' => ListWizard::class,
'optionWizard' => OptionWizard::class,
'moduleWizard' => ModuleWizard::class,
'keyValueWizard' => KeyValueWizard::class,
'imageSize' => ImageSize::class,
'timePeriod' => TimePeriod::class,
'metaWizard' => MetaWizard::class,
'sectionWizard' => SectionWizard::class,
'serpPreview' => SerpPreview::class
'text' => TextField::class,
'password' => Password::class,
'textStore' => TextStore::class,
'textarea' => TextArea::class,
'select' => SelectMenu::class,
'checkbox' => CheckBox::class,
'checkboxWizard' => CheckBoxWizard::class,
'radio' => RadioButton::class,
'radioTable' => RadioTable::class,
'inputUnit' => InputUnit::class,
'trbl' => TrblField::class,
'chmod' => ChmodTable::class,
'picker' => Picker::class,
'pageTree' => PageTree::class,
'pageSelector' => PageSelector::class,
'fileTree' => FileTree::class,
'fileSelector' => FileSelector::class,
'fileUpload' => Upload::class,
'tableWizard' => TableWizard::class,
'listWizard' => ListWizard::class,
'optionWizard' => OptionWizard::class,
'moduleWizard' => ModuleWizard::class,
'keyValueWizard' => KeyValueWizard::class,
'imageSize' => ImageSize::class,
'timePeriod' => TimePeriod::class,
'metaWizard' => MetaWizard::class,
'sectionWizard' => SectionWizard::class,
'serpPreview' => SerpPreview::class,
'rootPageDependentSelect' => RootPageDependentSelect::class
);

// Front end form fields
Expand Down
6 changes: 3 additions & 3 deletions core-bundle/src/Resources/contao/languages/en/modules.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@
<trans-unit id="FMD.two_factor.1">
<source>Generates a form to set up or change two-factor authentication</source>
</trans-unit>
<trans-unit id="FMD.root_page_dependent_module.0">
<source>Root page dependent module</source>
<trans-unit id="FMD.root_page_dependent_modules.0">
<source>Root page dependent modules</source>
</trans-unit>
<trans-unit id="FMD.root_page_dependent_module.1">
<source>Generates a root page dependent module</source>
<source>Generates a root page dependent modules</source>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* @property array $rootPages
*/
class RootPageDependentModule extends SelectMenu
class RootPageDependentSelect extends SelectMenu
{
public function generate(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use Contao\Controller;
use Contao\CoreBundle\Cache\EntityCacheTags;
use Contao\CoreBundle\Controller\FrontendModule\RootPageDependentModuleController;
use Contao\CoreBundle\Controller\FrontendModule\RootPageDependentModulesController;
use Contao\CoreBundle\Tests\TestCase;
use Contao\ModuleModel;
use Contao\PageModel;
Expand All @@ -24,7 +24,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

class RootPageDependentModuleControllerTest extends TestCase
class RootPageDependentModulesControllerTest extends TestCase
{
private ContainerBuilder $container;

Expand All @@ -40,7 +40,7 @@ protected function setUp(): void

public function testReturnsEmptyResponse(): void
{
$controller = new RootPageDependentModuleController();
$controller = new RootPageDependentModulesController();
$controller->setContainer($this->mockContainerWithFrameworkTemplate());

$response = $controller(new Request([], [], ['_scope' => 'frontend']), $this->getModuleModel(), 'main');
Expand All @@ -61,7 +61,7 @@ public function testPopulatesTheTemplateWithTheModule(): void
$requestStack = new RequestStack();
$requestStack->push($request);

$controller = new RootPageDependentModuleController();
$controller = new RootPageDependentModulesController();
$controller->setContainer($this->mockContainerWithFrameworkTemplate($requestStack, 'example-content'));

$response = $controller($request, $module, 'main');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Contao\CoreBundle\Tests\EventListener\DataContainer;

use Contao\CoreBundle\EventListener\DataContainer\RootPageDependentModuleListener;
use Contao\CoreBundle\EventListener\DataContainer\RootPageDependentSelectListener;
use Contao\CoreBundle\Routing\ScopeMatcher;
use Contao\TestCase\ContaoTestCase;
use Doctrine\DBAL\Connection;
Expand All @@ -24,7 +24,7 @@
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

class RootPageDependentModuleListenerTest extends ContaoTestCase
class RootPageDependentSelectListenerTest extends ContaoTestCase
{
public function testReturnsIfTheRequestIsNotABackendRequest(): void
{
Expand All @@ -33,7 +33,7 @@ public function testReturnsIfTheRequestIsNotABackendRequest(): void
$requestStack = new RequestStack();
$requestStack->push($request);

$listener = new RootPageDependentModuleListener(
$listener = new RootPageDependentSelectListener(
$this->createMock(Connection::class),
$this->createMock(TranslatorInterface::class),
$this->mockScopeMatcher(false, $request),
Expand All @@ -52,7 +52,7 @@ public function testReturnsIfThereAreNoFields(): void
$requestStack = new RequestStack();
$requestStack->push($request);

$listener = new RootPageDependentModuleListener(
$listener = new RootPageDependentSelectListener(
$this->createMock(Connection::class),
$this->createMock(TranslatorInterface::class),
$this->mockScopeMatcher(true, $request),
Expand All @@ -75,7 +75,7 @@ public function testOnlyModifyFieldsWithProperInputType(): void
$requestStack = new RequestStack();
$requestStack->push($request);

$listener = new RootPageDependentModuleListener(
$listener = new RootPageDependentSelectListener(
$this->createMock(Connection::class),
$this->createMock(TranslatorInterface::class),
$this->mockScopeMatcher(true, $request),
Expand All @@ -86,7 +86,7 @@ public function testOnlyModifyFieldsWithProperInputType(): void

$this->populateGlobalsArray([
'field1' => [
'inputType' => 'rootPageDependentModule',
'inputType' => 'rootPageDependentSelect',
],
'field2' => [
'eval' => [],
Expand All @@ -100,7 +100,7 @@ public function testOnlyModifyFieldsWithProperInputType(): void

$this->assertSame([
'field1' => [
'inputType' => 'rootPageDependentModule',
'inputType' => 'rootPageDependentSelect',
'eval' => [
'rootPages' => [],
'blankOptionLabel' => null,
Expand Down Expand Up @@ -149,7 +149,7 @@ public function testAddRootPagesToFieldConfig(): void
->willReturn($statement)
;

$listener = new RootPageDependentModuleListener(
$listener = new RootPageDependentSelectListener(
$connection,
$this->createMock(TranslatorInterface::class),
$this->mockScopeMatcher(true, $request),
Expand All @@ -160,15 +160,15 @@ public function testAddRootPagesToFieldConfig(): void

$this->populateGlobalsArray([
'field1' => [
'inputType' => 'rootPageDependentModule',
'inputType' => 'rootPageDependentSelect',
],
]);

$listener->onLoadDataContainer('tl_module');

$this->assertSame([
'field1' => [
'inputType' => 'rootPageDependentModule',
'inputType' => 'rootPageDependentSelect',
'eval' => [
'rootPages' => [
1 => 'title-1 (language-1)',
Expand Down

0 comments on commit 68256d2

Please sign in to comment.