Skip to content

Commit

Permalink
Update docs with information about callables (#486)
Browse files Browse the repository at this point in the history
Add note in documentation about callables and `$request` and `$response`
being provided as arguments.

In addition this adds two anchors to the documentation and changes the
name of the event listener anchor to be consistent with the other anchors.
  • Loading branch information
matslindh authored and christeredvartsen committed Jul 18, 2016
1 parent fda7265 commit 1f99712
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/develop/event_listeners.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ When writing an event listener for Imbo you can choose one of the following appr
Below you will find examples on the approaches mentioned above.

.. note::
Information regarding how to **attach** the event listeners to Imbo is available in the :ref:`event listener configuration <configuration-event-listeners>` section.
Information regarding how to **attach** the event listeners to Imbo is available in the :ref:`event listener configuration <event-listeners-configuration>` section.

Implement the ``Imbo\EventListener\ListenerInterface`` interface
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down Expand Up @@ -149,7 +149,7 @@ For testing and/or debugging purposes you can also write the event listener dire
// ...
];
The ``$event`` object passed to the function is the same as in the previous two examples. This approach should mostly be used for testing purposes and quick hacks. More information regarding this approach is available in the :ref:`event listener configuration <configuration-event-listeners>` section.
The ``$event`` object passed to the function is the same as in the previous two examples. This approach should mostly be used for testing purposes and quick hacks. More information regarding this approach is available in the :ref:`event listener configuration <event-listeners-configuration>` section.

Subscribing to events using a wild card
+++++++++++++++++++++++++++++++++++++++
Expand Down
16 changes: 15 additions & 1 deletion docs/installation/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ The configuration file(s) you need to create should simply return arrays with co
:local:
:depth: 1

.. _configuration-with-callables:

Using callables in configuration
--------------------------------

Imbo supports providing callables for certain configuration options. In Imbo 2 these are the :ref:`accessControl <access-control-configuration>`, :ref:`database <database-configuration>`, :ref:`eventListeners[name] <event-listeners-configuration>`, :ref:`resource <resource-configuration>` and :ref:`storage <storage-configuration>` options, while Imbo 3 adds callable support for :ref:`transformationPresets <transformation-presets-configuration>`. The callable receives two arguments (`$request` and `$response`) which map to the active request and response objects.

By using a callable you can extend Imbo with custom logic for most configuration options (or provide the ``$request`` or ``$response`` objects to your implementing class), such as switching storage modules based on which user performed the request.


.. _access-control-configuration:

Imbo access control - ``accessControl``
Expand Down Expand Up @@ -710,7 +720,7 @@ Example usage:
// ...
];
.. _configuration-event-listeners:
.. _event-listeners-configuration:

Event listeners - ``eventListeners``
------------------------------------
Expand Down Expand Up @@ -995,6 +1005,8 @@ Imbo itself includes an event listener initializer in the default configuration

.. note:: Only event listeners specified as strings (class names) in the configuration will be instantiated by Imbo, so event listeners instantiated in the configuration array, either directly or via a Closures, will not be initialized by the configured event listener initializers.

.. _transformation-presets-configuration:

Image transformation presets - ``transformationPresets``
--------------------------------------------------------

Expand Down Expand Up @@ -1043,6 +1055,8 @@ By doing this the ``thumbnail`` part of the ``fixedGraythumb`` preset will ignor

.. note:: The URLs will stay the same if you change the transformation chain in a preset. Keep this in mind if you use for instance Varnish or some other HTTP accelerator in front of your web server(s).

.. _resource-configuration:

Custom resources and routes - ``resources`` and ``routes``
----------------------------------------------------------

Expand Down

0 comments on commit 1f99712

Please sign in to comment.