diff --git a/CRM/Utils/Check/Component/Env.php b/CRM/Utils/Check/Component/Env.php index 2ac6246f6f2f..f0a88a71624a 100644 --- a/CRM/Utils/Check/Component/Env.php +++ b/CRM/Utils/Check/Component/Env.php @@ -1106,4 +1106,25 @@ public function checkPHPIntlExists() { return $messages; } + public function checkAngularModuleSettings() { + $messages = []; + $modules = Civi::container()->get('angular')->getModules(); + foreach ($modules as $name => $module) { + if (!empty($module['settings'])) { + $messages[] = new CRM_Utils_Check_Message( + __FUNCTION__ . $name, + ts('The Angular file "%1" from extension "%2" must be updated to use "settingsFactory" instead of "settings". Developer info...', [ + 1 => $name, + 2 => $module['ext'], + 3 => 'target="_blank" href="https://github.com/civicrm/civicrm-core/pull/19052"', + ]), + ts('Unsupported Angular Setting'), + \Psr\Log\LogLevel::WARNING, + 'fa-code' + ); + } + } + return $messages; + } + } diff --git a/Civi/Angular/Manager.php b/Civi/Angular/Manager.php index 9daf7ca62223..1a382743cb9d 100644 --- a/Civi/Angular/Manager.php +++ b/Civi/Angular/Manager.php @@ -135,6 +135,9 @@ public function getModules() { foreach ($angularModules as $module => $info) { // Merge in defaults $angularModules[$module] += ['basePages' => ['civicrm/a']]; + if (!empty($info['settings'])) { + \CRM_Core_Error::deprecatedWarning('Angular "settings" is not supported. See https://github.com/civicrm/civicrm-core/pull/19052'); + } // Validate settingsFactory callables if (isset($info['settingsFactory'])) { // To keep the cache small, we want `settingsFactory` to contain the string names of class & function, not an object diff --git a/tests/phpunit/Civi/Angular/ManagerTest.php b/tests/phpunit/Civi/Angular/ManagerTest.php index a7c69be7dd4a..39d523350248 100644 --- a/tests/phpunit/Civi/Angular/ManagerTest.php +++ b/tests/phpunit/Civi/Angular/ManagerTest.php @@ -47,7 +47,6 @@ public function testGetModules(): void { 'js' => 0, 'css' => 0, 'partials' => 0, - 'settings' => 0, 'settingsFactory' => 0, ]; @@ -75,12 +74,7 @@ public function testGetModules(): void { $counts['partials']++; } } - if (isset($module['settings'])) { - $this->assertTrue(is_array($module['settings'])); - foreach ($module['settings'] as $name => $value) { - $counts['settings']++; - } - } + $this->assertArrayNotHasKey('settings', $module); if (isset($module['settingsFactory'])) { $this->assertTrue(is_callable($module['settingsFactory'])); $counts['settingsFactory']++; @@ -91,7 +85,6 @@ public function testGetModules(): void { $this->assertTrue($counts['css'] > 0, 'Expect to find at least one CSS file'); $this->assertTrue($counts['partials'] > 0, 'Expect to find at least one partial HTML file'); $this->assertTrue($counts['settingsFactory'] > 0, 'Expect to find at least one settingsFactory'); - $this->assertEquals(0, $counts['settings'], 'Angular settings are deprecated in favor of settingsFactory'); } /**