X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBlock.php;h=c9f81dc82b73fe1c5345b534b20d7b2b1268ce83;hb=17fe106216c69552cfb28c67f945043eae545c4f;hp=68164605735f459d84f0217df0acf840071b68d7;hpb=1e5f06c8283ebad23974bb4c551386278176f004;p=civicrm-core.git diff --git a/CRM/Core/Block.php b/CRM/Core/Block.php index 6816460573..c9f81dc82b 100644 --- a/CRM/Core/Block.php +++ b/CRM/Core/Block.php @@ -185,7 +185,7 @@ class CRM_Core_Block { * One of the class constants (ADD, SEARCH, etc.). * @param string $property * The desired property. - * @param string $value + * @param mixed $value * The value of the desired property. */ public static function setProperty($id, $property, $value) { @@ -326,8 +326,6 @@ class CRM_Core_Block { * Create the list of options to create New objects for the application and format is as a block. */ private static function setTemplateShortcutValues() { - $config = CRM_Core_Config::singleton(); - static $shortCuts = []; if (!($shortCuts)) { @@ -349,14 +347,12 @@ class CRM_Core_Block { $components = CRM_Core_Component::getEnabledComponents(); - if (!empty($config->enableComponents)) { + if ($components) { // check if we can process credit card contribs $newCredit = CRM_Core_Config::isEnabledBackOfficeCreditCardPayments(); - foreach ($components as $componentName => $obj) { - if (in_array($componentName, $config->enableComponents)) { - $obj->creatNewShortcut($shortCuts, $newCredit); - } + foreach ($components as $obj) { + $obj->creatNewShortcut($shortCuts, $newCredit); } } @@ -398,9 +394,6 @@ class CRM_Core_Block { } $values = []; - foreach ($shortCuts as $key => $short) { - $values[$key] = self::setShortCutValues($short); - } // Deprecated hook with typo. Please don't use this! CRM_Utils_Hook::links('create.new.shorcuts', @@ -408,6 +401,13 @@ class CRM_Core_Block { CRM_Core_DAO::$_nullObject, $values ); + if ($values) { + CRM_Core_Error::deprecatedWarning('hook_civicrm_links "create.new.shorcuts" deprecated in favor of "create.new.shortcuts"'); + } + + foreach ($shortCuts as $key => $short) { + $values[$key] = self::setShortCutValues($short); + } // Hook that enables extensions to add user-defined links CRM_Utils_Hook::links('create.new.shortcuts', @@ -417,12 +417,11 @@ class CRM_Core_Block { ); foreach ($values as $key => $val) { - if (!empty($val['title'])) { - $values[$key]['name'] = CRM_Utils_Array::value('name', $val, $val['title']); - } + $values[$key]['name'] = $val['name'] ?? $val['title']; + $values[$key] += ['shortCuts' => []]; } - self::setProperty(self::CREATE_NEW, 'templateValues', array('shortCuts' => $values)); + self::setProperty(self::CREATE_NEW, 'templateValues', ['shortCuts' => $values]); } /**