Merge pull request #17770 from civicrm/5.28
[civicrm-core.git] / CRM / Utils / Check / Component / AddressParsing.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17 class CRM_Utils_Check_Component_AddressParsing extends CRM_Utils_Check_Component {
18
19 public static function checkLocaleSupportsAddressParsing() {
20
21 $addressOptions = CRM_Core_BAO_Setting::valueOptions(
22 CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
23 'address_options'
24 );
25
26 $messages = [];
27
28 if ($addressOptions['street_address_parsing']) {
29 if (!CRM_Core_BAO_Address::isSupportedParsingLocale()) {
30 $config = CRM_Core_Config::singleton();
31 $messages[] = new CRM_Utils_Check_Message(
32 __FUNCTION__,
33 ts(
34 '<a href=' .
35 CRM_Utils_System::url('civicrm/admin/setting/preferences/address', 'reset=1') .
36 '">Street address parsing</a> is enabled but not supported by <a href="' .
37 CRM_Utils_System::url('civicrm/admin/setting/localization', 'reset=1') .
38 '">your locale</a> (%1).',
39 [1 => $config->lcMessages]
40 ),
41 ts('Street address parsing'),
42 \Psr\Log\LogLevel::WARNING,
43 'fa-address-card'
44 );
45 }
46 }
47
48 return $messages;
49 }
50
51 }