Documentation

CRM_Search_Upgrader extends CRM_Extension_Upgrader_Base
in package

Collection of upgrade steps.

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
dropColumn()  : bool
Drop a column from a table if it exists.
dropIndex()  : bool
Drop index from a table if it exists.
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}
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
prependTask()  : mixed
Enqueue a task based on a method in this class.
setCurrentRevision()  : mixed
setQueue()  : void
upgrade_1001()  : bool
Upgrade 1001 - normalize search display column keys
upgrade_1002()  : bool
Upgrade 1002 - embellish search display link data
upgrade_1003()  : bool
Upgrade 1003 - update APIv4 join syntax in saved searches
upgrade_1005()  : bool
Upgrade 1005 - add acl_bypass column.
upgrade_1006()  : bool
Upgrade 1006 - add image column type
upgrade_1007()  : bool
Add SearchSegment table
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

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

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>

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.

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

upgrade_1001()

Upgrade 1001 - normalize search display column keys

public upgrade_1001() : bool
Return values
bool

upgrade_1002()

Upgrade 1002 - embellish search display link data

public upgrade_1002() : bool
Return values
bool

upgrade_1003()

Upgrade 1003 - update APIv4 join syntax in saved searches

public upgrade_1003() : bool
Return values
bool

upgrade_1005()

Upgrade 1005 - add acl_bypass column.

public upgrade_1005() : bool
Return values
bool

upgrade_1006()

Upgrade 1006 - add image column type

public upgrade_1006() : bool
Return values
bool

upgrade_1007()

Add SearchSegment table

public upgrade_1007() : bool
Return values
bool

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