Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ parameters:
paths:
- src
- tests
level: 6
level: 9
bootstrapFiles:
- vendor/codeigniter4/framework/system/Test/bootstrap.php

6 changes: 5 additions & 1 deletion src/Commands/PageCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ private function createFileFromTemplate(string $templateFile, string $targetFile
return;
}

// Read template content
/**
* Read template content
*
* @var string $content
*/
$content = file_get_contents($templateFile . '.tpl');

// Replace placeholders
Expand Down
11 changes: 10 additions & 1 deletion src/Config/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,21 @@ class Services extends BaseService
public static function router(?RouteCollectionInterface $routes = null, ?Request $request = null, bool $getShared = true)
{
if ($getShared) {
return static::getSharedInstance('router', $routes, $request);
/**
* @var PageRouter $pageRouter
*/
$pageRouter = static::getSharedInstance('router', $routes, $request);

return $pageRouter;
}

$routes ??= AppServices::get('routes');
$request ??= AppServices::get('request');

/**
* @var RouteCollectionInterface $routes
* @var Request $request
*/
return new PageRouter($routes, $request);
}
}
9 changes: 8 additions & 1 deletion src/Helpers/pageview_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
* the LICENSE file that was distributed with this source code.
*/

use CodeIgniter\Autoloader\FileLocatorInterface;
use Config\Services as AppServices;
use Config\View;
use Psr\Log\LoggerInterface;

if (! function_exists('pageView')) {
/**
Expand All @@ -24,7 +26,12 @@ function pageView(string $name, array $data = [], array $options = []): string
$pageViewPath = APPPATH . 'Pages/';

// Create new view instance with custom view path
$renderer = new CodeIgniter\View\View($config, $pageViewPath, AppServices::get('locator'), CI_DEBUG, AppServices::get('logger'));
/** @var FileLocatorInterface $locator */
$locator = AppServices::get('locator');
/** @var LoggerInterface $logger */
$logger = AppServices::get('logger');

$renderer = new CodeIgniter\View\View($config, $pageViewPath, $locator, CI_DEBUG, $logger);

if (array_key_exists('saveData', $options)) {
$saveData = (bool) $options['saveData'];
Expand Down
4 changes: 4 additions & 0 deletions src/PageRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public function handle(?string $uri = null)
try {
$handle = parent::handle($uri);
} catch (PageNotFoundException $e) {
if ($uri === null) {
throw $e;
}

// HACK: Check for page based routes
if ($this->pageBasedRoute($uri)) {
return $this->controllerName();
Expand Down
Loading