<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
*/
/**
- * Implement the "api.reload" option. This option can be used with "create" to
- * force the API to reload a clean copy of the entity before returning the result.
+ * Implement the "reload" option. This option can be used with "create" to force
+ * the API to reload a clean copy of the entity before returning the result.
*
* @code
* $clean = civicrm_api('myentity', 'create', array(
* @endcode
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*/
require_once 'api/Wrapper.php';
+
+/**
+ * Class CRM_Utils_API_ReloadOption
+ */
class CRM_Utils_API_ReloadOption implements API_Wrapper {
/**
*/
public function toApiOutput($apiRequest, $result) {
$reloadMode = NULL;
- if ($apiRequest['action'] === 'create' && isset($apiRequest['params'], $apiRequest['params']['options'], $apiRequest['params']['options']['reload'])) {
+ if ($apiRequest['action'] === 'create' && isset($apiRequest['params'], $apiRequest['params']['options']) && is_array($apiRequest['params']['options']) && isset($apiRequest['params']['options']['reload'])) {
if (!CRM_Utils_Array::value('is_error', $result, FALSE)) {
$reloadMode = $apiRequest['params']['options']['reload'];
}
case NULL:
case '0':
case 'null':
+ case '':
return $result;
case '1':
return $result;
default:
- throw new API_Exception("Unknown reload mode");
+ throw new API_Exception("Unknown reload mode " . $reloadMode);
}
}