3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class contains functions for managing extensions
21 class CRM_Core_BAO_Extension
extends CRM_Core_DAO_Extension
{
24 * Fetch object based on array of properties.
26 * @param array $params
27 * (reference ) an assoc array of name/value pairs.
28 * @param array $defaults
29 * (reference ) an assoc array to hold the flattened values.
31 * @return CRM_Core_BAO_LocationType|null
32 * object on success, null otherwise
34 public static function retrieve(&$params, &$defaults) {
35 $extension = new CRM_Core_DAO_Extension();
36 $extension->copyValues($params);
37 if ($extension->find(TRUE)) {
38 CRM_Core_DAO
::storeValues($extension, $defaults);
45 * Delete an extension.
48 * Id of the extension to be deleted.
52 public static function del($id) {
53 $extension = new CRM_Core_DAO_Extension();
55 return $extension->delete();
59 * Change the schema version of an extension.
61 * @param string $fullName
62 * the fully-qualified name (eg "com.example.myextension").
63 * @param string $schemaVersion
65 * @return \CRM_Core_DAO|object
67 public static function setSchemaVersion($fullName, $schemaVersion) {
68 $sql = 'UPDATE civicrm_extension SET schema_version = %1 WHERE full_name = %2';
70 1 => [$schemaVersion, 'String'],
71 2 => [$fullName, 'String'],
73 return CRM_Core_DAO
::executeQuery($sql, $params);
77 * Determine the schema version of an extension.
79 * @param string $fullName
80 * the fully-qualified name (eg "com.example.myextension").
83 public static function getSchemaVersion($fullName) {
84 $sql = 'SELECT schema_version FROM civicrm_extension WHERE full_name = %1';
86 1 => [$fullName, 'String'],
88 return CRM_Core_DAO
::singleValueQuery($sql, $params);