* An XML document defining a list of menu items.
* @param array $menu
* An alterable list of menu items.
+ *
+ * @throws CRM_Core_Exception
*/
public static function readXML($xml, &$menu) {
$config = CRM_Core_Config::singleton();
foreach ($xml->item as $item) {
if (!(string ) $item->path) {
CRM_Core_Error::debug('i', $item);
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Unable to read XML file');
}
$path = (string ) $item->path;
$menu[$path] = array();
* @param array $menu
* @param string $path
*
- * @throws Exception
+ * @throws CRM_Core_Exception
*/
public static function fillMenuValues(&$menu, $path) {
$fieldsToPropagate = array(
);
$fieldsPresent = array();
foreach ($fieldsToPropagate as $field) {
- $fieldsPresent[$field] = CRM_Utils_Array::value($field, $menu[$path]) !== NULL ? TRUE : FALSE;
+ $fieldsPresent[$field] = isset($menu[$path][$field]);
}
$args = explode('/', $path);
return;
}
- $messages = array();
+ $messages = [];
foreach ($fieldsToPropagate as $field) {
if (!$fieldsPresent[$field]) {
$messages[] = ts("Could not find %1 in path tree",
- array(1 => $field)
+ [1 => $field]
);
}
}
- CRM_Core_Error::fatal("'$path': " . implode(', ', $messages));
+ throw new CRM_Core_Exception("'$path': " . implode(', ', $messages));
}
/**
$value = array(
'title' => $item['title'],
- 'desc' => CRM_Utils_Array::value('desc', $item),
+ 'desc' => $item['desc'] ?? NULL,
'id' => strtr($item['title'], array(
'(' => '_',
')' => '',
// forceBackend; CRM-14439 work-around; acceptable for now because we don't display breadcrumbs on frontend
TRUE
),
- 'icon' => CRM_Utils_Array::value('icon', $item),
- 'extra' => CRM_Utils_Array::value('extra', $item),
+ 'icon' => $item['icon'] ?? NULL,
+ 'extra' => $item['extra'] ?? NULL,
);
if (!array_key_exists($item['adminGroup'], $values)) {
$values[$item['adminGroup']] = array();
$values[$item['adminGroup']]['fields'] = array();
}
- $weight = CRM_Utils_Array::value('weight', $item, 0);
$values[$item['adminGroup']]['fields']["{weight}.{$item['title']}"] = $value;
$values[$item['adminGroup']]['component_id'] = $item['component_id'];
}
foreach ($values as $group => $dontCare) {
- $values[$group]['perColumn'] = round(count($values[$group]['fields']) / 2);
ksort($values[$group]);
}