Skip to content

Commit 1188c64

Browse files
authored
Merge pull request #6180 from kenjis/fix-docs-extending-core_classes.rst
docs: improve extending/core_classes.rst
2 parents af4271f + 57afedf commit 1188c64

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

user_guide_src/source/extending/core_classes.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ the core versions.
99
**Most users will never have any need to do this, but the option to replace or extend them does exist for those
1010
who would like to significantly alter the CodeIgniter core.**
1111

12-
.. note:: Messing with a core system class has a lot of implications, so make sure you know what you are doing before
12+
.. important:: Messing with a core system class has a lot of implications, so make sure you know what you are doing before
1313
attempting it.
1414

1515
.. contents::
@@ -47,15 +47,23 @@ The following is a list of the core system classes that are invoked every time C
4747
Replacing Core Classes
4848
======================
4949

50-
To use one of your own system classes instead of a default one, ensure that the :doc:`Autoloader <../concepts/autoloader>`
51-
can find your class, that your new class implements the appropriate interface, and modify the appropriate
52-
:doc:`Service <../concepts/services>` to load your class in place of the core class.
50+
To use one of your own system classes instead of a default one, ensure:
51+
52+
1. the :doc:`Autoloader <../concepts/autoloader>` can find your class,
53+
2. your new class implements the appropriate interface,
54+
3. and modify the appropriate :doc:`Service <../concepts/services>` to load your class in place of the core class.
55+
56+
Creating Your Class
57+
-------------------
5358

5459
For example, if you have a new ``App\Libraries\RouteCollection`` class that you would like to use in place of
5560
the core system class, you would create your class like this:
5661

5762
.. literalinclude:: core_classes/001.php
5863

64+
Adding the Service
65+
------------------
66+
5967
Then you would add the ``routes`` service in **app/Config/Services.php** to load your class instead:
6068

6169
.. literalinclude:: core_classes/002.php
@@ -65,7 +73,7 @@ Extending Core Classes
6573

6674
If all you need to is add some functionality to an existing library - perhaps add a method or two - then it's overkill
6775
to recreate the entire library. In this case, it's better to simply extend the class. Extending the class is nearly
68-
identical to replacing a class with one exception:
76+
identical to `Replacing Core Classes`_ with one exception:
6977

7078
* The class declaration must extend the parent class.
7179

0 commit comments

Comments
 (0)