Skip to content

Commit f5d9f62

Browse files
committed
Use static method rather than function to use services
1 parent af2eba6 commit f5d9f62

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

system/CLI/CommandRunner.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
* @filesource
3838
*/
3939

40+
use CodeIgniter\Config\Services;
4041
use CodeIgniter\Controller;
4142

4243
class CommandRunner extends Controller
@@ -127,12 +128,10 @@ protected function runCommand(string $command, array $params)
127128
/**
128129
* Scans all Commands directories and prepares a list
129130
* of each command with it's group and file.
130-
*
131-
* @return null|void
132131
*/
133132
protected function createCommandList()
134133
{
135-
$files = service('locator')->listFiles('Commands/');
134+
$files = Services::locator()->listFiles('Commands/');
136135

137136
// If no matching command files were found, bail
138137
if (empty($files))
@@ -144,7 +143,7 @@ protected function createCommandList()
144143
// alias exists in the class. If so, return it. Otherwise, try the next.
145144
foreach ($files as $file)
146145
{
147-
$className = service('locator')->findQualifiedNameFromPath($file);
146+
$className = Services::locator()->findQualifiedNameFromPath($file);
148147
if (empty($className) || ! class_exists($className))
149148
{
150149
continue;

system/Language/Language.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636
* @filesource
3737
*/
3838

39+
use CodeIgniter\Config\Services;
40+
41+
/**
42+
* Class Language
43+
*
44+
* @package CodeIgniter\Language
45+
*/
3946
class Language
4047
{
4148

@@ -102,6 +109,8 @@ public function setLocale(string $locale = null)
102109
return $this;
103110
}
104111

112+
//--------------------------------------------------------------------
113+
105114
/**
106115
* @return string
107116
*/
@@ -110,6 +119,8 @@ public function getLocale(): string
110119
return $this->locale;
111120
}
112121

122+
//--------------------------------------------------------------------
123+
113124
/**
114125
* Parses the language string for a file, loads the file, if necessary,
115126
* getting the line.
@@ -263,7 +274,7 @@ protected function load(string $file, string $locale, bool $return = false)
263274
*/
264275
protected function requireFile(string $path): array
265276
{
266-
$files = service('locator')->search($path);
277+
$files = Services::locator()->search($path);
267278

268279
$strings = [];
269280

0 commit comments

Comments
 (0)