Skip to content

Commit e6c8aae

Browse files
authored
[9.x] Use standard path helper for Application::langPath() (#40274)
* [9.x] Use standard path helper for Application::langPath() Signed-off-by: Mior Muhammad Zaki <[email protected]> * Utilise `useLangPath()` instead of trying to resolve `is_dir()` on each method call. Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]>
1 parent b87ff62 commit e6c8aae

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Illuminate/Foundation/Application.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,20 @@ protected function bindPathsInContainer()
313313
{
314314
$this->instance('path', $this->path());
315315
$this->instance('path.base', $this->basePath());
316-
$this->instance('path.lang', $this->langPath());
317316
$this->instance('path.config', $this->configPath());
318317
$this->instance('path.public', $this->publicPath());
319318
$this->instance('path.storage', $this->storagePath());
320319
$this->instance('path.database', $this->databasePath());
321320
$this->instance('path.resources', $this->resourcePath());
322321
$this->instance('path.bootstrap', $this->bootstrapPath());
322+
323+
$this->useLangPath(value(function () {
324+
if (is_dir($directory = $this->resourcePath('lang'))) {
325+
return $directory;
326+
}
327+
328+
return $this->basePath('lang');
329+
}));
323330
}
324331

325332
/**
@@ -412,19 +419,12 @@ public function useDatabasePath($path)
412419
/**
413420
* Get the path to the language files.
414421
*
422+
* @param string $path
415423
* @return string
416424
*/
417-
public function langPath()
425+
public function langPath($path = '')
418426
{
419-
if ($this->langPath) {
420-
return $this->langPath;
421-
}
422-
423-
if (is_dir($path = $this->resourcePath().DIRECTORY_SEPARATOR.'lang')) {
424-
return $path;
425-
}
426-
427-
return $this->basePath().DIRECTORY_SEPARATOR.'lang';
427+
return $this->langPath.($path ? DIRECTORY_SEPARATOR.$path : '');
428428
}
429429

430430
/**

src/Illuminate/Foundation/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ function logger($message = null, array $context = [])
492492
*/
493493
function lang_path($path = '')
494494
{
495-
return app('path.lang').($path ? DIRECTORY_SEPARATOR.$path : $path);
495+
return app()->langPath($path);
496496
}
497497
}
498498

0 commit comments

Comments
 (0)