From 145fc64b916657c339800c269a01ccb558044b0b Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 12 Jun 2018 20:31:36 -0700 Subject: [PATCH] AfformScanner - Add getMetas() --- ext/afform/CRM/Afform/AfformScanner.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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. -- 2.25.1