Documentation

CRM_Moduleupgtest_Upgrader extends CRM_Extension_Upgrader_Base
in package

Base class which provides helpers to execute upgrade logic.

Table of Contents

Properties

$ctx  : CRM_Queue_TaskContext
$extensionDir  : string
$extensionName  : string
$queue  : CRM_Queue_Queue
$revisions  : array<string|int, mixed>
$revisionStorageIsDeprecated  : bool

Methods

_queueAdapter()  : mixed
Adapter that lets you add normal (non-static) member functions to the queue.
addColumn()  : bool
Add a column to a table if it doesn't already exist
addIndex()  : bool
Add an index to one or more columns.
addTask()  : mixed
disable()  : mixed
Implements civicrm_disable
dropColumn()  : bool
Drop a column from a table if it exists.
dropIndex()  : bool
Drop index from a table if it exists.
enable()  : mixed
Implements civicrm_enable
enqueuePendingRevisions()  : mixed
Add any pending revisions to the queue.
executeCustomDataFile()  : bool
Run a CustomData file.
executeSql()  : bool
Run one SQL query.
executeSqlFile()  : bool
Run a SQL file.
executeSqlTemplate()  : bool
Run the sql commands in the specified file.
getCurrentRevision()  : mixed
getExtensionDir()  : string
getExtensionKey()  : string
getQueue()  : CRM_Queue_Queue
getRevisions()  : array<string|int, mixed>
Get a list of revisions.
hasPendingRevisions()  : bool
Determine if there are any pending revisions.
init()  : mixed
{@inheritDoc}
install()  : mixed
Implements civicrm_install
notify()  : mixed
Notify the upgrader about a key lifecycle event, such as installation or uninstallation.
onDisable()  : mixed
onEnable()  : mixed
onInstall()  : mixed
Run early installation steps. Ex: Create new MySQL table.
onPostInstall()  : mixed
Run later installation steps. Ex: Call a bespoke API-job for the first time.
onPreInstall()  : void
Run pre-installation steps. Ex: Validate system environment
onUninstall()  : mixed
onUpgrade()  : mixed
postInstall()  : mixed
Implements civicrm_postInstall
prependTask()  : mixed
Enqueue a task based on a method in this class.
setCurrentRevision()  : mixed
setQueue()  : void
uninstall()  : mixed
Implements civicrm_uninstall
appendTask()  : mixed
Enqueue a task based on a method in this class.
executeCustomDataFileByAbsPath()  : bool
Run a CustomData file
deleteDeprecatedRevision()  : mixed
getCurrentRevisionDeprecated()  : mixed

Properties

$extensionDir

protected string $extensionDir

full path to the extension's source tree

$extensionName

protected string $extensionName

eg 'com.example.myextension'

$revisions

private array<string|int, mixed> $revisions

sorted numerically

$revisionStorageIsDeprecated

private bool $revisionStorageIsDeprecated = \FALSE

Flag to clean up extension revision data in civicrm_setting

Methods

_queueAdapter()

Adapter that lets you add normal (non-static) member functions to the queue.

public static _queueAdapter(CRM_Queue_TaskContext $ctx, string $extensionKey, string $method, mixed ...$args) : mixed

While working through a task-queue, the _queueAdapter is called statically. It looks up the appropriate object and invokes the expected method.

CRM_Extension_Upgrader::_queueAdapter($ctx, 'org.example.myext', 'methodName', 'arg1', 'arg2');
Parameters
$ctx : CRM_Queue_TaskContext
$extensionKey : string
$method : string
$args : mixed

addColumn()

Add a column to a table if it doesn't already exist

public static addColumn(string $table, string $column, string $properties) : bool
Parameters
$table : string
$column : string
$properties : string
Return values
bool

addIndex()

Add an index to one or more columns.

public static addIndex(string $table, string|array<string|int, mixed> $columns[, string $prefix = 'index' ]) : bool
Parameters
$table : string
$columns : string|array<string|int, mixed>
$prefix : string = 'index'
Return values
bool

addTask()

public addTask(string $title, string $funcName, mixed ...$options) : mixed
Parameters
$title : string
$funcName : string
$options : mixed

disable()

Implements civicrm_disable

public disable() : mixed

dropColumn()

Drop a column from a table if it exists.

public static dropColumn(string $table, string $column) : bool
Parameters
$table : string
$column : string
Return values
bool

dropIndex()

Drop index from a table if it exists.

public static dropIndex(string $table, string $indexName) : bool
Parameters
$table : string
$indexName : string
Return values
bool

enable()

