Skip to content

Commit d23acf0

Browse files
committed
refactor: use Services::get() in Config\Services
1 parent 8084f1e commit d23acf0

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

system/Config/Services.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public static function filters(?FiltersConfig $config = null, bool $getShared =
292292

293293
$config ??= config(FiltersConfig::class);
294294

295-
return new Filters($config, AppServices::request(), AppServices::response());
295+
return new Filters($config, AppServices::get('request'), AppServices::get('response'));
296296
}
297297

298298
/**
@@ -376,8 +376,8 @@ public static function language(?string $locale = null, bool $getShared = true)
376376
return static::getSharedInstance('language', $locale)->setLocale($locale);
377377
}
378378

379-
if (AppServices::request() instanceof IncomingRequest) {
380-
$requestLocale = AppServices::request()->getLocale();
379+
if (AppServices::get('request') instanceof IncomingRequest) {
380+
$requestLocale = AppServices::get('request')->getLocale();
381381
} else {
382382
$requestLocale = Locale::getDefault();
383383
}
@@ -432,7 +432,7 @@ public static function negotiator(?RequestInterface $request = null, bool $getSh
432432
return static::getSharedInstance('negotiator', $request);
433433
}
434434

435-
$request ??= AppServices::request();
435+
$request ??= AppServices::get('request');
436436

437437
return new Negotiate($request);
438438
}
@@ -449,7 +449,7 @@ public static function responsecache(?Cache $config = null, ?CacheInterface $cac
449449
}
450450

451451
$config ??= config(Cache::class);
452-
$cache ??= AppServices::cache();
452+
$cache ??= AppServices::get('cache');
453453

454454
return new ResponseCache($config, $cache);
455455
}
@@ -485,7 +485,7 @@ public static function parser(?string $viewPath = null, ?ViewConfig $config = nu
485485
$viewPath = $viewPath ?: (new Paths())->viewDirectory;
486486
$config ??= config(ViewConfig::class);
487487

488-
return new Parser($config, $viewPath, AppServices::locator(), CI_DEBUG, AppServices::logger());
488+
return new Parser($config, $viewPath, AppServices::get('locator'), CI_DEBUG, AppServices::get('logger'));
489489
}
490490

491491
/**
@@ -504,7 +504,7 @@ public static function renderer(?string $viewPath = null, ?ViewConfig $config =
504504
$viewPath = $viewPath ?: (new Paths())->viewDirectory;
505505
$config ??= config(ViewConfig::class);
506506

507-
return new View($config, $viewPath, AppServices::locator(), CI_DEBUG, AppServices::logger());
507+
return new View($config, $viewPath, AppServices::get('locator'), CI_DEBUG, AppServices::get('logger'));
508508
}
509509

510510
/**
@@ -565,7 +565,7 @@ public static function incomingrequest(?App $config = null, bool $getShared = tr
565565

566566
return new IncomingRequest(
567567
$config,
568-
AppServices::uri(),
568+
AppServices::get('uri'),
569569
'php://input',
570570
new UserAgent()
571571
);
@@ -600,7 +600,7 @@ public static function redirectresponse(?App $config = null, bool $getShared = t
600600

601601
$config ??= config(App::class);
602602
$response = new RedirectResponse($config);
603-
$response->setProtocolVersion(AppServices::request()->getProtocolVersion());
603+
$response->setProtocolVersion(AppServices::get('request')->getProtocolVersion());
604604

605605
return $response;
606606
}
@@ -617,7 +617,7 @@ public static function routes(bool $getShared = true)
617617
return static::getSharedInstance('routes');
618618
}
619619

620-
return new RouteCollection(AppServices::locator(), config(Modules::class), config(Routing::class));
620+
return new RouteCollection(AppServices::get('locator'), config(Modules::class), config(Routing::class));
621621
}
622622

623623
/**
@@ -632,8 +632,8 @@ public static function router(?RouteCollectionInterface $routes = null, ?Request
632632
return static::getSharedInstance('router', $routes, $request);
633633
}
634634

635-
$routes ??= AppServices::routes();
636-
$request ??= AppServices::request();
635+
$routes ??= AppServices::get('routes');
636+
$request ??= AppServices::get('request');
637637

638638
return new Router($routes, $request);
639639
}
@@ -668,7 +668,7 @@ public static function session(?SessionConfig $config = null, bool $getShared =
668668

669669
$config ??= config(SessionConfig::class);
670670

671-
$logger = AppServices::logger();
671+
$logger = AppServices::get('logger');
672672

673673
$driverName = $config->driver;
674674

@@ -685,7 +685,7 @@ public static function session(?SessionConfig $config = null, bool $getShared =
685685
}
686686
}
687687

688-
$driver = new $driverName($config, AppServices::request()->getIPAddress());
688+
$driver = new $driverName($config, AppServices::get('request')->getIPAddress());
689689
$driver->setLogger($logger);
690690

691691
$session = new Session($driver, $config);
@@ -713,7 +713,7 @@ public static function siteurifactory(
713713
}
714714

715715
$config ??= config('App');
716-
$superglobals ??= AppServices::superglobals();
716+
$superglobals ??= AppServices::get('superglobals');
717717

718718
return new SiteURIFactory($config, $superglobals);
719719
}
@@ -747,7 +747,7 @@ public static function throttler(bool $getShared = true)
747747
return static::getSharedInstance('throttler');
748748
}
749749

750-
return new Throttler(AppServices::cache());
750+
return new Throttler(AppServices::get('cache'));
751751
}
752752

753753
/**
@@ -796,7 +796,7 @@ public static function uri(?string $uri = null, bool $getShared = true)
796796

797797
if ($uri === null) {
798798
$appConfig = config(App::class);
799-
$factory = AppServices::siteurifactory($appConfig, AppServices::superglobals());
799+
$factory = AppServices::siteurifactory($appConfig, AppServices::get('superglobals'));
800800

801801
return $factory->createFromGlobals();
802802
}
@@ -817,7 +817,7 @@ public static function validation(?ValidationConfig $config = null, bool $getSha
817817

818818
$config ??= config(ValidationConfig::class);
819819

820-
return new Validation($config, AppServices::renderer());
820+
return new Validation($config, AppServices::get('renderer'));
821821
}
822822

823823
/**
@@ -832,7 +832,7 @@ public static function viewcell(bool $getShared = true)
832832
return static::getSharedInstance('viewcell');
833833
}
834834

835-
return new Cell(AppServices::cache());
835+
return new Cell(AppServices::get('cache'));
836836
}
837837

838838
/**

0 commit comments

Comments
 (0)