typerocket
typerocket copied to clipboard
Unable to set custom handler for post CPT
Hi Kevin,
I've got a CPT called 'car' that has to interoperate with a external service. So I:
- asked galaxy to create the model and the controller with
php galaxy make:model -c post Car - decleared the CPT in my
functions.php:
->setHandler(\App\Controllers\CarController::class);
This is the Car.php:
<?php
namespace App\Models;
use TypeRocket\Models\WPPost;
class Car extends WPPost
{
public const POST_TYPE = 'car';
}
and this the CarController.php:
<?php
namespace App\Controllers;
use App\Models\Car;
use TypeRocket\Controllers\WPPostController;
use TypeRocket\Http\Request;
use TypeRocket\Http\Response;
use TypeRocket\Models\AuthUser;
class CarController extends WPPostController
{
protected $modelClass = Car::class;
public function create(Request $request, Response $response, AuthUser $user) {
// Just to let me know that this has been called
die('called');
}
public function onActionSave($type, Car $car, Request $request) {
// Just to let me know that this has been called
die('action');
}
}
All seems good and I think typerocket should do what I need here but the fact is that my methods are never actually called. Is this scenario supported by typerocket? Am I missing some steps?
Thanks
Edit: I'm running:
- WP 6.0
- PHP 8.1
- TypeRocket v5 installed in mu-plugins