added api functions

This commit is contained in:
Dennis Eichhorn 2023-07-24 06:01:31 +00:00
parent cb2861eae8
commit e1a508d64e

View File

@ -16,7 +16,7 @@ declare(strict_types=1);
$modules = \scandir(__DIR__ . '/../../Modules');
$allowed = [];
$allowed = ['Billing'];
function createFunction($module, $modelName)
{
@ -127,8 +127,8 @@ function updateFunction($module, $modelName, $helperName = '')
return;
}
/** @var {$helperName} \$old */
\$old = {$modelName}Mapper::get()->where('id', (int) \$request->getData('id'));
/** @var \Modules\\{$module}\Models\\{$modelName} \$old */
\$old = {$modelName}Mapper::get()->where('id', (int) \$request->getData('id'))->execute();
\$new = \$this->update{$modelName}FromRequest(\$request, clone \$old);
\$this->updateModel(\$request->header->account, \$old, \$new, {$modelName}Mapper::class, '{$snakeCase}', \$request->getOrigin());
@ -270,6 +270,11 @@ foreach ($modules as $module) {
continue;
}
// Get might be standalone
if (\strpos($match, 'Get') !== false) {
continue;
}
if (\strpos($match, 'Create') !== false || \strpos($match, 'Add') !== false) {
$create[] = $match;
} elseif (\strpos($match, 'Update') !== false || \strpos($match, 'Change') !== false || \strpos($match, 'Set') !== false) {