File tree Expand file tree Collapse file tree
user_guide_src/source/concepts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,14 +106,14 @@ CodeIgniter's classes provide an interface that they adhere to. When you want to
106106core classes, you only need to ensure you meet the requirements of the interface and you know that
107107the classes are compatible.
108108
109- For example, the ``RouterCollection `` class implements the ``RouterCollectionInterface ``. When you
109+ For example, the ``RouteCollection `` class implements the ``RouteCollectionInterface ``. When you
110110want to create a replacement that provides a different way to create routes, you just need to
111- create a new class that implements the ``RouterCollectionInterface ``:
111+ create a new class that implements the ``RouteCollectionInterface ``:
112112
113113.. literalinclude :: services/006.php
114114
115- Finally, modify **app/Config/Services.php ** to create a new instance of ``MyRouter ``
116- instead of ``CodeIgniter\Router\RouterCollection ``:
115+ Finally, add the `` routes() `` method to **app/Config/Services.php ** to create a new instance of ``MyRouteCollection ``
116+ instead of ``CodeIgniter\Router\RouteCollection ``:
117117
118118.. literalinclude :: services/007.php
119119
Original file line number Diff line number Diff line change 44
55use CodeIgniter \Router \RouteCollectionInterface ;
66
7- class MyRouter implements RouteCollectionInterface
7+ class MyRouteCollection implements RouteCollectionInterface
88{
99 // Implement required methods here.
1010}
Original file line number Diff line number Diff line change 66
77class Services extends BaseService
88{
9+ // ...
10+
911 public static function routes ()
1012 {
11- return new \App \Router \MyRouter ( );
13+ return new \App \Router \MyRouteCollection ( static :: locator (), config ( ' Modules ' ) );
1214 }
13-
14- // ...
1515}
Original file line number Diff line number Diff line change 66
77class Services extends BaseService
88{
9+ // ...
10+
911 public static function renderer ($ viewPath = APPPATH . 'views/ ' )
1012 {
1113 return new \CodeIgniter \View \View ($ viewPath );
1214 }
13-
14- // ...
1515}
Original file line number Diff line number Diff line change 66
77class Services extends BaseService
88{
9- public static function routes ($ getShared = false )
9+ // ...
10+
11+ public static function routes ($ getShared = true )
1012 {
11- if (! $ getShared ) {
12- return new \ CodeIgniter \ Router \ RouteCollection ( );
13+ if ($ getShared ) {
14+ return static :: getSharedInstance ( ' routes ' );
1315 }
1416
15- return static ::getSharedInstance ( ' routes ' );
17+ return new \ App \ Router \ MyRouteCollection ( static ::locator (), config ( ' Modules ' ) );
1618 }
17-
18- // ...
1919}
You can’t perform that action at this time.
0 commit comments