mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 06:14:59 +00:00
sf4 depreciation: repairing crud custom routes loader
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user