Skip to content

Commit

Permalink
API Make the public folder mandatory (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Dec 14, 2022
1 parent 4e2135f commit 86600ce
Showing 1 changed file with 2 additions and 32 deletions.
34 changes: 2 additions & 32 deletions src/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
*/
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 86600ce

Please sign in to comment.