Skip to content

Commit 5062e81

Browse files
authored
Merge pull request #7681 from kenjis/docs-add-common-config
docs: add config() in Global Functions
2 parents 19db8f7 + c79698f commit 5062e81

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

user_guide_src/source/concepts/factories.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,12 @@ Convenience Functions
9999

100100
Two shortcut functions for Factories have been provided. These functions are always available.
101101

102+
.. _factories-config:
103+
102104
config()
103105
========
104106

105-
The first is ``config()`` which returns a new instance of a Config class. The only required parameter is the class name:
107+
The first is :php:func:`config()` which returns a new instance of a Config class. The only required parameter is the class name:
106108

107109
.. literalinclude:: factories/008.php
108110

user_guide_src/source/general/common_functions.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ Service Accessors
3030

3131
.. literalinclude:: common_functions/001.php
3232

33+
.. php:function:: config(string $name[, bool $getShared = true])
34+
35+
:param string $name: The config classname.
36+
:param bool $getShared: Whether to return a shared instance.
37+
:returns: The config instances.
38+
:rtype: object|null
39+
40+
More simple way of getting config instances from Factories.
41+
42+
See :ref:`Configuration <configuration-config>` and
43+
:ref:`Factories <factories-config>` for details.
44+
45+
The ``config()`` uses ``Factories::config()`` internally.
46+
See :ref:`factories-loading-class` for details on the first parameter ``$name``.
47+
3348
.. php:function:: cookie(string $name[, string $value = ''[, array $options = []]])
3449
3550
:param string $name: Cookie name

user_guide_src/source/general/configuration.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ By using the ``new`` keyword to create an instance:
3030

3131
.. literalinclude:: configuration/001.php
3232

33+
.. _configuration-config:
34+
3335
config()
3436
--------
3537

36-
By using the ``config()`` function:
38+
By using the :php:func:`config()` function:
3739

3840
.. literalinclude:: configuration/002.php
3941

user_guide_src/source/general/modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ with the ``new`` command:
189189

190190
.. literalinclude:: modules/008.php
191191

192-
Config files are automatically discovered whenever using the ``config()`` function that is always available.
192+
Config files are automatically discovered whenever using the :php:func:`config()` function that is always available.
193193

194194
.. note:: We don't recommend you use the same short classname in modules.
195195
Modules that need to override or add to known configurations in **app/Config/** should use :ref:`registrars`.

0 commit comments

Comments
 (0)