Skip to content

Commit 9f71f23

Browse files
committed
docs: fix and update the sample codes
1 parent 396fe84 commit 9f71f23

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

user_guide_src/source/concepts/services.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ CodeIgniter's classes provide an interface that they adhere to. When you want to
106106
core classes, you only need to ensure you meet the requirements of the interface and you know that
107107
the 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
110110
want 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

user_guide_src/source/concepts/services/006.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use CodeIgniter\Router\RouteCollectionInterface;
66

7-
class MyRouter implements RouteCollectionInterface
7+
class MyRouteCollection implements RouteCollectionInterface
88
{
99
// Implement required methods here.
1010
}

user_guide_src/source/concepts/services/007.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
class 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
}

user_guide_src/source/concepts/services/010.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
class 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
}

0 commit comments

Comments
 (0)