Skip to content

Commit

Permalink
CS
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Jan 17, 2022
1 parent ae1520c commit a562e5d
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 35 deletions.
4 changes: 3 additions & 1 deletion core-bundle/src/Controller/AbstractFragmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ protected function render(string $view, array $parameters = [], Response $respon
return parent::render($view, $parameters, $response);
}

/**
* Marks the response to affect the caching of the current page but removes any default cache header.
*/
protected function markResponseForInternalCaching(Response $response): void
{
// Mark this response to affect the caching of the current page but remove any default cache headers
$response->headers->set(SubrequestCacheSubscriber::MERGE_CACHE_HEADER, '1');
$response->headers->remove('Cache-Control');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Contao\Controller;
use Contao\CoreBundle\Controller\AbstractFragmentController;
use Contao\ModuleModel;
use Contao\PageModel;
use Contao\StringUtil;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -24,11 +23,8 @@ class RootPageDependentModulesController extends AbstractFragmentController
{
public function __invoke(Request $request, ModuleModel $model, string $section, array $classes = null): Response
{
/** @var PageModel $pageModel */
$pageModel = $this->getPageModel();

$controller = $this->container->get('contao.framework')->getAdapter(Controller::class);

$modules = StringUtil::deserialize($model->rootPageDependentModules);
$content = '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public function optionsCallback(DataContainer $dc): array
$rows = $this->connection->executeQuery(
"SELECT m.id, m.name, m.type
FROM tl_module m
WHERE m.type <> 'root_page_dependent_modules' AND
m.pid = ?
WHERE m.type != 'root_page_dependent_modules' AND m.pid = ?
ORDER BY m.name",
[$dc->activeRecord->pid]
);
Expand Down Expand Up @@ -105,8 +104,8 @@ public function wizardCallback(DataContainer $dc): string
$title = $this->translator->trans('tl_content.editalias', [$id], 'contao_content');

$wizards[$rootPage] = ' <a href="contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id='.$id.'&amp;popup=1&amp;nb=1&amp;rt='.$this->csrfTokenManager->getDefaultTokenValue().'"
title="'.StringUtil::specialchars($title).'"
onclick="Backend.openModalIframe({\'title\':\''.StringUtil::specialchars(str_replace("'", "\\'", $title)).'\',\'url\':this.href});return false">'.Image::getHtml('alias.svg', $title).'</a>';
title="'.StringUtil::specialchars($title).'"
onclick="Backend.openModalIframe({\'title\':\''.StringUtil::specialchars(str_replace("'", "\\'", $title)).'\',\'url\':this.href});return false">'.Image::getHtml('alias.svg', $title).'</a>';
}

return serialize($wizards);
Expand All @@ -122,7 +121,6 @@ private function getRootPages(): array
');

$rows = $statement->executeQuery();

$pages = [];

foreach ($rows->iterateAssociative() as $rootPage) {
Expand Down
8 changes: 4 additions & 4 deletions core-bundle/src/Resources/config/controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ services:
tags:
- controller.service_arguments

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

Contao\CoreBundle\Controller\FrontendModule\TemplateController:
tags:
- { name: contao.frontend_module, category: miscellaneous }
Expand All @@ -70,10 +74,6 @@ services:
tags:
- { name: contao.frontend_module, category: user }

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

Contao\CoreBundle\Controller\ImagesController:
public: true
arguments:
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/src/Resources/contao/dca/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@
(
'exclude' => true,
'inputType' => 'rootPageDependentSelect',
'eval' => array('submitOnChange'=>true, 'tl_class'=>'w50', 'includeBlankOption'=>true),
'eval' => array('submitOnChange'=>true, 'includeBlankOption'=>true, 'tl_class'=>'w50'),
'sql' => 'blob NULL'
),
)
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/src/Resources/contao/languages/en/modules.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
<source>Root page dependent modules</source>
</trans-unit>
<trans-unit id="FMD.root_page_dependent_module.1">
<source>Generates a root page dependent modules</source>
<source>Generates different modules depending on the root page</source>
</trans-unit>
</body>
</file>
Expand Down
18 changes: 9 additions & 9 deletions core-bundle/src/Resources/contao/languages/en/tl_module.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,15 @@
<trans-unit id="tl_module.data.1">
<source>These values are available as &lt;code&gt;$this->data&lt;/code&gt; in the template.</source>
</trans-unit>
<trans-unit id="tl_module.rootPageDependentModules.0">
<source>Modules</source>
</trans-unit>
<trans-unit id="tl_module.rootPageDependentModules.1">
<source>Please select a module for every root page.</source>
</trans-unit>
<trans-unit id="tl_module.rootPageDependentModulesBlankOptionLabel">
<source>Module for "%s"</source>
</trans-unit>
<trans-unit id="tl_module.title_legend">
<source>Title and type</source>
</trans-unit>
Expand Down Expand Up @@ -486,15 +495,6 @@ If you did not request this e-mail, please contact the website administrator.
<trans-unit id="tl_module.delete">
<source>Delete module ID %s</source>
</trans-unit>
<trans-unit id="tl_module.rootPageDependentModulesBlankOptionLabel">
<source>Please choose your module for %s</source>
</trans-unit>
<trans-unit id="tl_module.rootPageDependentModules.0">
<source>Module</source>
</trans-unit>
<trans-unit id="tl_module.rootPageDependentModules.1">
<source>Please assign the modules to the corresponding root page.</source>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ public function generate(): string
$rootPages = $framework->getAdapter(PageModel::class)->findByType('root', array('order' => 'sorting'));
$wizard = StringUtil::deserialize($this->wizard);

$this->blankOptionLabel = $translator->trans(
sprintf('tl_module.%sBlankOptionLabel', $this->name),
array(),
'contao_module'
);
$this->blankOptionLabel = $translator->trans(sprintf('tl_module.%sBlankOptionLabel', $this->name), array(), 'contao_module');

foreach ($rootPages as $rootPage)
{
Expand Down Expand Up @@ -65,10 +61,7 @@ protected function isSelected($arrOption): string
return ' selected';
}

return static::optionSelected(
$arrOption['value'] ?? null,
$this->varValue[$arrOption['index']] ?? null
);
return static::optionSelected($arrOption['value'] ?? null, $this->varValue[$arrOption['index']] ?? null);
}

private function getOptions(string $index): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public function testDoesNotSaveUnserializableData(): void
public function testSavesValuesRelatedToRootPage(): void
{
$dataContainer = $this->mockClassWithProperties(DataContainer::class);

$connection = $this->mockGetRootPages();

$listener = new RootPageDependentSelectListener(
Expand Down

0 comments on commit a562e5d

Please sign in to comment.