sf4 depreciation: repairing crud custom routes loader

This commit is contained in:
2021-02-02 11:48:19 +01:00
parent 42c2ac48d2
commit 0b8a22ae46
4 changed files with 173 additions and 13 deletions

View File

@@ -20,25 +20,58 @@
namespace Chill\MainBundle\CRUD\Routing;
use Symfony\Component\Config\Loader\Loader;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
/**
* Class CRUDRoutesLoader
* Load the route for CRUD
*
* @package Chill\MainBundle\CRUD\Routing
*/
class CRUDRoutesLoader
class CRUDRoutesLoader extends Loader
{
/**
* @var array
*/
protected $config = [];
/**
* @var bool
*/
private $isLoaded = false;
/**
* CRUDRoutesLoader constructor.
*
* @param $config
*/
public function __construct($config)
{
$this->config = $config;
}
public function load()
/**
* @param mixed $resource
* @param null $type
* @return bool
*/
public function supports($resource, $type = null)
{
return 'CRUD' === $type;
}
/**
* @return RouteCollection
*/
public function load($resource, $type = null)
{
if (true === $this->isLoaded) {
throw new \RuntimeException('Do not add the "CRUD" loader twice');
}
$collection = new RouteCollection();
foreach ($this->config as $config) {
@@ -48,6 +81,10 @@ class CRUDRoutesLoader
return $collection;
}
/**
* @param $config
* @return RouteCollection
*/
protected function loadConfig($config): RouteCollection
{
$collection = new RouteCollection();