Commit eec46d06 authored by colemanw's avatar colemanw
Browse files

Api - output module_name & directive_name

parent 1e76a585
......@@ -22,14 +22,27 @@ class Get extends \Civi\Api4\Generic\BasicGetAction {
$toGet = $this->_itemsToGet('name');
$names = $toGet ?? array_keys($scanner->findFilePaths());
// Optimize lookups by module/directive name
if (!$toGet) {
$moduleNames = $this->_itemsToGet('module_name');
$directiveNames = $this->_itemsToGet('directive_name');
}
$values = $this->getAutoGenerated($names, $toGet, $getLayout);
foreach ($names as $name) {
$info = [
'module_name' => _afform_angular_module_name($name, 'camel'),
'directive_name' => _afform_angular_module_name($name, 'dash'),
];
if (($moduleNames && !in_array($info['module_name'], $moduleNames)) || ($directiveNames && !in_array($info['directive_name'], $directiveNames))) {
continue;
}
$record = $scanner->getMeta($name);
if (!$record && !isset($values[$name])) {
continue;
}
$values[$name] = array_merge($values[$name] ?? [], $record ?? []);
$values[$name] = array_merge($values[$name] ?? [], $record ?? [], $info);
if ($getComputed) {
$scanner->addComputedFields($values[$name]);
}
......
......@@ -7,7 +7,7 @@ use Civi\Api4\Generic\BasicBatchAction;
use Civi\Api4\Generic\BasicGetFieldsAction;
/**
* Class Afform
* User-configurable forms
* @package Civi\Api4
*/
class Afform extends AbstractEntity {
......@@ -126,6 +126,12 @@ class Afform extends AbstractEntity {
];
if ($self->getAction() === 'get') {
$fields[] = [
'name' => 'module_name',
];
$fields[] = [
'name' => 'directive_name',
];
$fields[] = [
'name' => 'has_local',
];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment