Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg committed Dec 5, 2024
1 parent e979daa commit cffb35c
Show file tree
Hide file tree
Showing 21 changed files with 73 additions and 114 deletions.
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
"contao/image": "^1.2",
"symfony/config": "^5.4 || ^6.4 || ^7.1",
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.1",
"symfony/filesystem": "^5.4 || ^6.4 || ^7.1",
"symfony/http-foundation": "^5.4 || ^6.4 || ^7.1",
"symfony/http-kernel": "^5.4 || ^6.4 || ^7.1",
"symfony/security-core": "^5.4 || ^6.4 || ^7.1",
"webmozart/path-util": "^2.3",
"symfony/service-contracts": "^2.5 || ^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0"
"contao/easy-coding-standard": "^6.0",
"contao/rector": "^1.0"
},
"autoload": {
"psr-4": {
Expand All @@ -51,7 +52,8 @@
"config": {
"allow-plugins": {
"contao-components/installer": true,
"php-http/discovery": false
"php-http/discovery": false,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
4 changes: 2 additions & 2 deletions contao/dca/tl_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand Down
4 changes: 2 additions & 2 deletions contao/dca/tl_member.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand Down
4 changes: 2 additions & 2 deletions contao/languages/de/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand Down
4 changes: 2 additions & 2 deletions contao/languages/de/tl_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand Down
4 changes: 2 additions & 2 deletions contao/languages/de/tl_member.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand Down
4 changes: 2 additions & 2 deletions contao/languages/en/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand Down
4 changes: 2 additions & 2 deletions contao/languages/en/tl_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand Down
4 changes: 2 additions & 2 deletions contao/languages/en/tl_member.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand Down
4 changes: 2 additions & 2 deletions src/ContaoFileAccessBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand Down
12 changes: 3 additions & 9 deletions src/ContaoManager/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand All @@ -24,11 +24,8 @@
/**
* Plugin for the Contao Manager.
*/
class ContaoManagerPlugin implements BundlePluginInterface, RoutingPluginInterface
class Plugin implements BundlePluginInterface, RoutingPluginInterface
{
/**
* {@inheritdoc}
*/
public function getBundles(ParserInterface $parser)
{
return [
Expand All @@ -37,9 +34,6 @@ public function getBundles(ParserInterface $parser)
];
}

/**
* {@inheritdoc}
*/
public function getRouteCollection(LoaderResolverInterface $resolver, KernelInterface $kernel)
{
return $resolver
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/AbstractFilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function setRootPage(Request $request): void
{
$root = $this->findFirstPublishedRootByHostAndLanguage($request->getHost(), $request->getLocale());

if (null !== $root) {
if ($root) {
$root->loadDetails();
$request->attributes->set('pageModel', $root);
$GLOBALS['objPage'] = $root;
Expand Down Expand Up @@ -130,7 +130,7 @@ protected function tokenChecker(): TokenChecker
return $this->container->get(__METHOD__);
}

private function findFirstPublishedRootByHostAndLanguage(string $host, string $language): ?PageModel
private function findFirstPublishedRootByHostAndLanguage(string $host, string $language): PageModel|null
{
$t = PageModel::getTable();
$columns = ["$t.type='root' AND ($t.dns=? OR $t.dns='') AND ($t.language=? OR $t.fallback='1')"];
Expand Down
21 changes: 8 additions & 13 deletions src/Controller/FilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand All @@ -16,21 +16,16 @@
use Contao\CoreBundle\Framework\ContaoFramework;
use Contao\Dbafs;
use Contao\FilesModel;
use Contao\PageModel;
use Symfony\Component\Filesystem\Path;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;
use Webmozart\PathUtil\Path;

class FilesController extends AbstractFilesController
{
protected $framework;
protected $projectDir;

public function __construct(ContaoFramework $framework, string $projectDir)
{
$this->framework = $framework;
$this->projectDir = $projectDir;
public function __construct(
private readonly ContaoFramework $framework,
private readonly string $projectDir,
) {
}

public function fileAction(Request $request, string $file): BinaryFileResponse
Expand All @@ -43,7 +38,7 @@ public function fileAction(Request $request, string $file): BinaryFileResponse
}

// Initialize the Contao framework
$this->framework->initialize(true);
$this->framework->initialize();

// Set the root page for the domain as the pageModel attribute
$this->setRootPage($request);
Expand Down
37 changes: 11 additions & 26 deletions src/Controller/ProtectedImagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand All @@ -22,37 +22,22 @@
use Contao\Image\DeferredResizerInterface;
use Contao\Image\Exception\FileNotExistsException;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Path;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Webmozart\PathUtil\Path;

class ProtectedImagesController extends AbstractFilesController
{
private ImageFactoryInterface $imageFactory;
private DeferredResizerInterface $resizer;
private DeferredImageStorageInterface $deferredImageStorage;
private Filesystem $filesystem;
private ContaoFramework $framework;
private string $targetDir;
private string $projectDir;

public function __construct(
ImageFactoryInterface $imageFactory,
DeferredResizerInterface $resizer,
DeferredImageStorageInterface $deferredImageStorage,
Filesystem $filesystem,
ContaoFramework $framework,
string $targetDir,
string $projectDir
private readonly ImageFactoryInterface $imageFactory,
private readonly DeferredResizerInterface $resizer,
private readonly DeferredImageStorageInterface $deferredImageStorage,
private readonly Filesystem $filesystem,
private readonly ContaoFramework $framework,
private readonly string $targetDir,
private readonly string $projectDir,
) {
$this->imageFactory = $imageFactory;
$this->resizer = $resizer;
$this->deferredImageStorage = $deferredImageStorage;
$this->filesystem = $filesystem;
$this->framework = $framework;
$this->targetDir = $targetDir;
$this->projectDir = $projectDir;
}

public function __invoke(Request $request, string $path): Response
Expand All @@ -66,7 +51,7 @@ public function __invoke(Request $request, string $path): Response
$filePath = Path::join($this->targetDir, $config['path']);

// Initialize the Contao framework
$this->framework->initialize(true);
$this->framework->initialize();

// Set the root page for the domain as the pageModel attribute
$this->setRootPage($request);
Expand Down
11 changes: 4 additions & 7 deletions src/DataContainer/FilesCallbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand All @@ -19,15 +19,12 @@
use Contao\FilesModel;
use Contao\Folder;
use Contao\Input;
use Webmozart\PathUtil\Path;
use Symfony\Component\Filesystem\Path;

class FilesCallbacks
{
private $projectDir;

public function __construct(string $projectDir)
public function __construct(private readonly string $projectDir)
{
$this->projectDir = $projectDir;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/Compiler/AdjustResizerServicePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand Down
11 changes: 4 additions & 7 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand All @@ -14,15 +14,12 @@

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Webmozart\PathUtil\Path;
use Symfony\Component\Filesystem\Path;

class Configuration implements ConfigurationInterface
{
private string $projectDir;

public function __construct(string $projectDir)
public function __construct(private readonly string $projectDir)
{
$this->projectDir = $projectDir;
}

public function getConfigTreeBuilder(): TreeBuilder
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/ContaoFileAccessExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/*
* This file is part of the ContaoFileAccessBundle.
* This file is part of the Contao File Access extension.
*
* (c) inspiredminds
* (c) INSPIRED MINDS
*
* @license LGPL-3.0-or-later
*/
Expand Down
Loading

0 comments on commit cffb35c

Please sign in to comment.