Yeah so reading into how to use xdebug this is very much beyond my experience to do correctly. Can we instead please work through how this error could come to be? Like, my current usage of Routing/RouteList is not high in complexity at all, and comparing it versus documentation does not show anything written incorrectly.
Me going down the xdebug avenue really is going to take a huge amount of time (a week or more?) for me to even understand how to use it at all, let alone correctly, or even reach a useful position. I’m not a developer “proper” so this is nowhere near a trivial thing for me to step into (xdebug).
Can we at least start somewhere in the code I have to explore what could be the matter? It seems plenty reasonable to get the expertise of the Concrete Devs who actually wrote this code, instead of me brute-forcing my massive ignorance on the debug tooling alone, let alone the additional massive ignorance on the core Concrete CMS code base.
I guess here’s some starter insights that may or may not be helpful… (this is in a package btw, most of the package stuff is Block Templates):
/controller.php, in the on_start() section:
// Routing, related to RouteList and RouteList.php stuff above
$router = $this->app->make('router');
$list = new RouteList();
$list->loadRoutes($router);
/controller.php, in the root section (before class Controller extends…):
use redacted\redacted\RouteList;
/src/RouteList.php:
<?php
namespace redacted\redacted;
use Concrete\Core\Routing\RouteListInterface;
use Concrete\Core\Routing\Router;
//Temporary maybe lel
use Log;
use redacted\redacted\Tickets\TicketManagementController;
class RouteList implements RouteListInterface
{
public function loadRoutes($router)
{
Log::addInfo('redacted');
$router->post('/api/tickets/applyTicket', [TicketManagementController::class, 'applyTicket']);
}
}
-Template calling the API endpoint:
<form id="redacted" action="/api/tickets/applyTicket" method="post">
/src/Tickets/TicketManagementController.php:
<?php
namespace redacted\redacted\Tickets;
use Concrete\Core\Controller\AbstractController;
use Concrete\Core\Http\Request;
use Concrete\Core\Http\Response;
use Concrete\Core\Http\ResponseFactoryInterface;
use Concrete\Core\User\User;
class TicketManagementController extends AbstractController {
/**
* The currently logged in user.
*/
private User $user;
public function __construct(User $user) {
$this->user = $user;
}
/**
* Applies a ticket to the user provided in the request.
*/
public function applyTicket() {
if (!$this->user === null || !$this->user->isRegistered()) {
// Will redirect the user to the login page, and on successfuly login back to
// where this post came from.
return $this->getResponseFactory()->forbidden($this->getRequest()->getReferer());
}
// Inputs
$ticketid = $this->getRequest()->post('redacted');
$applyRedacted = $this->getRequest()->post('redacted');
$applyRegRecId = $this->getRequest()->post('redacted');
// Fetch
$regRecTargetEntry = Express::getEntry($applyRegRecId);
$modTicket = Express::getEntry($ticketid);
// Update
$modTicket->setAttribute("redacted", false);
$modTicket->setAttribute("redacted", true);
$modTicket->setAttribute("redacted", $applyRedacted);
$modTicket->associateEntries()->setRedacted($regRecTargetEntry);
// Go back to where you came from
return $this->getResponseFactory()->redirect($this->getRequest()->getReferer(), Response::HTTP_FOUND);
}
private function getResponseFactory(): ResponseFactoryInterface {
return $this->app->make(ResponseFactoryInterface::class);
}
}
I think that’s everything relevant?