3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2018
35 * This class contains functions for managing extensions
37 class CRM_Core_BAO_Extension
extends CRM_Core_DAO_Extension
{
40 * Fetch object based on array of properties.
42 * @param array $params
43 * (reference ) an assoc array of name/value pairs.
44 * @param array $defaults
45 * (reference ) an assoc array to hold the flattened values.
47 * @return CRM_Core_BAO_LocationType|null
48 * object on success, null otherwise
50 public static function retrieve(&$params, &$defaults) {
51 $extension = new CRM_Core_DAO_Extension();
52 $extension->copyValues($params);
53 if ($extension->find(TRUE)) {
54 CRM_Core_DAO
::storeValues($extension, $defaults);
61 * Delete an extension.
64 * Id of the extension to be deleted.
68 public static function del($id) {
69 $extension = new CRM_Core_DAO_Extension();
71 return $extension->delete();
75 * Change the schema version of an extension.
77 * @param string $fullName
78 * the fully-qualified name (eg "com.example.myextension").
79 * @param string $schemaVersion
81 * @return \CRM_Core_DAO|object
83 public static function setSchemaVersion($fullName, $schemaVersion) {
84 $sql = 'UPDATE civicrm_extension SET schema_version = %1 WHERE full_name = %2';
86 1 => array($schemaVersion, 'String'),
87 2 => array($fullName, 'String'),
89 return CRM_Core_DAO
::executeQuery($sql, $params);
93 * Determine the schema version of an extension.
95 * @param string $fullName
96 * the fully-qualified name (eg "com.example.myextension").
99 public static function getSchemaVersion($fullName) {
100 $sql = 'SELECT schema_version FROM civicrm_extension WHERE full_name = %1';
102 1 => array($fullName, 'String'),
104 return CRM_Core_DAO
::singleValueQuery($sql, $params);