Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Undefined variable $directories' when directory does not exist #1752

Closed
Subtixx opened this issue Feb 29, 2024 · 0 comments
Closed

'Undefined variable $directories' when directory does not exist #1752

Subtixx opened this issue Feb 29, 2024 · 0 comments

Comments

@Subtixx
Copy link
Contributor

Subtixx commented Feb 29, 2024

$path = $module->getPath() . '/Resources/lang';
if (is_dir($path)) {
$directories = $this->laravel['files']->directories($path);
$directories = array_map(function ($directory) use ($moduleName) {
return [
'name' => basename($directory),
'module' => $moduleName,
'path' => $directory,
'files' => array_map(function ($file) {
return basename($file);
}, \File::glob($directory . DIRECTORY_SEPARATOR . "*")),
];
}, $directories);
}
if (count($directories) == 0) {

If the path "Resources/lang" does not exist the command fails with an "ErrorException" because the $directories variable not exists.

Also why is it hardcoded to "Resources/lang"? When the directory created "resources" is?

$this->langPath = DIRECTORY_SEPARATOR . config('modules.paths.generator.lang.path', 'Resources/lang');

dcblogdev added a commit that referenced this issue Mar 12, 2024
Fix Issue #1752 - Hardcoded string + undefined variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant