From b8b55e9bf3a4b0701371e83c65c24b8c2272c3d3 Mon Sep 17 00:00:00 2001 From: Arunas Mazeika Date: Thu, 29 Jun 2023 10:54:11 +0200 Subject: [PATCH] #658 Double check that there's a package --- .../component/koowa/class/locator/plugin.php | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/code/libraries/joomlatools/component/koowa/class/locator/plugin.php b/code/libraries/joomlatools/component/koowa/class/locator/plugin.php index 9f4565430..74c0d274f 100644 --- a/code/libraries/joomlatools/component/koowa/class/locator/plugin.php +++ b/code/libraries/joomlatools/component/koowa/class/locator/plugin.php @@ -49,6 +49,8 @@ class ComKoowaClassLocatorPlugin extends KClassLocatorAbstract */ public function locate($classname, $basepath = null) { + $result = false; + if (substr($classname, 0, 3) === 'Plg') { /* @@ -67,37 +69,38 @@ public function locate($classname, $basepath = null) array_shift($parts); $package = array_shift($parts); - $namespace = ucfirst($package); - if(count($parts)) { - $file = array_pop($parts); - } else { - $file = $package; - } + if ($package) + { + $namespace = ucfirst($package); - //Switch basepath - if(!$this->getNamespace($namespace)) { - $basepath = $this->getNamespace('\\'); - } else { - $basepath = $this->getNamespace($namespace); - } + if(count($parts)) { + $file = array_pop($parts); + } else { + $file = $package; + } - $path = ''; + //Switch basepath + if(!$this->getNamespace($namespace)) { + $basepath = $this->getNamespace('\\'); + } else { + $basepath = $this->getNamespace($namespace); + } - if (!empty($parts)) { - $path = implode('/', $parts) . '/'; - } + $path = ''; - $result = $basepath.'/'.$package.'/'.$path . $file.'.php'; + if (!empty($parts)) { + $path = implode('/', $parts) . '/'; + } - if(!is_file($result)) { - $result = $basepath.'/'.$package.'/'.$path . $file.'/'.$file.'.php'; - } + $result = $basepath.'/'.$package.'/'.$path . $file.'.php'; - return $result; + if(!is_file($result)) { + $result = $basepath.'/'.$package.'/'.$path . $file.'/'.$file.'.php'; + } + } } - return false; - + return $result; } }