Skip to content

Commit

Permalink
Merge pull request #5790 from kenjis/fix-docs-events
Browse files Browse the repository at this point in the history
docs: fix events.rst
  • Loading branch information
kenjis authored Mar 15, 2022
2 parents c8dbb73 + d8b3ed4 commit d95e461
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions user_guide_src/source/extending/common.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Replacing Common Functions

There are quite a few functions necessary to CodeIgniter that need to be loaded early for use in the core classes and
thus cannot be placed into a helper. While most users will never have any need to do this, but the option to replace
these functions does exist for those who would like to significantly alter the CodeIgniter core. In the ``App\``
directory there is a file ``Common.php``, and any functions defined in there will take precedence over the versions
found in ``system/Common.php``. This is also an opportunity to create globally-available functions you intend to
these functions does exist for those who would like to significantly alter the CodeIgniter core. In the **app/**
directory there is a file **Common.php**, and any functions defined in there will take precedence over the versions
found in **system/Common.php**. This is also an opportunity to create globally-available functions you intend to
use throughout the framework.

.. note:: Messing with a core system class has a lot of implications, so make sure you know what you are doing before
Expand Down
6 changes: 3 additions & 3 deletions user_guide_src/source/extending/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ Defining an Event
=================

Most events are defined within the **app/Config/Events.php** file. You can subscribe an action to an event with
the Events class' ``on()`` method. The first parameter is the name of the event to subscribe to. The second parameter is
the ``Events`` class' ``on()`` method. The first parameter is the name of the event to subscribe to. The second parameter is
a callable that will be run when that event is triggered:

.. literalinclude:: events/001.php

In this example, whenever the **pre_controller** event is executed, an instance of ``MyClass`` is created and the
``MyFunction`` method is run. Note that the second parameter can be *any* form of
In this example, whenever the ``pre_system`` event is executed, an instance of ``MyClass`` is created and the
``myFunction()`` method is run. Note that the second parameter can be *any* form of
`callable <https://www.php.net/manual/en/function.is-callable.php>`_ that PHP recognizes:

.. literalinclude:: events/002.php
Expand Down
2 changes: 1 addition & 1 deletion user_guide_src/source/extending/events/001.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

use CodeIgniter\Events\Events;

Events::on('pre_system', ['MyClass', 'MyFunction']);
Events::on('pre_system', ['MyClass', 'myFunction']);
2 changes: 1 addition & 1 deletion user_guide_src/source/extending/events/002.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// Call on an instance method
$user = new User();
Events::on('pre_system', [$user, 'some_method']);
Events::on('pre_system', [$user, 'someMethod']);

// Call on a static method
Events::on('pre_system', 'SomeClass::someMethod');
Expand Down

0 comments on commit d95e461

Please sign in to comment.