mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix: SA: Fix "...does not call parent constructor... and ...Access to an undefined property..." rules.
SA stands for Static Analysis.
This commit is contained in:
parent
a17c22c74f
commit
8879734ea2
@ -35,11 +35,6 @@ parameters:
|
||||
count: 2
|
||||
path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
|
||||
|
||||
-
|
||||
message: "#^Chill\\\\MainBundle\\\\CRUD\\\\Routing\\\\CRUDRoutesLoader\\:\\:__construct\\(\\) does not call parent constructor from Symfony\\\\Component\\\\Config\\\\Loader\\\\Loader\\.$#"
|
||||
count: 1
|
||||
path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
|
||||
|
||||
-
|
||||
message: "#^Cannot unset offset '_token' on array\\{formatter\\: mixed, export\\: mixed, centers\\: mixed, alias\\: string\\}\\.$#"
|
||||
count: 1
|
||||
|
@ -100,11 +100,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property Chill\\\\MainBundle\\\\CRUD\\\\Routing\\\\CRUDRoutesLoader\\:\\:\\$apiConfig\\.$#"
|
||||
count: 2
|
||||
path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Command\\\\ChillImportUsersCommand\\:\\:tempOutput\\(\\)\\.$#"
|
||||
count: 1
|
||||
|
@ -1,22 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2019, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\CRUD\Routing;
|
||||
|
||||
@ -27,22 +11,13 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
|
||||
/**
|
||||
* Class CRUDRoutesLoader
|
||||
* Load the route for CRUD
|
||||
*
|
||||
* @package Chill\MainBundle\CRUD\Routing
|
||||
*/
|
||||
class CRUDRoutesLoader extends Loader
|
||||
{
|
||||
protected array $crudConfig = [];
|
||||
|
||||
protected array $apiCrudConfig = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isLoaded = false;
|
||||
|
||||
private bool $isLoaded = false;
|
||||
|
||||
private const ALL_SINGLE_METHODS = [
|
||||
Request::METHOD_GET,
|
||||
@ -52,19 +27,15 @@ class CRUDRoutesLoader extends Loader
|
||||
];
|
||||
|
||||
private const ALL_INDEX_METHODS = [ Request::METHOD_GET, Request::METHOD_HEAD ];
|
||||
|
||||
/**
|
||||
* CRUDRoutesLoader constructor.
|
||||
*
|
||||
* @param $crudConfig the config from cruds
|
||||
* @param $apicrudConfig the config from api_crud
|
||||
*/
|
||||
public function __construct(array $crudConfig, array $apiConfig)
|
||||
|
||||
public function __construct(array $crudConfig, array $apiCrudConfig)
|
||||
{
|
||||
$this->crudConfig = $crudConfig;
|
||||
$this->apiConfig = $apiConfig;
|
||||
$this->apiCrudConfig = $apiCrudConfig;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $resource
|
||||
* @param null $type
|
||||
@ -74,7 +45,7 @@ class CRUDRoutesLoader extends Loader
|
||||
{
|
||||
return 'CRUD' === $type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load routes for CRUD and CRUD Api
|
||||
*/
|
||||
@ -85,17 +56,17 @@ class CRUDRoutesLoader extends Loader
|
||||
}
|
||||
|
||||
$collection = new RouteCollection();
|
||||
|
||||
|
||||
foreach ($this->crudConfig as $crudConfig) {
|
||||
$collection->addCollection($this->loadCrudConfig($crudConfig));
|
||||
}
|
||||
foreach ($this->apiConfig as $crudConfig) {
|
||||
foreach ($this->apiCrudConfig as $crudConfig) {
|
||||
$collection->addCollection($this->loadApi($crudConfig));
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load routes for CRUD (without api)
|
||||
*
|
||||
@ -112,7 +83,7 @@ class CRUDRoutesLoader extends Loader
|
||||
$defaults = [
|
||||
'_controller' => $controller.':'.($action['controller_action'] ?? $name)
|
||||
];
|
||||
|
||||
|
||||
if ($name === 'index') {
|
||||
$path = "{_locale}".$crudConfig['base_path'];
|
||||
$route = new Route($path, $defaults);
|
||||
@ -126,10 +97,10 @@ class CRUDRoutesLoader extends Loader
|
||||
];
|
||||
$route = new Route($path, $defaults, $requirements);
|
||||
}
|
||||
|
||||
|
||||
$collection->add('chill_crud_'.$crudConfig['name'].'_'.$name, $route);
|
||||
}
|
||||
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
@ -186,14 +157,14 @@ class CRUDRoutesLoader extends Loader
|
||||
if (count($methods) === 0) {
|
||||
throw new \RuntimeException("The api configuration named \"{$crudConfig['name']}\", action \"{$name}\", ".
|
||||
"does not have any allowed methods. You should remove this action from the config ".
|
||||
"or allow, at least, one method");
|
||||
"or allow, at least, one method");
|
||||
}
|
||||
|
||||
if ('_entity' === $name && \in_array(Request::METHOD_POST, $methods)) {
|
||||
unset($methods[\array_search(Request::METHOD_POST, $methods)]);
|
||||
$entityPostRoute = $this->createEntityPostRoute($name, $crudConfig, $action,
|
||||
$entityPostRoute = $this->createEntityPostRoute($name, $crudConfig, $action,
|
||||
$controller);
|
||||
$collection->add("chill_api_single_{$crudConfig['name']}_{$name}_create",
|
||||
$collection->add("chill_api_single_{$crudConfig['name']}_{$name}_create",
|
||||
$entityPostRoute);
|
||||
}
|
||||
|
||||
@ -205,7 +176,7 @@ class CRUDRoutesLoader extends Loader
|
||||
|
||||
$route = new Route($path, $defaults, $requirements);
|
||||
$route->setMethods($methods);
|
||||
|
||||
|
||||
$collection->add('chill_api_single_'.$crudConfig['name'].'_'.$name, $route);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user