From f36fd0f6ff53cc1683e29ecf8e83be78bd1cfc1e Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 16 Sep 2020 15:53:39 +1200 Subject: [PATCH] [Ref] Separate url path calculation into the relevant classes --- CRM/Event/Form/Participant.php | 67 +++++++++----------------------- CRM/Event/Form/Task/Register.php | 38 ++++++++++++++++++ 2 files changed, 56 insertions(+), 49 deletions(-) diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 5697924b8799..71c3204b8ce7 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -338,55 +338,7 @@ public function preProcess() { return CRM_Event_Form_EventFees::preProcess($this); } - //check the mode when this form is called either single or as - //search task action - if ($this->_single) { - $this->assign('urlPath', 'civicrm/contact/view/participant'); - if (!$this->_id && !$this->_contactId) { - $breadCrumbs = [ - [ - 'title' => ts('CiviEvent Dashboard'), - 'url' => CRM_Utils_System::url('civicrm/event', 'reset=1'), - ], - ]; - - CRM_Utils_System::appendBreadCrumb($breadCrumbs); - } - } - else { - //set the appropriate action - $context = $this->get('context'); - $urlString = 'civicrm/contact/search'; - $this->_action = CRM_Core_Action::BASIC; - switch ($context) { - case 'advanced': - $urlString = 'civicrm/contact/search/advanced'; - $this->_action = CRM_Core_Action::ADVANCED; - break; - - case 'builder': - $urlString = 'civicrm/contact/search/builder'; - $this->_action = CRM_Core_Action::PROFILE; - break; - - case 'basic': - $urlString = 'civicrm/contact/search/basic'; - $this->_action = CRM_Core_Action::BASIC; - break; - - case 'custom': - $urlString = 'civicrm/contact/search/custom'; - $this->_action = CRM_Core_Action::COPY; - break; - } - CRM_Contact_Form_Task::preProcessCommon($this); - - $this->_contactId = NULL; - - //set ajax path, this used for custom data building - $this->assign('urlPath', $urlString); - $this->assign('urlPathVar', "_qf_Participant_display=true&qfKey={$this->controller->_key}"); - } + $this->assignUrlPath(); $this->assign('single', $this->_single); @@ -2329,4 +2281,21 @@ public function getFeeDetails($participantIds, $hasLineItems = FALSE) { return $feeDetails; } + /** + * Assign the url path to the template. + */ + protected function assignUrlPath() { + $this->assign('urlPath', 'civicrm/contact/view/participant'); + if (!$this->_id && !$this->_contactId) { + $breadCrumbs = [ + [ + 'title' => ts('CiviEvent Dashboard'), + 'url' => CRM_Utils_System::url('civicrm/event', 'reset=1'), + ], + ]; + + CRM_Utils_System::appendBreadCrumb($breadCrumbs); + } + } + } diff --git a/CRM/Event/Form/Task/Register.php b/CRM/Event/Form/Task/Register.php index af434f4fd456..b13a5619db24 100644 --- a/CRM/Event/Form/Task/Register.php +++ b/CRM/Event/Form/Task/Register.php @@ -37,4 +37,42 @@ class CRM_Event_Form_Task_Register extends CRM_Event_Form_Participant { */ public $_single = FALSE; + /** + * Assign the url path to the template. + */ + protected function assignUrlPath() { + //set the appropriate action + $context = $this->get('context'); + $urlString = 'civicrm/contact/search'; + $this->_action = CRM_Core_Action::BASIC; + switch ($context) { + case 'advanced': + $urlString = 'civicrm/contact/search/advanced'; + $this->_action = CRM_Core_Action::ADVANCED; + break; + + case 'builder': + $urlString = 'civicrm/contact/search/builder'; + $this->_action = CRM_Core_Action::PROFILE; + break; + + case 'basic': + $urlString = 'civicrm/contact/search/basic'; + $this->_action = CRM_Core_Action::BASIC; + break; + + case 'custom': + $urlString = 'civicrm/contact/search/custom'; + $this->_action = CRM_Core_Action::COPY; + break; + } + CRM_Contact_Form_Task::preProcessCommon($this); + + $this->_contactId = NULL; + + //set ajax path, this used for custom data building + $this->assign('urlPath', $urlString); + $this->assign('urlPathVar', "_qf_Participant_display=true&qfKey={$this->controller->_key}"); + } + }