Skip to content

Commit 335cca9

Browse files
committed
docs: improve helpers
Add about $helpers in Controller. Add sub sections.
1 parent ed25eae commit 335cca9

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

user_guide_src/source/general/helpers.rst

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ global **system/Helpers** directory.
3232
Loading a Helper
3333
================
3434

35+
.. note:: The URL helper is always loaded so you do not need to load it yourself.
36+
3537
Loading a helper file is quite simple using the following method:
3638

3739
.. literalinclude:: helpers/001.php
@@ -44,22 +46,31 @@ For example, to load the **Cookie Helper** file, which is named
4446

4547
.. literalinclude:: helpers/002.php
4648

49+
.. note:: The Helper loading method above does not return a value, so
50+
don't try to assign it to a variable. Just use it as shown.
51+
52+
Loading Multiple Helpers
53+
------------------------
54+
4755
If you need to load more than one helper at a time, you can pass
4856
an array of file names in and all of them will be loaded:
4957

5058
.. literalinclude:: helpers/003.php
5159

60+
Loading in a Controller
61+
-----------------------
62+
5263
A helper can be loaded anywhere within your controller methods (or
5364
even within your View files, although that's not a good practice), as
54-
long as you load it before you use it. You can load your helpers in your
65+
long as you load it before you use it.
66+
67+
You can load your helpers in your
5568
controller constructor so that they become available automatically in
5669
any function, or you can load a helper in a specific function that needs
5770
it.
5871

59-
.. note:: The Helper loading method above does not return a value, so
60-
don't try to assign it to a variable. Just use it as shown.
61-
62-
.. note:: The URL helper is always loaded so you do not need to load it yourself.
72+
However if you want to load in your controller constructor, you can use the ``$helpers``
73+
property in Controller instead. See :ref:`Controllers <controllers-helpers>`.
6374

6475
Loading from Non-standard Locations
6576
-----------------------------------

user_guide_src/source/incoming/controllers.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Logger Object
5353
An instance of the :doc:`Logger <../general/logging>` class is available as a class property,
5454
``$this->logger``.
5555

56+
.. _controllers-helpers:
57+
5658
Helpers
5759
=======
5860

0 commit comments

Comments
 (0)