Skip to content

Commit 29901ec

Browse files
committed
docs: add "Loading a Class in Sub-directories"
1 parent 26605ad commit 29901ec

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

user_guide_src/source/concepts/factories.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,16 @@ On the other hand, Services have code to create instances, so it can create a co
4141
that needs other services or class instances. When you get a service, Services require a service name,
4242
not a class name, so the returned instance can be changed without changing the client code.
4343

44+
Loading Classes
45+
***************
46+
47+
Loading a Class
48+
===============
49+
4450
.. _factories-example:
4551

46-
Example
47-
=======
52+
Model Example
53+
-------------
4854

4955
Take a look at **Models** as an example. You can access the Factory specific to Models
5056
by using the magic static method of the Factories class, ``Factories::models()``.
@@ -79,6 +85,15 @@ you get back the instance as before:
7985

8086
.. literalinclude:: factories/003.php
8187

88+
Loading a Class in Sub-directories
89+
==================================
90+
91+
If you want to load a class in sub directories, you use the ``/`` as a separator.
92+
The following code loads **app/Libraries/Sub/SubLib.php**:
93+
94+
.. literalinclude:: factories/013.php
95+
:lines: 2-
96+
8297
Convenience Functions
8398
*********************
8499

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
$lib = Factories::libraries('Sub/SubLib');

0 commit comments

Comments
 (0)