[REF] - Deprecate & delegate BAO::retrieve
[civicrm-core.git] / CRM / Core / BAO / Extension.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
19 * This class contains functions for managing extensions
20 */
21class CRM_Core_BAO_Extension extends CRM_Core_DAO_Extension {
22
23 /**
4f940304 24 * Retrieve DB object and copy to defaults array.
6a488035 25 *
6a0b768e 26 * @param array $params
4f940304 27 * Array of criteria values.
6a0b768e 28 * @param array $defaults
4f940304 29 * Array to be populated with found values.
6a488035 30 *
4f940304
CW
31 * @return self|null
32 * The DAO object, if found.
33 *
34 * @deprecated
6a488035 35 */
4f940304
CW
36 public static function retrieve($params, &$defaults) {
37 return self::commonRetrieve(self::class, $params, $defaults);
6a488035
TO
38 }
39
40 /**
fe482240 41 * Delete an extension.
6a488035 42 *
6a0b768e
TO
43 * @param int $id
44 * Id of the extension to be deleted.
6a488035 45 *
192d36c5 46 * @return mixed
6a488035 47 */
00be9182 48 public static function del($id) {
6a488035
TO
49 $extension = new CRM_Core_DAO_Extension();
50 $extension->id = $id;
51 return $extension->delete();
52 }
53
54 /**
fe482240 55 * Change the schema version of an extension.
6a488035 56 *
5a4f6742
CW
57 * @param string $fullName
58 * the fully-qualified name (eg "com.example.myextension").
59 * @param string $schemaVersion
192d36c5 60 *
61 * @return \CRM_Core_DAO|object
6a488035 62 */
00be9182 63 public static function setSchemaVersion($fullName, $schemaVersion) {
6a488035 64 $sql = 'UPDATE civicrm_extension SET schema_version = %1 WHERE full_name = %2';
be2fb01f
CW
65 $params = [
66 1 => [$schemaVersion, 'String'],
67 2 => [$fullName, 'String'],
68 ];
6a488035
TO
69 return CRM_Core_DAO::executeQuery($sql, $params);
70 }
71
72 /**
fe482240 73 * Determine the schema version of an extension.
6a488035 74 *
5a4f6742
CW
75 * @param string $fullName
76 * the fully-qualified name (eg "com.example.myextension").
6a488035
TO
77 * @return string
78 */
00be9182 79 public static function getSchemaVersion($fullName) {
6a488035 80 $sql = 'SELECT schema_version FROM civicrm_extension WHERE full_name = %1';
be2fb01f
CW
81 $params = [
82 1 => [$fullName, 'String'],
83 ];
6a488035
TO
84 return CRM_Core_DAO::singleValueQuery($sql, $params);
85 }
86
87}