Blesta Source Documentation

UpgradeUtil

AbstractYes

Upgrade Utility that all upgrade objects must extend

Attributes
#[AllowDynamicProperties]
Table of Contents

Properties

$environment

Methods

addConfig() Adds a config setting to the given file
editConfig() Updates a config setting in the given file with the given value
errors() Return all validation errors encountered
getEnvironment() Fetches the current tasks environment
mergeConfig() Extracts all config settings from $file, merges their values into $template and writes the result back in $file.
process() Processes the given task
rollback() Rolls back all tasks completed for the upgrade process
setEnvironment() Set the environment where the task are going to be executed
tasks() Returns a numerically indexed array of tasks to execute for the upgrade process
newRecord() Creates a new database connection
replaceConfig() Replaces a config setting within the context of a string
escapeReplacement() Escape preg_replace replacement values
replaceConfigMisc() Replaces miscellaneous config values within the context of a string
Properties

$environment

private string $environment = 'upgrade'

The environment where the upgrade is being executed, it could be "install" or "upgrade"

Methods

addConfig()

Adds a config setting to the given file

public addConfig(string $file, string $key, mixed $value) : mixed
Parameters
$file : string

The full path to the config file

$key : string

The config setting name

$value : mixed

The config setting value

editConfig()

Updates a config setting in the given file with the given value

public editConfig(string $file, string $key, mixed $value) : mixed
Parameters
$file : string

The full path to the config file

$key : string

The config setting name

$value : mixed

The config setting value

errors()

Return all validation errors encountered

public errors() : mixed
Return values
mixed

Boolean false if no errors encountered, an array of errors otherwise

getEnvironment()

Fetches the current tasks environment

public getEnvironment() : string
Return values
string

The environment where the tasks are running

mergeConfig()

Extracts all config settings from $file, merges their values into $template and writes the result back in $file.

public mergeConfig(string $file, string $template) : mixed
Parameters
$file : string

The full path to the config

$template : string

The full path to the config template

process()

Processes the given task

public abstract process(string $task) : mixed
Parameters
$task : string

The task to process

rollback()

Rolls back all tasks completed for the upgrade process

public abstract rollback() : mixed

setEnvironment()

Set the environment where the task are going to be executed

public setEnvironment(string $environment) : mixed
Parameters
$environment : string

The environment where the upgrade tasks are running, "install" or "upgrade"

tasks()

Returns a numerically indexed array of tasks to execute for the upgrade process

public abstract tasks() : mixed
Tags
retrun

array A numerically indexed array of tasks to execute for the upgrade process

newRecord()

Creates a new database connection

protected newRecord() : Record
Return values
Record

a new instance of Record

replaceConfig()

Replaces a config setting within the context of a string

protected replaceConfig(string $key, string $value, string $contents) : string
Parameters
$key : string

The config key to replace the value of

$value : string

The new value

$contents : string

The context in which the $key is set

Return values
string

$contents with the given $value replaced

escapeReplacement()

Escape preg_replace replacement values

private static escapeReplacement(string $value) : string
Parameters
$value : string

The value to escape

Return values
string

The properly escape value

replaceConfigMisc()

Replaces miscellaneous config values within the context of a string

private replaceConfigMisc(string $template_contents, string $contents) : string
Parameters
$template_contents : string

The contents of the template config file

$contents : string

The contents of the config file

Return values
string

The updated template contents from the config file

Tags
subpackage

components.upgrades

copyright

Copyright (c) 2010, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results