Skip to content

Commit 9279e2d

Browse files
committed
Bugfix for subdirectory controllers; check for nonexistant files
1 parent 6871e6f commit 9279e2d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ Install easily via Composer to take advantage of CodeIgniter 4's autoloading cap
1818
and always be up-to-date:
1919
* `> composer require tatter/assets`
2020

21-
Or, install manually by downloading the source files and copying them into CodeIgniter 4's
22-
app/ same subdirectories.
21+
Or, install manually by downloading the source files and adding the directory to
22+
`app/Config/Autoload.php`.
2323

2424
## Configuration (optional)
2525

src/Assets.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ public function displayFile(string $file)
8484
protected function tag(string $file)
8585
{
8686
$path = $this->config->fileBase . $file;
87+
if (! is_file($path))
88+
return false;
8789

8890
// get file extension
8991
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
@@ -125,11 +127,11 @@ protected function routed($extension)
125127

126128
// get the controller (controllerName less its namespace)
127129
// accounts for default route and subdirectories
128-
$controller = str_replace([$routes->getDefaultNamespace(), '\\'], '', $router->controllerName());
130+
$controller = str_replace($routes->getDefaultNamespace(), '', $router->controllerName());
129131

130132
// start the route from the controller
131-
$segments = explode(PATH_SEPARATOR, $controller);
132-
133+
$segments = explode('\\', $controller);
134+
133135
// add the method
134136
$segments[] = $router->methodName();
135137

0 commit comments

Comments
 (0)