- 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.
65 lines
2.2 KiB
PHP
65 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\AnalyticsHub\Controller;
|
|
|
|
use OCP\IRequest;
|
|
use OCP\AppFramework\Controller;
|
|
|
|
/**
|
|
* Admin Settings Controller
|
|
*
|
|
* @NoAdminRequired
|
|
* @NoCSRFRequired
|
|
*/
|
|
class PageController extends Controller {
|
|
|
|
private $appName;
|
|
|
|
public function __construct(string $appName, IRequest $request) {
|
|
parent::__construct($appName, $request);
|
|
$this->appName = $appName;
|
|
}
|
|
|
|
/**
|
|
* Index page - simple render without TemplateResponse
|
|
*
|
|
* @NoAdminRequired
|
|
* @NoCSRFRequired
|
|
*/
|
|
public function index(): void {
|
|
echo '<!DOCTYPE html>';
|
|
echo '<html>';
|
|
echo '<head>';
|
|
echo '<meta charset="UTF-8">';
|
|
echo '<title>Mini-CMO Analytics Hub</title>';
|
|
echo '<style>';
|
|
echo 'body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; padding: 40px; max-width: 800px; margin: 0 auto; }';
|
|
echo 'h1 { color: #0082c9; margin-bottom: 20px; }';
|
|
echo 'p { line-height: 1.6; color: #333; }';
|
|
echo 'strong { color: #0066cc; }';
|
|
echo '.success { background: #d4edda; color: #28a745; padding: 15px; border-radius: 5px; margin: 20px 0; }';
|
|
echo '</style>';
|
|
echo '</head>';
|
|
echo '<body>';
|
|
echo '<h1>✅ Mini-CMO Analytics Hub</h1>';
|
|
echo '<div class="success"><strong>Admin page is working!</strong></div>';
|
|
echo '<p><strong>App Name:</strong> ' . htmlspecialchars($this->appName) . '</p>';
|
|
echo '<p><strong>Status:</strong> Controller successfully loaded and extending proper Controller base class.</p>';
|
|
echo '<hr>';
|
|
echo '<p>✅ <strong>Routing test successful!</strong></p>';
|
|
echo '<p>The app is now working correctly. You can:</p>';
|
|
echo '<ul>';
|
|
echo '<li><strong>Next steps:</strong></li>';
|
|
echo '<li>Replace this simple HTML with proper TemplateResponse</li>';
|
|
echo '<li>Add configuration forms (Google Analytics, Claude API)</li>';
|
|
echo '<li>Add save/load functionality</li>';
|
|
echo '<li>Test end-to-end workflow</li>';
|
|
echo '</ul>';
|
|
echo '</body>';
|
|
echo '</html>';
|
|
exit;
|
|
}
|
|
}
|