@@ -64,18 +64,21 @@ To load routes from some custom source (i.e. from something other than annotatio
64
64
YAML or XML files), you need to create a custom route loader. This loader
65
65
has to implement :class: `Symfony\\ Component\\ Config\\ Loader\\ LoaderInterface `.
66
66
67
+ In most cases it's better not to implement
68
+ :class: `Symfony\\ Component\\ Config\\ Loader\\ LoaderInterface `
69
+ yourself, but extend from :class: `Symfony\\ Component\\ Config\\ Loader\\ Loader `.
70
+
67
71
The sample loader below supports loading routing resources with a type of
68
72
``extra ``. The type ``extra `` isn't important - you can just invent any resource
69
73
type you want. The resource name itself is not actually used in the example::
70
74
71
75
namespace AppBundle\Routing;
72
76
73
- use Symfony\Component\Config\Loader\LoaderInterface;
74
- use Symfony\Component\Config\Loader\LoaderResolverInterface;
77
+ use Symfony\Component\Config\Loader\Loader;
75
78
use Symfony\Component\Routing\Route;
76
79
use Symfony\Component\Routing\RouteCollection;
77
80
78
- class ExtraLoader implements LoaderInterface
81
+ class ExtraLoader extends Loader
79
82
{
80
83
private $loaded = false;
81
84
@@ -110,17 +113,6 @@ type you want. The resource name itself is not actually used in the example::
110
113
{
111
114
return 'extra' === $type;
112
115
}
113
-
114
- public function getResolver()
115
- {
116
- // needed, but can be blank, unless you want to load other resources
117
- // and if you do, using the Loader base class is easier (see below)
118
- }
119
-
120
- public function setResolver(LoaderResolverInterface $resolver)
121
- {
122
- // same as above
123
- }
124
116
}
125
117
126
118
Make sure the controller you specify really exists. In this case you
@@ -130,6 +122,7 @@ of the ``AppBundle``::
130
122
namespace AppBundle\Controller;
131
123
132
124
use Symfony\Component\HttpFoundation\Response;
125
+ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
133
126
134
127
class ExtraController extends Controller
135
128
{
@@ -232,11 +225,10 @@ for the ``ExtraLoader``, so it is set to ".".
232
225
More advanced Loaders
233
226
---------------------
234
227
235
- In most cases it's better not to implement
236
- :class: `Symfony\\ Component\\ Config\\ Loader\\ LoaderInterface `
237
- yourself, but extend from :class: `Symfony\\ Component\\ Config\\ Loader\\ Loader `.
238
- This class knows how to use a
239
- :class: `Symfony\\ Component\\ Config\\ Loader\\ LoaderResolver ` to load secondary
228
+ If your custom route loader extends from
229
+ :class: `Symfony\\ Component\\ Config\\ Loader\\ Loader ` as shown above, you
230
+ can also make use of the provided resolver, an instance of
231
+ :class: `Symfony\\ Component\\ Config\\ Loader\\ LoaderResolver `, to load secondary
240
232
routing resources.
241
233
242
234
Of course you still need to implement
0 commit comments