2021-04-30 23:59:53 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace CommonConnectorTools;
|
2021-06-01 07:48:06 +02:00
|
|
|
use Cake\ORM\Locator\LocatorAwareTrait;
|
2021-04-30 23:59:53 +02:00
|
|
|
|
|
|
|
class CommonConnectorTools
|
|
|
|
{
|
|
|
|
public $description = '';
|
|
|
|
public $name = '';
|
|
|
|
public $exposedFunctions = [
|
|
|
|
'diagnostics'
|
|
|
|
];
|
|
|
|
public $version = '???';
|
|
|
|
|
|
|
|
public function addExposedFunction(string $functionName): void
|
|
|
|
{
|
|
|
|
$this->exposedFunctions[] = $functionName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function runAction($action, $params) {
|
|
|
|
if (!in_array($action, $exposedFunctions)) {
|
|
|
|
throw new MethodNotAllowedException(__('Invalid connector function called.'));
|
|
|
|
}
|
|
|
|
return $this->{$action}($params);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function health(Object $connection): array
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2021-06-01 07:48:06 +02:00
|
|
|
|
|
|
|
public function captureOrganisation($input): bool
|
|
|
|
{
|
|
|
|
if (empty($input['uuid'])) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$organisations = \Cake\ORM\TableRegistry::getTableLocator()->get('Organisations');
|
|
|
|
$organisations->captureOrg($input);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function captureSharingGroup($input): bool
|
|
|
|
{
|
|
|
|
if (empty($input['uuid'])) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$sharing_groups = \Cake\ORM\TableRegistry::getTableLocator()->get('SharingGroups');
|
|
|
|
$sharing_groups->captureSharingGroup($input);
|
|
|
|
return true;
|
|
|
|
}
|
2021-04-30 23:59:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|