Merge pull request #15921 from civicrm/5.20
[civicrm-core.git] / CRM / Core / QuickForm / Action / Reload.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 * Define the reload action. Reload the page but do not do any validation.
14 * This help with actions where we might want hooks to process some data
15 * but not validate all the fields. Was incorporated to improve the discount
16 * module integration.
17 *
18 * @package CRM
19 * @copyright CiviCRM LLC https://civicrm.org/licensing
20 */
21 class CRM_Core_QuickForm_Action_Reload extends CRM_Core_QuickForm_Action {
22
23 /**
24 * Class constructor.
25 *
26 * @param object $stateMachine
27 * Reference to state machine object.
28 *
29 * @return \CRM_Core_QuickForm_Action_Reload
30 */
31 public function __construct(&$stateMachine) {
32 parent::__construct($stateMachine);
33 }
34
35 /**
36 * Processes the request.
37 *
38 * @param CRM_Core_Form $page
39 * CRM_Core_Form the current form-page.
40 * @param string $actionName
41 * Current action name, as one Action object can serve multiple actions.
42 *
43 * @return object|void
44 */
45 public function perform(&$page, $actionName) {
46 // save the form values and validation status to the session
47 $page->isFormBuilt() or $page->buildForm();
48
49 $pageName = $page->getAttribute('name');
50 $data = &$page->controller->container();
51 $data['values'][$pageName] = $page->exportValues();
52
53 return $page->handle('display');
54 }
55
56 }