From 86600cead02300885e2020929126a2d95cb246e5 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Wed, 14 Dec 2022 15:44:57 +1300 Subject: [PATCH] API Make the public folder mandatory (#64) --- src/Library.php | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/src/Library.php b/src/Library.php index 175df4c..877b10c 100644 --- a/src/Library.php +++ b/src/Library.php @@ -115,9 +115,7 @@ public function getBasePublicPath() { $projectPath = $this->getBasePath(); $resourceDir = $this->getResourcesDir(); - $publicPath = $this->publicPathExists() - ? Util::joinPaths($projectPath, self::PUBLIC_PATH, $resourceDir) - : Util::joinPaths($projectPath, $resourceDir); + $publicPath = Util::joinPaths($projectPath, self::PUBLIC_PATH, $resourceDir); return $publicPath; } @@ -152,12 +150,6 @@ public function getPublicPath() { $relativePath = $this->getRelativePath(); - // 4.0 compatibility: If there is no public folder, and this is a vendor path, - // remove the leading `vendor` from the destination - if (!$this->publicPathExists() && $this->installedIntoVendor()) { - $relativePath = substr($relativePath ?? '', strlen('vendor/')); - } - return Util::joinPaths($this->getBasePublicPath(), $relativePath); } @@ -189,7 +181,6 @@ protected function getJson() /** * Determine if this module should be exposed. - * Note: If not using public folders, only vendor modules need to be exposed * * @return bool */ @@ -200,8 +191,7 @@ public function requiresExpose() return false; } - // Expose if either public root exists, or vendor module - return $this->publicPathExists() || $this->installedIntoVendor(); + return true; } /** @@ -270,26 +260,6 @@ protected function validateFolder($exposeFolder) return true; } - /** - * Determin eif the public folder exists - * - * @return bool - */ - public function publicPathExists() - { - return is_dir(Util::joinPaths($this->getBasePath(), self::PUBLIC_PATH) ?? ''); - } - - /** - * Check if this module is installed in vendor - * - * @return bool - */ - protected function installedIntoVendor() - { - return preg_match('#^vendor[/\\\\]#', $this->getRelativePath() ?? ''); - } - /** * Determine the name of the folder where vendor module's resources will be exposed. e.g. `_resources` * @throws LogicException