diff --git a/Module/InstallerAbstract.php b/Module/InstallerAbstract.php index a38e48ac9..c1b030b0c 100644 --- a/Module/InstallerAbstract.php +++ b/Module/InstallerAbstract.php @@ -17,6 +17,8 @@ namespace phpOMS\Module; use phpOMS\DataStorage\Database\DatabaseType; use phpOMS\DataStorage\Database\Pool; +use phpOMS\System\File\Directory; +use phpOMS\System\File\PathException; use phpOMS\System\File\PermissionException; use phpOMS\Utils\Parser\Php\ArrayParser; @@ -153,9 +155,9 @@ class InstallerAbstract $directories = new Directory(ROOT_PATH . '/Modules/' . $info->getDirectory() . '/Admin/Routes'); foreach($directories as $key => $subdir) { - if($subdir instanceOf Directory) { + if($subdir instanceof Directory) { foreach($subdir as $key2 => $file) { - self::installRoutes(ROOT_PATH . '/' . $subdir->getName() . '/' . $file->getName() . '/Routes.php', $file->getPath()); + self::installRoutes(ROOT_PATH . '/' . $subdir->getName() . '/' . basename($file->getName(), '.php') . '/Routes.php', $file->getPath()); } } } @@ -177,7 +179,7 @@ class InstallerAbstract private static function installRoutes(string $destRoutePath, string $srcRoutePath) { if(!file_exists($destRoutePath)) { - mkdir($destRoutePath); + file_put_contents($destRoutePath, 'loadInfo($module); /** @var $class InstallerAbstract */ $class = '\\Modules\\' . $info->getDirectory() . '\\Admin\\Installer'; diff --git a/System/File/Directory.php b/System/File/Directory.php index e25913afd..cbe1e7778 100644 --- a/System/File/Directory.php +++ b/System/File/Directory.php @@ -15,6 +15,7 @@ */ namespace phpOMS\System\File; +use phpOMS\Utils\StringUtils; use phpOMS\Validation\Validator; /** @@ -43,7 +44,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess /** * Direcotry nodes (files and directories). * - * @var string + * @var FileAbstract[] * @since 1.0.0 */ private $nodes = []; @@ -80,7 +81,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess parent::index(); foreach (glob($this->path . DIRECTORY_SEPARATOR . $this->filter) as $filename) { - if(strpos($filename, '.') === false) { + if(!StringUtils::endsWith(trim($filename), '.') ) { $file = is_dir($filename) ? new self($filename) : new File($filename); $this->add($file); @@ -102,7 +103,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess { $this->count += $file->getCount(); $this->size += $file->getSize(); - $this->nodes[$this->getName()] = $file; + $this->nodes[$file->getName()] = $file; return $file->createNode(); } diff --git a/System/File/FileAbstract.php b/System/File/FileAbstract.php index 638762804..96a3a184e 100644 --- a/System/File/FileAbstract.php +++ b/System/File/FileAbstract.php @@ -104,7 +104,7 @@ abstract class FileAbstract */ public function __construct(string $path) { - $this->path = $path; + $this->path = rtrim($path, '/\\'); $this->name = basename($path); $this->createdAt = new \DateTime('now');