Skip to content

Commit

Permalink
Run build-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Nov 9, 2023
1 parent 5359e73 commit 02fe437
Show file tree
Hide file tree
Showing 39 changed files with 137 additions and 125 deletions.
2 changes: 1 addition & 1 deletion contao/templates/nav_dropdown.html5
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (1 == $intLevel):
$arrLanguages = \Contao\System::getLanguages();

foreach ($this->items as $item) {
if ($item['isActive'] || false !== strpos($item['subitems'], 'class="active')) {
if ($item['isActive'] || str_contains($item['subitems'], 'class="active')) {
$blnHasActive = true;
break;
}
Expand Down
2 changes: 0 additions & 2 deletions src/ContaoManager/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Contao\ManagerPlugin\Bundle\Config\BundleConfig;
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface;
use Contao\NewsBundle\ContaoNewsBundle;
use MenAtWork\MultiColumnWizardBundle\MultiColumnWizardBundle;
use Terminal42\ChangeLanguage\Terminal42ChangeLanguageBundle;

class Plugin implements BundlePluginInterface
Expand All @@ -26,7 +25,6 @@ public function getBundles(ParserInterface $parser)
ContaoNewsBundle::class,
ContaoCalendarBundle::class,
ContaoFaqBundle::class,
MultiColumnWizardBundle::class,
]),
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function load(array $config, ContainerBuilder $container): void
{
$loader = new YamlFileLoader(
$container,
new FileLocator(__DIR__.'/../../config')
new FileLocator(__DIR__.'/../../config'),
);

$loader->load('services.yaml');
Expand Down
18 changes: 5 additions & 13 deletions src/Event/ChangelanguageNavigationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

namespace Terminal42\ChangeLanguage\Event;

use Symfony\Contracts\EventDispatcher\Event;
use Terminal42\ChangeLanguage\Navigation\NavigationItem;
use Terminal42\ChangeLanguage\Navigation\UrlParameterBag;

class ChangelanguageNavigationEvent
class ChangelanguageNavigationEvent extends Event
{
private NavigationItem $navigationItem;

private UrlParameterBag $urlParameterBag;

private bool $skipped = false;
private bool $stopPropagation = false;

public function __construct(NavigationItem $navigationItem, UrlParameterBag $urlParameters)
{
Expand Down Expand Up @@ -46,18 +48,8 @@ public function skipInNavigation(): void
$this->stopPropagation();
}

public function isSkipped()
public function isSkipped(): bool
{
return $this->skipped;
}

public function isPropagationStopped()
{
return $this->stopPropagation;
}

public function stopPropagation(): void
{
$this->stopPropagation = true;
}
}
2 changes: 2 additions & 0 deletions src/EventListener/AbstractTableListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public function __construct(string $table)

/**
* Register necessary callbacks for this listener.
*
* @return void
*/
abstract public function register();

Expand Down
9 changes: 5 additions & 4 deletions src/EventListener/BackendView/AbstractViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
abstract class AbstractViewListener extends AbstractTableListener
{
protected DataContainer $dataContainer;

protected PageFinder $pageFinder;

public function __construct($table)
public function __construct(string $table)
{
parent::__construct($table);

Expand Down Expand Up @@ -93,7 +94,7 @@ abstract protected function getAvailableLanguages(PageModel $page);
*
* @param string $id
*/
abstract protected function doSwitchView($id);
abstract protected function doSwitchView($id): void;

/**
* @param string $languageCode
Expand Down Expand Up @@ -152,7 +153,7 @@ private function getSwitchButton(PageModel $page, array $languages): string
'<li><a href="%s" title="%s">%s</a></li>',
Backend::addToUrl('&amp;switchLanguage='.$id),
sprintf($GLOBALS['TL_LANG']['MSC']['switchLanguageTo'][1], $language),
$language
$language,
);
}

Expand All @@ -161,7 +162,7 @@ private function getSwitchButton(PageModel $page, array $languages): string
$GLOBALS['TL_LANG']['MSC']['switchLanguage'],
$this->getLanguageLabel($page->language),
$GLOBALS['TL_LANG']['MSC']['switchLanguageTo'][0],
$list
$list,
);
}
}
6 changes: 3 additions & 3 deletions src/EventListener/BackendView/ArticleViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected function getAvailableLanguages(PageModel $page): array

$articles = array_values(array_filter(
$articles,
fn (ArticleModel $article) => $article->inColumn === $this->currentArticle->inColumn
fn (ArticleModel $article) => $article->inColumn === $this->currentArticle->inColumn,
));

if (1 === \count($articles)) {
Expand All @@ -100,7 +100,7 @@ protected function doSwitchView($id): void
$uri = UriModifier::removeParams($uri, 'switchLanguage', 'act', 'mode');
$uri = UriModifier::mergeQuery($uri, 'id='.$id);

throw new RedirectResponseException($uri->toString());
throw new RedirectResponseException((string) $uri);
}

/**
Expand All @@ -123,7 +123,7 @@ private function findArticlesForPage(PageModel $page, int $articleId): array
$articleId,
$articleId,
],
['order' => 'tl_article.id=? DESC, tl_article.languageMain=? DESC']
['order' => 'tl_article.id=? DESC, tl_article.languageMain=? DESC'],
);

if (!$articles instanceof Collection) {
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/BackendView/PageViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ protected function doSwitchView($id): void
$uri = Uri::createFromString($requestStack->getCurrentRequest()->getUri());
$uri = UriModifier::removePairs($uri, 'switchLanguage');

throw new RedirectResponseException($uri->toString());
throw new RedirectResponseException((string) $uri);
}
}
22 changes: 8 additions & 14 deletions src/EventListener/BackendView/ParentChildViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ class ParentChildViewListener extends AbstractViewListener
*/
private $current = false;

/**
* {@inheritdoc}
*/
protected function isSupported()
{
return $this->getTable() === Input::get('table')
Expand Down Expand Up @@ -91,7 +88,7 @@ protected function doSwitchView($id): void

$uri = UriModifier::mergeQuery($uri, 'id='.$id);

throw new RedirectResponseException($uri->toString());
throw new RedirectResponseException((string) $uri);
}

/**
Expand Down Expand Up @@ -122,18 +119,15 @@ private function findRelatedForPageAndId(PageModel $page, $id)
];
}

return $class::findOneBy(
$columns,
[
$page->id,
$this->current->id,
$id,
$id,
]
);
return $class::findOneBy($columns, [
$page->id,
$this->current->id,
$id,
$id,
]);
}

private function getModelClass()
private function getModelClass(): string
{
Controller::loadDataContainer($this->getTable());

Expand Down
14 changes: 12 additions & 2 deletions src/EventListener/DataContainer/AbstractChildTableListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function onLoad(DataContainer $dc): void
}
}

/**
* @return array
*/
public function onLanguageMainOptions(DataContainer $dc)
{
if (
Expand All @@ -49,7 +52,7 @@ public function onLanguageMainOptions(DataContainer $dc)
$this->table.'.pid=?',
sprintf('%s.id NOT IN (SELECT languageMain FROM %s WHERE pid=? AND id!=?)', $this->table, $this->table),
],
[$master->id, $current->pid, $current->id]
[$master->id, $current->pid, $current->id],
);

return $models instanceof Collection ? $this->formatOptions($current, $models) : [];
Expand All @@ -65,14 +68,19 @@ protected function addFieldsToPalettes(): void

$palettes = array_diff(
array_keys($GLOBALS['TL_DCA'][$this->table]['palettes']),
['__selector__']
['__selector__'],
);

foreach ($palettes as $palette) {
$pm->applyToPalette($palette, $this->table);
}
}

/**
* @param int|string $id
*
* @return Model
*/
protected function getModel($id)
{
/** @var Model $class */
Expand All @@ -92,6 +100,8 @@ abstract protected function getTitleField();
abstract protected function getSorting();

/**
* @param Collection<Model> $models
*
* @return array
*/
abstract protected function formatOptions(Model $current, Collection $models);
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/DataContainer/CalendarEventsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function formatOptions(Model $current, Collection $models): array
$options[$model->id] = sprintf(
'%s [%s]',
$model->title,
Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $model->startTime)
Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $model->startTime),
);
}

Expand Down
4 changes: 4 additions & 0 deletions src/EventListener/DataContainer/FaqListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Terminal42\ChangeLanguage\EventListener\DataContainer;

use Contao\FaqModel;
use Contao\Model;
use Contao\Model\Collection;

Expand All @@ -19,6 +20,9 @@ protected function getSorting(): string
return 'sorting';
}

/**
* @param Collection<FaqModel> $models
*/
protected function formatOptions(Model $current, Collection $models): array
{
$options = [];
Expand Down
18 changes: 4 additions & 14 deletions src/EventListener/DataContainer/MissingLanguageIconListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,13 @@ public function __invoke(string $table): void
if (\array_key_exists($table, self::$callbacks)) {
LabelCallback::createAndRegister(
$table,
fn (array $args, $previousResult) => $this->{self::$callbacks[$table]}($args, $previousResult)
fn (array $args, $previousResult) => $this->{self::$callbacks[$table]}($args, $previousResult),
);
}
}

/**
* Adds missing translation warning to page tree.
*
* @param mixed $previousResult
*/
private function onPageLabel(array $args, $previousResult = null): string
{
Expand Down Expand Up @@ -95,7 +93,7 @@ private function onPageLabel(array $args, $previousResult = null): string
$label,
Backend::addToUrl('pn='.$mainPage->id),
StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['selectNode']),
$mainPage->title
$mainPage->title,
);
}

Expand All @@ -104,8 +102,6 @@ private function onPageLabel(array $args, $previousResult = null): string

/**
* Adds missing translation warning to article tree.
*
* @param mixed $previousResult
*/
private function onArticleLabel(array $args, $previousResult = null): string
{
Expand All @@ -131,8 +127,6 @@ private function onArticleLabel(array $args, $previousResult = null): string

/**
* Generate missing translation warning for news child records.
*
* @param mixed $previousResult
*/
private function onNewsChildRecords(array $args, $previousResult = null): string
{
Expand All @@ -158,8 +152,6 @@ private function onNewsChildRecords(array $args, $previousResult = null): string

/**
* Generate missing translation warning for calendar events child records.
*
* @param mixed $previousResult
*/
private function onCalendarEventChildRecords(array $args, $previousResult = null): string
{
Expand All @@ -181,8 +173,6 @@ private function onCalendarEventChildRecords(array $args, $previousResult = null

/**
* Generate missing translation warning for faq child records.
*
* @param mixed $previousResult
*/
private function onFaqChildRecords(array $args, $previousResult = null): string
{
Expand All @@ -200,7 +190,7 @@ private function onFaqChildRecords(array $args, $previousResult = null): string
'#</div>#',
$this->generateLabelWithWarning('', 'position:absolute;top:6px').'</div>',
$label,
1
1,
);
}

Expand All @@ -220,7 +210,7 @@ private function generateLabelWithWarning($label, $imgStyle = '')
'bundles/terminal42changelanguage/language-warning.png',
$GLOBALS['TL_LANG']['MSC']['noMainLanguage'],
$GLOBALS['TL_LANG']['MSC']['noMainLanguage'],
$imgStyle
$imgStyle,
);
}
}
6 changes: 5 additions & 1 deletion src/EventListener/DataContainer/NewsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Contao\Date;
use Contao\Model;
use Contao\Model\Collection;
use Contao\NewsModel;

class NewsListener extends AbstractChildTableListener
{
Expand All @@ -20,6 +21,9 @@ protected function getSorting(): string
return 'date DESC, time DESC';
}

/**
* @param Collection<NewsModel> $models
*/
protected function formatOptions(Model $current, Collection $models): array
{
$sameDay = $GLOBALS['TL_LANG']['tl_news']['sameDay'];
Expand All @@ -33,7 +37,7 @@ protected function formatOptions(Model $current, Collection $models): array
$options[$group][$model->id] = sprintf(
'%s [%s]',
$model->headline,
Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $model->time)
Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $model->time),
);
}

Expand Down
Loading

0 comments on commit 02fe437

Please sign in to comment.