Skip to content

Commit

Permalink
Fix templates getContainer call
Browse files Browse the repository at this point in the history
  • Loading branch information
zonky2 committed May 21, 2024
1 parent 45d37d6 commit f5fc860
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/Resources/contao/templates/dcbe_general_clipboard.html5
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Contao\System;
use Contao\StringUtil;
use ContaoCommunityAlliance\Contao\Bindings\ContaoEvents;
use ContaoCommunityAlliance\Contao\Bindings\Events\Image\GenerateHtmlEvent;
Expand All @@ -9,7 +10,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
/** @var \ContaoCommunityAlliance\DcGeneral\EnvironmentInterface $environment */
$environment = $this->environment;
$eventDispatcher = $environment->getEventDispatcher();
$translator = \System::getContainer()->get('translator');
$translator = System::getContainer()->get('translator');
assert($translator instanceof TranslatorInterface);

// pre render the clipboard icon
Expand Down
8 changes: 5 additions & 3 deletions src/Resources/contao/templates/dcbe_general_common_list.html5
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php

use Contao\Message;
use Contao\System;
use Contao\StringUtil;
use ContaoCommunityAlliance\DcGeneral\Data\ModelId;
use ContaoCommunityAlliance\DcGeneral\Data\ModelInterface;
use ContaoCommunityAlliance\DcGeneral\DataDefinition\Definition\View\GroupAndSortingInformationInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

$requestToken = \System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue();
$translator = \System::getContainer()->get('translator');
$requestToken = System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue();
$translator = System::getContainer()->get('translator');
assert($translator instanceof TranslatorInterface);
?>
<?php $this->block('messages'); ?>
<?= $this->getMessages() ?>
<?= Message::generate() ?>
<?php if ($this->info): ?>
<div class="tl_message">
<p class="tl_info"><?= \implode('<br />', $this->info) ?></p>
Expand Down
6 changes: 4 additions & 2 deletions src/Resources/contao/templates/dcbe_general_edit.html5
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

use Contao\System;
use Contao\StringUtil;
use ContaoCommunityAlliance\DcGeneral\Data\VersionModelInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

$requestToken = \System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue();
$translator = \System::getContainer()->get('translator');
$requestToken = System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue();
$translator = System::getContainer()->get('translator');
assert($translator instanceof TranslatorInterface);
// Add CSS
$GLOBALS['TL_CSS'][] = 'bundles/ccadcgeneral/css/generalDriver.css';
Expand Down
5 changes: 4 additions & 1 deletion src/Resources/contao/templates/dcbe_general_field.html5
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
$translator = \Contao\System::getContainer()->get('translator');

use Contao\System;

$translator = System::getContainer()->get('translator');
assert($translator instanceof \Symfony\Contracts\Translation\TranslatorInterface);
?>
<div id="widget_<?= $this->strName; ?>" class="widget <?= $this->strClass ?>">
Expand Down
10 changes: 7 additions & 3 deletions src/Resources/contao/templates/dcbe_general_language_panel.html5
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?php
$requestToken = \Contao\System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue();
$translator = \Contao\System::getContainer()->get('translator');
assert($translator instanceof \Symfony\Contracts\Translation\TranslatorInterface);

use Contao\System;
use Symfony\Contracts\Translation\TranslatorInterface;

$requestToken = System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue();
$translator = System::getContainer()->get('translator');
assert($translator instanceof TranslatorInterface);

$apply = $translator->trans(id: 'apply', domain: 'dc-general');
?>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
use Contao\System;
use Contao\StringUtil;
?>
<?php if ($this->language && !empty($this->languages)): ?>
Expand All @@ -7,7 +8,7 @@ use Contao\StringUtil;
<div class="tl_formbody">
<input type="hidden" name="FORM_SUBMIT" value="language_switch" />
<input type="hidden" name="REQUEST_TOKEN" value="<?= $this->REQUEST_TOKEN ?>" />
<label for="selectLanguage"><strong><?= \Contao\System::getContainer()->get('translator')->trans('language', [], 'dc-general') ?>: </strong></label>
<label for="selectLanguage"><strong><?= System::getContainer()->get('translator')->trans('language', [], 'dc-general') ?>: </strong></label>
<select name="language" id="selectLanguage" class="tl_select" onchange="Backend.autoSubmit('language_switch')">
<?php foreach ($this->languages as $langCode => $languageName) : ?>
<option value="<?= $langCode; ?>"<?php if ($langCode === $this->language): ?> selected="selected"<?php endif; ?>>
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/contao/templates/dcbe_general_panel.html5
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
$requestToken = \System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue();
use Contao\System;

$requestToken = System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue();
?>
<form action="<?= $this->action ?>" class="tl_form dc_general_panel" method="post">
<div class="tl_formbody">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
$translator = \Contao\System::getContainer()->get('translator');

use Contao\System;

$translator = System::getContainer()->get('translator');
assert($translator instanceof \Symfony\Contracts\Translation\TranslatorInterface);
?>
<div class="tl_limit tl_subpanel <?= $this->rowClass; ?>">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
$translator = \Contao\System::getContainer()->get('translator');

use Contao\System;

$translator = System::getContainer()->get('translator');
assert($translator instanceof \Symfony\Contracts\Translation\TranslatorInterface);
?>
<div class="tl_search tl_subpanel <?= $this->rowClass ?>">
Expand Down
5 changes: 4 additions & 1 deletion src/Resources/contao/templates/dcbe_general_panel_sort.html5
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
$translator = \Contao\System::getContainer()->get('translator');

use Contao\System;

$translator = System::getContainer()->get('translator');
assert($translator instanceof \Symfony\Contracts\Translation\TranslatorInterface);
?>
<div class="tl_sorting tl_subpanel <?= $this->rowClass; ?>">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
$translator = \Contao\System::getContainer()->get('translator');

use Contao\System;

$translator = System::getContainer()->get('translator');
assert($translator instanceof \Symfony\Contracts\Translation\TranslatorInterface);

$apply = $translator->trans(id: 'apply', domain: 'dc-general');
Expand Down
8 changes: 6 additions & 2 deletions src/Resources/contao/templates/dcbe_general_show.html5
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php

use Contao\System;
use Symfony\Contracts\Translation\TranslatorInterface;

$this->insert(
'dcbe_general_language_selector',
[
Expand All @@ -10,8 +14,8 @@ $this->insert(
]
);

$translator = \Contao\System::getContainer()->get('translator');
assert($translator instanceof \Symfony\Contracts\Translation\TranslatorInterface);
$translator = System::getContainer()->get('translator');
assert($translator instanceof TranslatorInterface);
?>

<div id="tl_buttons">
Expand Down
3 changes: 2 additions & 1 deletion src/Resources/contao/templates/widget_common_picker.html5
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

use Contao\System;
use Contao\StringUtil;

$requestToken = \System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue();
$requestToken = System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue();
?>
<input type="hidden" name="<?= $this->name ?>" id="ctrl_<?= $this->id ?>" value="<?= \implode(',', \array_keys($this->values)) ?>">

Expand Down

0 comments on commit f5fc860

Please sign in to comment.