Fix: Make PageController extend OCP\AppFramework\Controller
- Added parent::__construct() call to PageController - Fixes: "must be an instance of OCP\AppFramework\Controller" - Error: Argument 1 passed to Dispatcher was PageController, not Controller - This is the CRITICAL fix for controller DI in Nextcloud - PageController now properly extends OCP\AppFramework\Controller - Maintains simple HTML output for testing The error showed the controller wasn't properly extending the base class. Nextcloud's Dispatcher requires all controllers to extend OCP\AppFramework\Controller.
This commit is contained in:
BIN
analyticshub.zip
BIN
analyticshub.zip
Binary file not shown.
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace OCA\AnalyticsHub\Controller;
|
namespace OCA\AnalyticsHub\Controller;
|
||||||
|
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
|
use OCP\AppFramework\Controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Admin Settings Controller
|
* Admin Settings Controller
|
||||||
@@ -12,14 +13,13 @@ use OCP\IRequest;
|
|||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*/
|
*/
|
||||||
class PageController {
|
class PageController extends Controller {
|
||||||
|
|
||||||
private $appName;
|
private $appName;
|
||||||
private $request;
|
|
||||||
|
|
||||||
public function __construct(string $appName, IRequest $request) {
|
public function __construct(string $appName, IRequest $request) {
|
||||||
|
parent::__construct($appName, $request);
|
||||||
$this->appName = $appName;
|
$this->appName = $appName;
|
||||||
$this->request = $request;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,19 +39,19 @@ class PageController {
|
|||||||
echo 'h1 { color: #0082c9; margin-bottom: 20px; }';
|
echo 'h1 { color: #0082c9; margin-bottom: 20px; }';
|
||||||
echo 'p { line-height: 1.6; color: #333; }';
|
echo 'p { line-height: 1.6; color: #333; }';
|
||||||
echo 'strong { color: #0066cc; }';
|
echo 'strong { color: #0066cc; }';
|
||||||
echo '.success { color: #28a745; background: #d4edda; padding: 10px; border-radius: 5px; margin: 20px 0; }';
|
echo '.success { background: #d4edda; color: #28a745; padding: 15px; border-radius: 5px; margin: 20px 0; }';
|
||||||
echo '</style>';
|
echo '</style>';
|
||||||
echo '</head>';
|
echo '</head>';
|
||||||
echo '<body>';
|
echo '<body>';
|
||||||
echo '<h1>✅ Mini-CMO Analytics Hub</h1>';
|
echo '<h1>✅ Mini-CMO Analytics Hub</h1>';
|
||||||
echo '<div class="success"><strong>Admin page is working!</strong></div>';
|
echo '<div class="success"><strong>Admin page is working!</strong></div>';
|
||||||
echo '<p><strong>App Name:</strong> ' . htmlspecialchars($this->appName) . '</p>';
|
echo '<p><strong>App Name:</strong> ' . htmlspecialchars($this->appName) . '</p>';
|
||||||
echo '<p><strong>Request Path:</strong> ' . htmlspecialchars($this->request->getPathInfo()) . '</p>';
|
echo '<p><strong>Status:</strong> Controller successfully loaded and extending proper Controller base class.</p>';
|
||||||
echo '<p><strong>Status:</strong> Controller successfully resolved and executed.</p>';
|
|
||||||
echo '<hr>';
|
echo '<hr>';
|
||||||
echo '<p>The app routing is now working correctly. You can now build the full admin UI with TemplateResponse, forms, and all the features.</p>';
|
echo '<p>✅ <strong>Routing test successful!</strong></p>';
|
||||||
echo '<p>Next steps:</p>';
|
echo '<p>The app is now working correctly. You can:</p>';
|
||||||
echo '<ul>';
|
echo '<ul>';
|
||||||
|
echo '<li><strong>Next steps:</strong></li>';
|
||||||
echo '<li>Replace this simple HTML with proper TemplateResponse</li>';
|
echo '<li>Replace this simple HTML with proper TemplateResponse</li>';
|
||||||
echo '<li>Add configuration forms (Google Analytics, Claude API)</li>';
|
echo '<li>Add configuration forms (Google Analytics, Claude API)</li>';
|
||||||
echo '<li>Add save/load functionality</li>';
|
echo '<li>Add save/load functionality</li>';
|
||||||
|
|||||||
Reference in New Issue
Block a user