File tree Expand file tree Collapse file tree 4 files changed +21
-28
lines changed
user_guide_src/source/concepts Expand file tree Collapse file tree 4 files changed +21
-28
lines changed Original file line number Diff line number Diff line change @@ -20,4 +20,13 @@ class Optimize
2020 * @see https://codeigniter.com/user_guide/concepts/factories.html#config-caching
2121 */
2222 public bool $ configCacheEnabled = false ;
23+
24+ /**
25+ * --------------------------------------------------------------------------
26+ * Config Caching
27+ * --------------------------------------------------------------------------
28+ *
29+ * @see https://codeigniter.com/user_guide/concepts/autoloader.html#file-locator-caching
30+ */
31+ public bool $ locatorCacheEnabled = false ;
2332}
Original file line number Diff line number Diff line change 1515
1616use CodeIgniter \Autoloader \Autoloader ;
1717use CodeIgniter \Autoloader \FileLocator ;
18+ use CodeIgniter \Autoloader \FileLocatorCached ;
1819use CodeIgniter \Autoloader \FileLocatorInterface ;
1920use CodeIgniter \Cache \CacheInterface ;
2021use CodeIgniter \Cache \ResponseCache ;
7172use Config \Images ;
7273use Config \Migrations ;
7374use Config \Modules ;
75+ use Config \Optimize ;
7476use Config \Pager as ConfigPager ;
7577use Config \Services as AppServices ;
7678use Config \Toolbar as ConfigToolbar ;
@@ -281,7 +283,14 @@ public static function locator(bool $getShared = true)
281283 {
282284 if ($ getShared ) {
283285 if (empty (static ::$ instances ['locator ' ])) {
284- static ::$ instances ['locator ' ] = new FileLocator (static ::autoloader ());
286+ $ cacheEnabled = class_exists (Optimize::class)
287+ && (new Optimize ())->locatorCacheEnabled ;
288+
289+ if ($ cacheEnabled ) {
290+ static ::$ instances ['locator ' ] = new FileLocatorCached (new FileLocator (static ::autoloader ()));
291+ } else {
292+ static ::$ instances ['locator ' ] = new FileLocator (static ::autoloader ());
293+ }
285294 }
286295
287296 return static ::$ mocks ['locator ' ] ?? static ::$ instances ['locator ' ];
Original file line number Diff line number Diff line change @@ -190,6 +190,6 @@ Or simply delete the **writable/cache/FileLocatorCache** file.
190190How to Enable FileLocator Caching
191191=================================
192192
193- Add the following code in **app/Config/Services .php **:
193+ Set the following property to `` true `` in **app/Config/Optimize .php **: :
194194
195- .. literalinclude :: autoloader/004.php
195+ public bool $locatorCacheEnabled = true;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments