Skip to content

Commit 2413c8c

Browse files
authored
Merge pull request #5366 from kenjis/docs-add-about-config-in-modules
docs: add about Config in Modules
2 parents 045a168 + d4d3316 commit 2413c8c

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

user_guide_src/source/concepts/factories.rst

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,28 @@ to access user records always go through that connection::
5858
Now any time the ``UserModel`` is loaded from ``Factories`` it will in fact be returning a
5959
class instance that uses the alternate database connection.
6060

61+
.. _factories-options:
62+
6163
Factories Options
6264
==================
6365

6466
The default behavior might not work for every component. For example, say your component
6567
name and its path do not align, or you need to limit instances to a certain type of class.
6668
Each component takes a set of options to direct discovery and instantiation.
6769

68-
========== ============== ==================================================================================================================== ===================================================
69-
Key Type Description Default
70-
========== ============== ==================================================================================================================== ===================================================
71-
component string or null The name of the component (if different than the static method). This can be used to alias one component to another. ``null`` (defaults to the component name)
72-
path string or null The relative path within the namespace/folder to look for classes. ``null`` (defaults to the component name)
73-
instanceOf string or null A required class name to match on the returned instance. ``null`` (no filtering)
74-
getShared boolean Whether to return a shared instance of the class or load a fresh one. ``true``
75-
preferApp boolean Whether a class with the same basename in the App namespace overrides other explicit class requests. ``true``
76-
========== ============== ==================================================================================================================== ===================================================
70+
========== ============== ============================================================ ===================================================
71+
Key Type Description Default
72+
========== ============== ============================================================ ===================================================
73+
component string or null The name of the component (if different than the static ``null`` (defaults to the component name)
74+
method). This can be used to alias one component to another.
75+
path string or null The relative path within the namespace/folder to look for ``null`` (defaults to the component name)
76+
classes.
77+
instanceOf string or null A required class name to match on the returned instance. ``null`` (no filtering)
78+
getShared boolean Whether to return a shared instance of the class or load a ``true``
79+
fresh one.
80+
preferApp boolean Whether a class with the same basename in the App namespace ``true``
81+
overrides other explicit class requests.
82+
========== ============== ============================================================ ===================================================
7783

7884
Factories Behavior
7985
==================

user_guide_src/source/general/modules.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ with the ``new`` command::
191191

192192
Config files are automatically discovered whenever using the **config()** function that is always available.
193193

194+
.. note:: We don't recommend you use the same short classname in modules.
195+
Modules that need to override or add to known configurations in **app/Config/** should use :ref:`registrars`.
196+
197+
.. note:: **config()** finds the file in **app/Config/** when there is a class with the same shortname,
198+
even if you specify a fully qualified class name like ``config(\Acme\Blog\Config\Blog::class)``.
199+
This is because ``config()`` is a wrapper for the ``Factories`` class which uses ``preferApp`` by default. See :ref:`factories-options` for more information.
200+
194201
Migrations
195202
==========
196203

0 commit comments

Comments
 (0)