3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * The Contact Wrapper is a wrapper class which is called by
30 * contact.module after it parses the menu path.
32 * The key elements of the wrapper are the controller and the
33 * run method as explained below.
36 * @copyright CiviCRM LLC (c) 2004-2019
38 class CRM_Utils_Wrapper
{
43 * The controller which will handle the display and processing of this page.
44 * @var \CRM_Core_Controller_Simple object
46 protected $_controller;
51 * The heart of the callback processing is done by this method.
52 * forms are of different type and have different operations.
54 * @param string $formName name of the form processing this action
55 * @param string $formLabel label for the above form
56 * @param array $arguments
57 * - int mode: mode of operation.
58 * - bool addSequence: should we add a unique sequence number to the end of the key
59 * - bool ignoreKey: should we not set a qfKey for this controller (for standalone forms)
63 public function run($formName, $formLabel = NULL, $arguments = NULL) {
64 if (is_array($arguments)) {
65 $mode = CRM_Utils_Array
::value('mode', $arguments);
66 $imageUpload = !empty($arguments['imageUpload']);
67 $addSequence = !empty($arguments['addSequence']);
68 $attachUpload = !empty($arguments['attachUpload']);
69 $ignoreKey = !empty($arguments['ignoreKey']);
74 $addSequence = $ignoreKey = $imageUpload = $attachUpload = FALSE;
77 $this->_controller
= new CRM_Core_Controller_Simple(
87 if (array_key_exists('urlToSession', $arguments)) {
88 if (is_array($arguments['urlToSession'])) {
89 foreach ($arguments['urlToSession'] as $params) {
90 $urlVar = CRM_Utils_Array
::value('urlVar', $params);
91 $sessionVar = CRM_Utils_Array
::value('sessionVar', $params);
92 $type = CRM_Utils_Array
::value('type', $params);
93 $default = CRM_Utils_Array
::value('default', $params);
94 $abort = CRM_Utils_Array
::value('abort', $params, FALSE);
97 $value = CRM_Utils_Request
::retrieve(
104 $this->_controller
->set($sessionVar, $value);
109 if (array_key_exists('setEmbedded', $arguments)) {
110 $this->_controller
->setEmbedded(TRUE);
113 $this->_controller
->process();
114 return $this->_controller
->run();