No docs yet… but the core SuiteCRM v8 uses the API everywhere, so the trick is to copy existing code from core.
That Github repo was an older solution to use GraphQL before SuiteCRM v8 came out - it is a different GraphQL, I don’t think it’s good to use that, going forward.
I have a barely-working-example I worked on a year ago; I don’t remember anything from it, and if you can’t get it to work, I probably won’t be able to help you. But here it goes:
Create file
extensions/MyProject/core/backend/Process/Service/MyProjectSiteProcessHandler.php
with these contents
<?php
namespace App\Extension\MyProject\core\backend\Process\Service;
use ApiPlatform\Core\Exception\InvalidArgumentException;
use App\Process\Entity\Process;
use App\Process\Service\ProcessHandlerInterface;
use App\Engine\LegacyHandler\LegacyHandler;
use BeanFactory;
class MyProjectSiteProcessHandler extends LegacyHandler implements ProcessHandlerInterface
{
protected const MSG_OPTIONS_NOT_FOUND = 'Process options are not defined';
protected const PROCESS_TYPE = 'myproject-site-process';
/**
* @inheritDoc
*/
public function getProcessType(): string
{
return self::PROCESS_TYPE;
}
/**
* @inheritDoc
*/
public function requiredAuthRole(): string
{
return 'ROLE_USER';
}
/**
* @inheritDoc
*/
public function getHandlerKey(): string
{
return self::PROCESS_TYPE;
}
/**
* @inheritDoc
*/
public function configure(Process $process): void
{
//This process is synchronous
//We aren't going to store a record on db
//thus we will use process type as the id
$process->setId(self::PROCESS_TYPE);
$process->setAsync(false);
}
/**
* @inheritDoc
*/
public function validate(Process $process): void
{
if (empty($process->getOptions())) {
throw new InvalidArgumentException(self::MSG_OPTIONS_NOT_FOUND);
}
$options = $process->getOptions();
if (empty($options['action'])) {
throw new InvalidArgumentException(self::MSG_OPTIONS_NOT_FOUND);
}
if (empty($options['first_name']) || empty($options['last_name']) ) {
throw new InvalidArgumentException(self::MSG_OPTIONS_NOT_FOUND);
}
}
/**
* @inheritDoc
*/
public function run(Process $process)
{
$this->init();
$new = BeanFactory::newBean("Leads");
// might be necessary to call StartLegacyApp to load user, controller etc
$process->setStatus('success');
$process->setMessages([
'LBL_RECOVER_PASSWORD_SUCCESS'
]);
['first_name' => $new->first_name, 'last_name' => $new->last_name] = $process->getOptions();
$ret = $new->save();
$this->close();
}
}
Now, I can’t find any records of how I called that custom API entry-point
But I think this is part of it:
{
"input": {
"type": "myproject-site-process",
"options": {
"action": "create-lead",
"first_name": "Test lead",
"last_name": "From API"
}
}
}
It should create a new Lead with provided data.
I think this doesn’t handle authentication very well, but it’s a start. If you have problems, try calling some API endpoint from Core code until you get things right. For example, the one from Core which I used to copy this one: core/backend/Process/LegacyHandler/ResetPasswordHandler.php