From: Tim Otten Date: Sat, 19 Oct 2019 03:46:17 +0000 (-0700) Subject: 'exports' - Specify symbols in notation more like Angular directives ("A", "AE",... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2331541111c709d5112ea922ffc18cc8171f4140;p=civicrm-core.git 'exports' - Specify symbols in notation more like Angular directives ("A", "AE", etc) --- diff --git a/ext/afform/core/afform.php b/ext/afform/core/afform.php index 167af68d67..735b678c19 100644 --- a/ext/afform/core/afform.php +++ b/ext/afform/core/afform.php @@ -174,9 +174,7 @@ function afform_civicrm_angularModules(&$angularModules) { 'requires' => $meta['requires'], 'basePages' => [], 'exports' => [ - // Each afform is an attribute and an element. - 'el' => [_afform_angular_module_name($name, 'dash')], - 'attr' => [_afform_angular_module_name($name, 'dash')], + _afform_angular_module_name($name, 'dash') => 'AE', ], ]; @@ -268,20 +266,31 @@ function _afform_civicrm_angularModules_autoReq($e) { * 'el': array(string $elementName => string $angModuleName) */ function _afform_reverse_deps($angularModules) { - $revMap = []; - foreach (['attr', 'el'] as $exportType) { - $revMap[$exportType] = []; - foreach (array_keys($angularModules) as $module) { - if (isset($angularModules[$module]['exports'][$exportType])) { - foreach ($angularModules[$module]['exports'][$exportType] as $exportItem) { - $revMap[$exportType][$exportItem] = $module; - } + $revMap = ['attr' => [], 'el' => []]; + foreach (array_keys($angularModules) as $module) { + if (!isset($angularModules[$module]['exports'])) { + continue; + } + foreach ($angularModules[$module]['exports'] as $symbolName => $symbolTypes) { + if (strpos($symbolTypes, 'A') !== FALSE) { + $revMap['attr'][$symbolName] = $module; + } + if (strpos($symbolTypes, 'E') !== FALSE) { + $revMap['el'][$symbolName] = $module; } } } return $revMap; } +/** + * @param string $formName + * @param string $html + * @param array $revMap + * The reverse-dependencies map from _afform_reverse_deps(). + * @return array + * @see _afform_reverse_deps() + */ function _afform_reverse_deps_find($formName, $html, $revMap) { $symbols = \Civi\Afform\Symbols::scan($html); $elems = array_intersect_key($revMap['el'], $symbols->elements); diff --git a/ext/afform/core/ang/af.ang.php b/ext/afform/core/ang/af.ang.php index 68c9067849..a97b538142 100644 --- a/ext/afform/core/ang/af.ang.php +++ b/ext/afform/core/ang/af.ang.php @@ -15,7 +15,8 @@ return [ 'settings' => [], 'basePages' => [], 'exports' => [ - 'el' => ['af-entity', 'af-fieldset', 'af-form'], - 'attr' => ['af-entity', 'af-fieldset', 'af-form'], + 'af-entity' => 'AE', + 'af-fieldset' => 'AE', + 'af-form' => 'AE', ], ]; diff --git a/ext/afform/core/ang/afBlock.ang.php b/ext/afform/core/ang/afBlock.ang.php index af988bb723..ccf473bb1f 100644 --- a/ext/afform/core/ang/afBlock.ang.php +++ b/ext/afform/core/ang/afBlock.ang.php @@ -18,7 +18,7 @@ return [ 'settings' => [], 'basePages' => [], 'exports' => [ - 'el' => ['af-block-contact-name', 'af-block-contact-email'], - 'attr' => ['af-block-contact-name', 'af-block-contact-email'], + 'af-block-contact-name' => 'AE', + 'af-block-contact-email' => 'AE', ], ]; diff --git a/ext/afform/core/ang/afField.ang.php b/ext/afform/core/ang/afField.ang.php index ac52351553..a50114e60d 100644 --- a/ext/afform/core/ang/afField.ang.php +++ b/ext/afform/core/ang/afField.ang.php @@ -18,7 +18,6 @@ return [ 'settings' => [], 'basePages' => [], 'exports' => [ - 'el' => ['af-field'], - 'attr' => ['af-field'], + 'af-field' => 'AE', ], ]; diff --git a/ext/afform/html/ang/afMoncao.ang.php b/ext/afform/html/ang/afMoncao.ang.php index d394532c1f..81e069f248 100644 --- a/ext/afform/html/ang/afMoncao.ang.php +++ b/ext/afform/html/ang/afMoncao.ang.php @@ -20,6 +20,6 @@ return array( ], 'basePages' => [], 'exports' => [ - 'attr' => ['af-monaco'], + 'af-monaco' => 'A', ], );