Skip to content

Commit

Permalink
ecs
Browse files Browse the repository at this point in the history
  • Loading branch information
denniserdmann committed Jul 31, 2024
1 parent d0a7b2e commit cf15d3c
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 160 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"config": {
"allow-plugins": {
"contao-components/installer": true,
"contao/manager-plugin": true
"contao/manager-plugin": true,
"php-http/discovery": true
}
},
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion src/Classes/Portfolio.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace EuF\PortfolioBundle\Classes;

use Contao\ArticleModel;
use Contao\Config;
use Contao\Environment;
use Contao\Frontend;
use Contao\PageModel;
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/InsertTagsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __invoke(string $insertTag, bool $useCache, string $cachedValue,
$elements = explode('::', $insertTag);
$key = strtolower($elements[0]);

if (in_array($key, self::SUPPORTED_TAGS, true)) {
if (\in_array($key, self::SUPPORTED_TAGS, true)) {
return $this->replaceInsertTags($key, $elements[1], $flags);
}

Expand All @@ -58,7 +58,7 @@ private function replaceInsertTags(string $insertTag, string $idOrAlias, array $
/** @var Portfolio $adapter */
$adapter = $this->framework->getAdapter(Portfolio::class);

return $adapter->generatePortfolioUrl($portfolio, false, in_array('absolute', $flags, true));
return $adapter->generatePortfolioUrl($portfolio, false, \in_array('absolute', $flags, true));
}

return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Contao\PageModel;
use EuF\PortfolioBundle\Models\PortfolioArchiveModel;
use EuF\PortfolioBundle\Models\PortfolioModel;
use Terminal42\ChangeLanguage\Event\ChangelanguageNavigationEvent;
use Terminal42\ChangeLanguage\EventListener\Navigation\AbstractNavigationListener;

/**
Expand Down
25 changes: 18 additions & 7 deletions src/Migration/Version500/BooleanFieldsMigration.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
<?php

declare(strict_types=1);

/*
* Contao Portfolio Bundle for Contao Open Source CMS.
* @copyright Copyright (c) Erdmann & Freunde
* @author Erdmann & Freunde <https://erdmann-freunde.de>
* @license MIT
* @link http://github.com/erdmannfreunde/contao-portfolio-bundle
*/

namespace EuF\PortfolioBundle\Migration\Version500;

use Doctrine\DBAL\Connection;
use Contao\CoreBundle\Migration\MigrationResult;
use Contao\CoreBundle\Migration\AbstractMigration;
use Contao\CoreBundle\Migration\MigrationResult;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\StringType;

class BooleanFieldsMigration extends AbstractMigration
Expand Down Expand Up @@ -36,7 +46,7 @@ public function shouldRun(): bool
foreach ($columns as $currentColumn) {
$currentColumnName = $currentColumn->getName();

if (true === in_array($currentColumnName, $this->columns, true)) {
if (true === \in_array($currentColumnName, $this->columns, true)) {
if ($currentColumn->getType() instanceof StringType) {
return true;
}
Expand All @@ -57,12 +67,13 @@ public function run(): MigrationResult
foreach ($columns as $currentColumn) {
$currentColumnName = $currentColumn->getName();

if (true === in_array($currentColumnName, $this->columns, true)) {
if (true === \in_array($currentColumnName, $this->columns, true)) {
if ($currentColumn->getType() instanceof StringType) {
$this->connection
->executeQuery(
'ALTER TABLE ' . $table . ' CHANGE ' . $currentColumnName . ' ' . $currentColumnName . ' TINYINT(1) NOT NULL DEFAULT 0'
);
'ALTER TABLE '.$table.' CHANGE '.$currentColumnName.' '.$currentColumnName.' TINYINT(1) NOT NULL DEFAULT 0'
)
;
}
}
}
Expand All @@ -73,4 +84,4 @@ public function run(): MigrationResult
'All char fields have been changed to tinyint.'
);
}
}
}
7 changes: 3 additions & 4 deletions src/Models/PortfolioModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@

namespace EuF\PortfolioBundle\Models;

use Contao\CoreBundle\File\ModelMetadataTrait;
use Contao\Date;
use Contao\Model;
use Contao\System;
use Contao\StringUtil;
use Contao\Model\Collection;
use Contao\CoreBundle\File\ModelMetadataTrait;
use Contao\StringUtil;

class PortfolioModel extends Model
{
Expand Down Expand Up @@ -111,7 +110,7 @@ public static function findPublishedByPids(array $arrPids, bool $blnFeatured = n
*/
public static function countPublishedByPids(array $arrPids, bool $blnFeatured = null, array $arrCategories = [], array $arrOptions = []): int
{
if (empty($arrPids) || !is_array($arrPids)) {
if (empty($arrPids) || !\is_array($arrPids)) {
return 0;
}

Expand Down
19 changes: 10 additions & 9 deletions src/Modules/ModulePortfolio.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

namespace EuF\PortfolioBundle\Modules;

use Contao\ContentModel;
use Contao\Date;
use Contao\System;
use Contao\Module;
use Contao\StringUtil;
use Contao\FilesModel;
use Contao\FrontendUser;
use Contao\ContentModel;
use Contao\FrontendTemplate;
use Contao\FrontendUser;
use Contao\Module;
use Contao\StringUtil;
use Contao\System;
use EuF\PortfolioBundle\Classes\Portfolio;
use EuF\PortfolioBundle\Models\PortfolioArchiveModel;
use EuF\PortfolioBundle\Models\PortfolioCategoryModel;
Expand All @@ -31,7 +31,7 @@ abstract class ModulePortfolio extends Module
*/
protected function sortOutProtected(array $arrArchives): array
{
if (empty($arrArchives) || !is_array($arrArchives)) {
if (empty($arrArchives) || !\is_array($arrArchives)) {
return $arrArchives;
}

Expand All @@ -42,13 +42,13 @@ protected function sortOutProtected(array $arrArchives): array
if (null !== $objArchive) {
while ($objArchive->next()) {
if ($objArchive->protected) {
if (!FE_USER_LOGGED_IN || !is_array($this->User->groups)) {
if (!FE_USER_LOGGED_IN || !\is_array($this->User->groups)) {
continue;
}

$groups = StringUtil::deserialize($objArchive->groups);

if (empty($groups) || !is_array($groups) || !count(array_intersect($groups, $this->User->groups))) {
if (empty($groups) || !\is_array($groups) || !\count(array_intersect($groups, $this->User->groups))) {
continue;
}
}
Expand Down Expand Up @@ -166,7 +166,8 @@ protected function parseItem($objItem, $blnAddArchive = false, $strClass = '', $
->setSize($imgSize)
->setOverwriteMetadata($objItem->getOverwriteMetadata())
->enableLightbox((bool) $objItem->fullsize)
->buildIfResourceExists();
->buildIfResourceExists()
;

$figure?->applyLegacyTemplateData($objTemplate);

Expand Down
1 change: 0 additions & 1 deletion src/Modules/ModulePortfolioReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace EuF\PortfolioBundle\Modules;

use Contao\BackendTemplate;
use Contao\Config;
use Contao\CoreBundle\Exception\InternalServerErrorException;
use Contao\CoreBundle\Exception\PageNotFoundException;
use Contao\CoreBundle\Routing\ResponseContext\HtmlHeadBag\HtmlHeadBag;
Expand Down
8 changes: 2 additions & 6 deletions src/Picker/PortfolioPickerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ class PortfolioPickerProvider extends AbstractInsertTagPickerProvider implements
{
private Security $security;

public function __construct(
FactoryInterface $menuFactory,
RouterInterface $router,
?TranslatorInterface $translator,
Security $security)
public function __construct(FactoryInterface $menuFactory, RouterInterface $router, ?TranslatorInterface $translator, Security $security)
{
parent::__construct($menuFactory, $router, $translator);

Expand All @@ -42,7 +38,7 @@ public function getName(): string

public function supportsContext($context): bool
{
return in_array($context, ['portfolio', 'link'], true) && $this->security->isGranted('contao_user.modules', 'portfolio');
return \in_array($context, ['portfolio', 'link'], true) && $this->security->isGranted('contao_user.modules', 'portfolio');
}

public function supportsValue(PickerConfig $config): bool
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/contao/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
*/

use EuF\PortfolioBundle\Classes\Portfolio;
use EuF\PortfolioBundle\Models\PortfolioModel;
use EuF\PortfolioBundle\Modules\ModulePortfolioList;
use EuF\PortfolioBundle\Models\PortfolioArchiveModel;
use EuF\PortfolioBundle\Models\PortfolioCategoryModel;
use EuF\PortfolioBundle\Models\PortfolioModel;
use EuF\PortfolioBundle\Modules\ModulePortfolioList;
use EuF\PortfolioBundle\Modules\ModulePortfolioReader;

$GLOBALS['BE_MOD']['content']['portfolio'] = [
Expand All @@ -30,7 +30,7 @@
];

$GLOBALS['TL_MODELS']['tl_portfolio'] = PortfolioModel::class;
$GLOBALS['TL_MODELS']['tl_portfolio_archive'] = PortfolioArchiveModel::class ;
$GLOBALS['TL_MODELS']['tl_portfolio_archive'] = PortfolioArchiveModel::class;
$GLOBALS['TL_MODELS']['tl_portfolio_category'] = PortfolioCategoryModel::class;

/*
Expand Down
8 changes: 5 additions & 3 deletions src/Resources/contao/dca/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
*/

use Contao\Backend;
use Contao\Database;
use Contao\BackendUser;
use Contao\Database;

$GLOBALS['TL_DCA']['tl_module']['palettes']['portfoliolist'] = '{title_legend},name,headline,type;{config_legend},portfolio_archives,portfolio_readerModule,portfolio_featured,numberOfItems,filter_categories,perPage;{nav_legend},portfolio_filter,portfolio_filter_reset;{redirect_legend},jumpTo;{template_legend:hide},portfolio_template,customTpl;{image_legend:hide},imgSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space';
$GLOBALS['TL_DCA']['tl_module']['palettes']['portfolioreader'] = '{title_legend},name,headline,type;{config_legend},portfolio_archives,overviewPage,customLabel;{template_legend:hide},portfolio_template,customTpl;{protected_legend:hide},{image_legend:hide},imgSize;protected;{expert_legend:hide},guests,cssID,space';
Expand Down Expand Up @@ -121,7 +121,8 @@ public function getPortfolioArchives(): array

$arrArchives = [];
$objArchives = Database::getInstance()
->execute('SELECT id, title FROM tl_portfolio_archive ORDER BY title');
->execute('SELECT id, title FROM tl_portfolio_archive ORDER BY title')
;

while ($objArchives->next()) {
if ($this->User->hasAccess($objArchives->id, 'portfolio')) {
Expand All @@ -139,7 +140,8 @@ public function getReaderModules(): array
{
$arrModules = [];
$objModules = Database::getInstance()
->execute("SELECT m.id, m.name, t.name AS theme FROM tl_module m LEFT JOIN tl_theme t ON m.pid=t.id WHERE m.type='portfolioreader' ORDER BY t.name, m.name");
->execute("SELECT m.id, m.name, t.name AS theme FROM tl_module m LEFT JOIN tl_theme t ON m.pid=t.id WHERE m.type='portfolioreader' ORDER BY t.name, m.name")
;

while ($objModules->next()) {
$arrModules[$objModules->theme][$objModules->id] = $objModules->name.' (ID '.$objModules->id.')';
Expand Down
Loading

0 comments on commit cf15d3c

Please sign in to comment.