Implements civicrm_enable

public enable() : mixed

enqueuePendingRevisions()

Add any pending revisions to the queue.

public enqueuePendingRevisions() : mixed

executeCustomDataFile()

Run a CustomData file.

public executeCustomDataFile(string $relativePath) : bool
Parameters
$relativePath : string

the CustomData XML file path (relative to this extension's dir)

Return values
bool

executeSql()

Run one SQL query.

public executeSql(mixed $query[, mixed $params = [] ]) : bool

This is just a wrapper for CRM_Core_DAO::executeSql, but it provides syntactic sugar for queueing several tasks that run different queries

Parameters
$query : mixed
$params : mixed = []
Return values
bool

executeSqlFile()

Run a SQL file.

public executeSqlFile(string $tplFile) : bool
Parameters
$tplFile : string

The SQL file path (relative to this extension's dir, or absolute)

Return values
bool

executeSqlTemplate()

Run the sql commands in the specified file.

public executeSqlTemplate(string $tplFile) : bool
Parameters
$tplFile : string

The SQL file path (relative to this extension's dir, or absolute). Ex: "sql/mydata.mysql.tpl".

Tags
throws
CRM_Core_Exception
Return values
bool

getExtensionDir()

public getExtensionDir() : string
Return values
string

Ex: '/var/www/sites/default/ext/org.example.foobar'

getExtensionKey()

public getExtensionKey() : string
Return values
string

Ex: 'org.example.foobar'

getRevisions()

Get a list of revisions.

public getRevisions() : array<string|int, mixed>
Return values
array<string|int, mixed>

revisionNumbers sorted numerically

hasPendingRevisions()

Determine if there are any pending revisions.

public hasPendingRevisions() : bool
Return values
bool

init()

{@inheritDoc}

public init(array<string|int, mixed> $params) : mixed
Parameters
$params : array<string|int, mixed>

install()

Implements civicrm_install

public install() : mixed

notify()

Notify the upgrader about a key lifecycle event, such as installation or uninstallation.

public notify(string $event[, array<string|int, mixed> $params = [] ]) : mixed
Parameters
$event : string

One of the following: 'install', 'onPostInstall', 'enable', 'disable', 'uninstall', 'upgrade'

$params : array<string|int, mixed> = []

Any data that would ordinarily be provided via the equivalent hook.

onInstall()

Run early installation steps. Ex: Create new MySQL table.

public onInstall() : mixed

This dispatches directly to each new extension. You will only receive notices for your own installation.

If multiple extensions are installed simultaneously, they will all run hook_install/hook_enable back-to-back (in order of dependency).

This runs AFTER creating tables, but BEFORE refreshing major caches and services (such as ManagedEntities and CRM_Logging_Schema).

Tags
see
https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_install

onPostInstall()

Run later installation steps. Ex: Call a bespoke API-job for the first time.

public onPostInstall() : mixed

This dispatches directly to each new extension. You will only receive notices for your own installation.

If multiple extensions are installed simultaneously, they will all run hook_postInstall back-to-back (in order of dependency).

This runs AFTER refreshing major caches and services (such as ManagedEntities and CRM_Logging_Schema).

Tags
see
https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall

onPreInstall()

Run pre-installation steps. Ex: Validate system environment

public onPreInstall() : void

This runs BEFORE creating any sql tables.

postInstall()

Implements civicrm_postInstall

public postInstall() : mixed

prependTask()

Enqueue a task based on a method in this class.

public prependTask(string $title, string $funcName, mixed ...$options) : mixed

The task is weighted so that it is processed as part of the currently-pending revision.

After passing the $funcName, you can also pass parameters that will go to the function. Note that all params must be serializable.

Parameters
$title : string
$funcName : string
$options : mixed

setCurrentRevision()

public setCurrentRevision(mixed $revision) : mixed
Parameters
$revision : mixed

uninstall()

Implements civicrm_uninstall

public uninstall() : mixed

appendTask()

Enqueue a task based on a method in this class.

protected appendTask(string $title, string $funcName, mixed ...$options) : mixed

The task has a default weight.

Parameters
$title : string
$funcName : string
$options : mixed

executeCustomDataFileByAbsPath()

Run a CustomData file

protected executeCustomDataFileByAbsPath(string $xml_file) : bool
Parameters
$xml_file : string

the CustomData XML file path (absolute path)

Return values
bool

deleteDeprecatedRevision()

private deleteDeprecatedRevision() : mixed

getCurrentRevisionDeprecated()

private getCurrentRevisionDeprecated() : mixed

        
On this page

Search results