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 { ...@@ -22,14 +22,27 @@ class Get extends \Civi\Api4\Generic\BasicGetAction {
$toGet = $this->_itemsToGet('name'); $toGet = $this->_itemsToGet('name');
$names = $toGet ?? array_keys($scanner->findFilePaths()); $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); $values = $this->getAutoGenerated($names, $toGet, $getLayout);
foreach ($names as $name) { 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); $record = $scanner->getMeta($name);
if (!$record && !isset($values[$name])) { if (!$record && !isset($values[$name])) {
continue; continue;
} }
$values[$name] = array_merge($values[$name] ?? [], $record ?? []); $values[$name] = array_merge($values[$name] ?? [], $record ?? [], $info);
if ($getComputed) { if ($getComputed) {
$scanner->addComputedFields($values[$name]); $scanner->addComputedFields($values[$name]);
} }
......
...@@ -7,7 +7,7 @@ use Civi\Api4\Generic\BasicBatchAction; ...@@ -7,7 +7,7 @@ use Civi\Api4\Generic\BasicBatchAction;
use Civi\Api4\Generic\BasicGetFieldsAction; use Civi\Api4\Generic\BasicGetFieldsAction;
/** /**
* Class Afform * User-configurable forms
* @package Civi\Api4 * @package Civi\Api4
*/ */
class Afform extends AbstractEntity { class Afform extends AbstractEntity {
...@@ -126,6 +126,12 @@ class Afform extends AbstractEntity { ...@@ -126,6 +126,12 @@ class Afform extends AbstractEntity {
]; ];
if ($self->getAction() === 'get') { if ($self->getAction() === 'get') {
$fields[] = [
'name' => 'module_name',
];
$fields[] = [
'name' => 'directive_name',
];
$fields[] = [ $fields[] = [
'name' => 'has_local', '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