@@ -24,22 +24,22 @@ by using the magic static method of the Factories class, ``Factories::models()``
2424the common path structure for namespaces and folders, Factories know that the model files
2525and classes are found within **Models **, so you can request a model by its shorthand base name::
2626
27- use CodeIgniter\Config\Factories;
27+ use CodeIgniter\Config\Factories;
2828
29- $users = Factories::models('UserModel');
29+ $users = Factories::models('UserModel');
3030
3131Or you could also request a specific class::
3232
33- $widgets = Factories::models('Some\Namespace\Models\WidgetModel');
33+ $widgets = Factories::models('Some\Namespace\Models\WidgetModel');
3434
3535Next time you ask for the same class anywhere in your code, ``Factories `` will be sure
3636you get back the instance as before::
3737
38- class SomeOtherClass
39- {
40- $widgets = Factories::models('WidgetModel');
41- ...
42- }
38+ class SomeOtherClass
39+ {
40+ $widgets = Factories::models('WidgetModel');
41+ ...
42+ }
4343
4444Factory Parameters
4545==================
@@ -52,8 +52,8 @@ constructor, making it easy to configure your class instance on-the-fly. For exa
5252your app uses a separate database for authentication and you want to be sure that any attempts
5353to access user records always go through that connection::
5454
55- $conn = db_connect('AuthDatabase');
56- $users = Factories::models('UserModel', [], $conn);
55+ $conn = db_connect('AuthDatabase');
56+ $users = Factories::models('UserModel', [], $conn);
5757
5858Now any time the ``UserModel `` is loaded from ``Factories `` it will in fact be returning a
5959class instance that uses the alternate database connection.
@@ -92,17 +92,17 @@ that supplies options as an array property that matches the name of the componen
9292if you wanted to ensure that all Filters used by your app were valid framework instances,
9393your **Factories.php ** file might look like this::
9494
95- <?php namespace Config;
95+ <?php namespace Config;
9696
97- use CodeIgniter\Config\Factory as BaseFactory;
98- use CodeIgniter\Filters\FilterInterface;
97+ use CodeIgniter\Config\Factory as BaseFactory;
98+ use CodeIgniter\Filters\FilterInterface;
9999
100- class Factories extends BaseFactory
101- {
102- public $filters = [
103- 'instanceOf' => FilterInterface::class,
104- ];
105- }
100+ class Factories extends BaseFactory
101+ {
102+ public $filters = [
103+ 'instanceOf' => FilterInterface::class,
104+ ];
105+ }
106106
107107This would prevent conflict of an unrelated third-party module which happened to have an
108108unrelated "Filters" path in its namespace.
@@ -114,10 +114,10 @@ The ``Factories`` class has a static method to allow runtime option configuratio
114114supply the desired array of options using the ``setOptions() `` method and they will be
115115merged with the default values and stored for the next call::
116116
117- Factories::setOptions('filters', [
118- 'instanceOf' => FilterInterface::class,
119- 'prefersApp' => false,
120- ]);
117+ Factories::setOptions('filters', [
118+ 'instanceOf' => FilterInterface::class,
119+ 'prefersApp' => false,
120+ ]);
121121
122122Parameter Options
123123-----------------
@@ -131,5 +131,5 @@ For example, by default ``Factories`` assumes that you want to locate a shared i
131131a component. By adding a second parameter to the magic static call, you can control whether
132132that single call will return a new or shared instance::
133133
134- $users = Factories::models('UserModel', ['getShared' => true]); // Default; will always be the same instance
135- $other = Factories::models('UserModel', ['getShared' => false]); // Will always create a new instance
134+ $users = Factories::models('UserModel', ['getShared' => true]); // Default; will always be the same instance
135+ $other = Factories::models('UserModel', ['getShared' => false]); // Will always create a new instance
0 commit comments