From: Tim Otten Date: Wed, 13 Jun 2018 03:31:36 +0000 (-0700) Subject: AfformScanner - Add getMetas() X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=145fc64b916657c339800c269a01ccb558044b0b;p=civicrm-core.git AfformScanner - Add getMetas() --- diff --git a/ext/afform/CRM/Afform/AfformScanner.php b/ext/afform/CRM/Afform/AfformScanner.php index b6bf50a4c8..03cc44642d 100644 --- a/ext/afform/CRM/Afform/AfformScanner.php +++ b/ext/afform/CRM/Afform/AfformScanner.php @@ -31,6 +31,8 @@ class CRM_Afform_AfformScanner { } /** + * Get a list of all forms and their file paths. + * * @return array * Ex: ['view-individual' => ['/var/www/foo/afform/view-individual']] */ @@ -108,7 +110,8 @@ class CRM_Afform_AfformScanner { * @param string $name * Ex: 'view-individual' * @return array - * An array with some mix of the following keys: name, title, description, client_route, server_route, requires + * An array with some mix of the following keys: name, title, description, client_route, server_route, requires. + * NOTE: This is only data available in meta.json. It does *NOT* include layout. * Ex: [ * 'name' => 'view-individual', * 'title' => 'View an individual contact', @@ -133,6 +136,22 @@ class CRM_Afform_AfformScanner { return array_merge($defaults, json_decode(file_get_contents($metaFile), 1)); } + /** + * Get the effective metadata for all forms. + * + * @return array + * A list of all forms, keyed by form name. + * NOTE: This is only data available in meta.json. It does *NOT* include layout. + * Ex: ['view-individual' => ['title' => 'View an individual contact', ...]] + */ + public function getMetas() { + $result = array(); + foreach (array_keys($this->findFilePaths()) as $name) { + $result[$name] = $this->getMeta($name); + } + return $result; + } + /** * @param array $formPaths * List of all form paths.