Commit c0e4df43 authored by Tino Goratsch's avatar Tino Goratsch

run php-cs-fixer

parent e2f2e28f
Pipeline #16379173 passed with stages
in 13 minutes and 5 seconds
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core;
use ACP3\Core\ACL\Model\Repository\UserRoleRepositoryInterface;
......@@ -80,6 +86,7 @@ class ACL
}
}
}
return $this->userRoles[$userId];
}
......@@ -96,6 +103,7 @@ class ACL
foreach ($this->userRoleRepository->getRolesByUserId($userId) as $userRole) {
$roles[] = $userRole['name'];
}
return $roles;
}
......@@ -114,7 +122,7 @@ class ACL
*/
public function userHasRole($roleId)
{
return in_array($roleId, $this->getUserRoleIds($this->user->getUserId()));
return \in_array($roleId, $this->getUserRoleIds($this->user->getUserId()));
}
/**
......@@ -151,7 +159,7 @@ class ACL
public function hasPermission($resource)
{
if (!empty($resource) && $this->modules->controllerActionExists($resource) === true) {
$resourceParts = explode('/', $resource);
$resourceParts = \explode('/', $resource);
if ($this->modules->isActive($resourceParts[1]) === true) {
return $this->canAccessResource($resource);
......@@ -177,6 +185,7 @@ class ACL
if (isset($this->getResources()[$area][$resource])) {
$module = $resourceParts[1];
$privilegeKey = $this->getResources()[$area][$resource]['key'];
return $this->userHasPrivilege($module, $privilegeKey) === true || $this->user->isSuperUser() === true;
}
......@@ -190,7 +199,7 @@ class ACL
*/
protected function convertResourcePathToArray($resource)
{
$resourceArray = explode('/', $resource);
$resourceArray = \explode('/', $resource);
if (empty($resourceArray[2]) === true) {
$resourceArray[2] = 'index';
......@@ -198,6 +207,7 @@ class ACL
if (empty($resourceArray[3]) === true) {
$resourceArray[3] = 'index';
}
return $resourceArray;
}
......@@ -225,10 +235,11 @@ class ACL
*/
protected function userHasPrivilege($module, $privilegeKey)
{
$privilegeKey = strtolower($privilegeKey);
$privilegeKey = \strtolower($privilegeKey);
if (isset($this->getPrivileges()[$module][$privilegeKey])) {
return $this->getPrivileges()[$module][$privilegeKey]['access'];
}
return false;
}
}
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licencing details.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\ACL\Exception;
......
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\ACL\Model\Repository;
interface UserRoleRepositoryInterface
......
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\ACL;
use ACP3\Core\Enum\BaseEnum;
......
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\ACL;
use ACP3\Core\Enum\BaseEnum;
......
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\Application;
use ACP3\Core\Environment\ApplicationPath;
......@@ -72,6 +78,6 @@ abstract class AbstractBootstrap implements BootstrapInterface
{
$path = $this->appPath->getAppDir() . 'config.yml';
return is_file($path) === true && filesize($path) !== 0;
return \is_file($path) === true && \filesize($path) !== 0;
}
}
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\Application;
use ACP3\Core\Controller\AreaEnum;
......@@ -15,7 +20,6 @@ use Symfony\Component\HttpFoundation\Response;
/**
* Bootstraps the application
* @package ACP3\Core\Application
*/
class Bootstrap extends AbstractBootstrap
{
......@@ -103,7 +107,7 @@ class Bootstrap extends AbstractBootstrap
} catch (\ACP3\Core\Authentication\Exception\UnauthorizedAccessException $e) {
/** @var \ACP3\Core\Http\Request $request */
$request = $this->container->get('core.http.request');
$redirectUri = base64_encode($request->getPathInfo());
$redirectUri = \base64_encode($request->getPathInfo());
$response = $redirect->temporary('users/index/login/redirect_' . $redirectUri);
} catch (\ACP3\Core\ACL\Exception\AccessForbiddenException $e) {
$response = $redirect->temporary('errors/index/access_forbidden');
......@@ -147,7 +151,7 @@ class Bootstrap extends AbstractBootstrap
return (bool)$this->systemSettings['maintenance_mode'] === true &&
$request->getArea() !== AreaEnum::AREA_ADMIN &&
strpos($request->getQuery(), 'users/index/login/') !== 0;
\strpos($request->getQuery(), 'users/index/login/') !== 0;
}
/**
......@@ -161,7 +165,7 @@ class Bootstrap extends AbstractBootstrap
$view->assign([
'PAGE_TITLE' => 'ACP3',
'ROOT_DIR' => $this->appPath->getWebRoot(),
'CONTENT' => $this->systemSettings['maintenance_message']
'CONTENT' => $this->systemSettings['maintenance_message'],
]);
$response = new Response($view->fetchTemplate('System/layout.maintenance.tpl'));
......@@ -215,7 +219,7 @@ class Bootstrap extends AbstractBootstrap
*/
public function startupChecks()
{
date_default_timezone_set('UTC');
\date_default_timezone_set('UTC');
return $this->databaseConfigExists();
}
......
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licencing details.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\Application;
......@@ -13,7 +14,6 @@ use FOS\HttpCache\SymfonyCache\CacheInvalidation;
use FOS\HttpCache\SymfonyCache\DebugListener;
use FOS\HttpCache\SymfonyCache\EventDispatchingHttpCache;
use FOS\HttpCache\SymfonyCache\PurgeListener;
use FOS\HttpCache\SymfonyCache\PurgeTagsListener;
use FOS\HttpCache\SymfonyCache\RefreshListener;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpCache\HttpCache;
......@@ -38,7 +38,7 @@ class BootstrapCache extends HttpCache implements CacheInvalidation
$this->addSubscriber(new UserContextListener([
'user_hash_uri' => '/widget/users/index/hash/',
'session_name_prefix' => SessionHandlerInterface::SESSION_NAME
'session_name_prefix' => SessionHandlerInterface::SESSION_NAME,
]));
$this->addSubscriber(new PurgeListener());
$this->addSubscriber(new RefreshListener());
......
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licencing details.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\Application\BootstrapCache;
......
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licencing details.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Core\Application\BootstrapCache\Event\Listener;
......@@ -22,7 +23,7 @@ class StaticAssetsListener implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return [
Events::POST_HANDLE => 'postHandle'
Events::POST_HANDLE => 'postHandle',
];
}
......@@ -30,15 +31,15 @@ class StaticAssetsListener implements EventSubscriberInterface
{
$response = $event->getResponse();
$content = $response->getContent();
if (strpos($content, static::PLACEHOLDER) !== false) {
$content = str_replace(
if (\strpos($content, static::PLACEHOLDER) !== false) {
$content = \str_replace(
static::PLACEHOLDER,
$this->addElementsFromTemplates($content) . "\n" . static::PLACEHOLDER,
$this->getCleanedUpTemplateOutput($content)
);
$response->setContent($content);
$response->headers->set('Content-Length', strlen($content));
$response->headers->set('Content-Length', \strlen($content));
}
}
......@@ -48,7 +49,7 @@ class StaticAssetsListener implements EventSubscriberInterface
*/
private function getCleanedUpTemplateOutput(string $tplOutput): string
{
return preg_replace(static::JAVASCRIPTS_REGEX_PATTERN, '', $tplOutput);
return \preg_replace(static::JAVASCRIPTS_REGEX_PATTERN, '', $tplOutput);
}