File tree Expand file tree Collapse file tree
user_guide_src/source/concepts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -150,6 +150,9 @@ Configurations
150150To set default component options, create a new Config files at **app/Config/Factory.php **
151151that supplies options as an array property that matches the name of the component.
152152
153+ Example: Filters Factories
154+ --------------------------
155+
153156For example, if you want to create **Filters ** by Factories, the component name wll be ``filters ``.
154157And if you want to ensure that each filter is an instance of a class which implements CodeIgniter's ``FilterInterface ``,
155158your **app/Config/Factory.php ** file might look like this:
@@ -162,6 +165,22 @@ and the returned instance will surely be a CodeIgniter's filter.
162165This would prevent conflict of an third-party module which happened to have an
163166unrelated ``Filters `` path in its namespace.
164167
168+ Example: Library Factories
169+ --------------------------
170+
171+ If you want to load your library classes in the **app/Libraries ** directory with
172+ ``Factories::library('SomeLib') ``, the path `Libraries ` is different from the
173+ default path `Library `.
174+
175+ In this case, your **app/Config/Factory.php ** file will look like this:
176+
177+ .. literalinclude :: factories/011.php
178+
179+ Now you can load your libraries with the ``Factories::library() `` method:
180+
181+ .. literalinclude :: factories/012.php
182+ :lines: 2-
183+
165184setOptions Method
166185=================
167186
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Config ;
4+
5+ use CodeIgniter \Config \Factory as BaseFactory ;
6+
7+ class Factory extends BaseFactory
8+ {
9+ public $ library = [
10+ 'path ' => 'Libraries ' ,
11+ ];
12+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use CodeIgniter \Config \Factories ;
4+
5+ $ someLib = Factories::library ('SomeLib ' );
You can’t perform that action at this time.
0 commit comments