Search ext: Rework URL routing in preparation for search display management
[civicrm-core.git] / ext / search / search.php
index 7c7f9e1a83eac1135efa45bcabc5d0656253956c..45b79b6aa2087fa8ca0d433e8893f5dddc5dea59 100644 (file)
@@ -121,8 +121,23 @@ function search_civicrm_entityTypes(&$entityTypes) {
 }
 
 /**
- * Implements hook_civicrm_thems().
+ * Implements hook_civicrm_themes().
  */
 function search_civicrm_themes(&$themes) {
   _search_civix_civicrm_themes($themes);
 }
+
+/**
+ * Implements hook_civicrm_pre().
+ */
+function search_civicrm_pre($op, $entity, $id, &$params) {
+  // Supply default name/label when creating new SearchDisplay
+  if ($entity === 'SearchDisplay' && $op === 'create') {
+    if (empty($params['label'])) {
+      $params['label'] = $params['name'];
+    }
+    elseif (empty($params['name'])) {
+      $params['name'] = \CRM_Utils_String::munge($params['label']);
+    }
+  }
+}