class Updater (View source)

Defines the base class for Updaters used in Drupal.

Properties

string $source

Directory to install from.

protected string $root

The root directory under which new projects will be copied.

Methods

__construct(string $source, string $root)

Constructs a new updater.

static Updater
factory(string $source, string $root)

Returns an Updater of the appropriate type depending on the source.

static string
getUpdaterFromDirectory(string $directory)

Determines which Updater class can operate on the given directory.

static string
findInfoFile(string $directory)

Determines what the most important (or only) info file is in a directory.

static array
getExtensionInfo(string $directory)

Get Extension information from directory.

static string
getProjectName(string $directory)

Gets the name of the project directory (basename).

static string
getProjectTitle(string $directory)

Returns the project name from a Drupal info file.

array
getInstallArgs(array $overrides = [])

Stores the default parameters for the Updater.

array
update(FileTransfer $filetransfer, array $overrides = [])

Updates a Drupal project and returns a list of next actions.

array
install(FileTransfer $filetransfer, array $overrides = [])

Installs a Drupal project, returns a list of next actions.

prepareInstallDirectory(FileTransfer $filetransfer, string $directory)

Makes sure the installation parent directory exists and is writable.

makeWorldReadable(FileTransfer $filetransfer, string $path, bool $recursive = TRUE)

Ensures that a given directory is world readable.

makeBackup(FileTransfer $filetransfer, string $from, string $to)

Performs a backup.

getBackupDir()

Returns the full path to a directory where backups should be written.

postUpdate()

Performs actions after new code is updated.

postInstall()

Performs actions after installation.

array
postInstallTasks()

Returns an array of links to pages that should be visited post operation.

array
postUpdateTasks()

Returns an array of links to pages that should be visited post operation.

Details

__construct(string $source, string $root)

Constructs a new updater.

Parameters

string $source

Directory to install from.

string $root

The root directory under which the project will be copied to if it's a new project. Usually this is the app root (the directory in which the Drupal site is installed).

static Updater factory(string $source, string $root)

Returns an Updater of the appropriate type depending on the source.

If a directory is provided which contains a module, will return a ModuleUpdater.

Parameters

string $source

Directory of a Drupal project.

string $root

The root directory under which the project will be copied to if it's a new project. Usually this is the app root (the directory in which the Drupal site is installed).

Return Value

Updater

A new Drupal\Core\Updater\Updater object.

Exceptions

UpdaterException

static string getUpdaterFromDirectory(string $directory)

Determines which Updater class can operate on the given directory.

Parameters

string $directory

Extracted Drupal project.

Return Value

string

The class name which can work with this project type.

Exceptions

UpdaterException

static string findInfoFile(string $directory)

Determines what the most important (or only) info file is in a directory.

Since there is no enforcement of which info file is the project's "main" info file, this will get one with the same name as the directory, or the first one it finds. Not ideal, but needs a larger solution.

Parameters

string $directory

Directory to search in.

Return Value

string

Path to the info file.

static protected array getExtensionInfo(string $directory)

Get Extension information from directory.

Parameters

string $directory

Directory to search in.

Return Value

array

Extension info.

Exceptions

UpdaterException

static string getProjectName(string $directory)

Gets the name of the project directory (basename).

It would be nice, if projects contained an info file which could provide their canonical name.

Parameters

string $directory

The full directory path.

Return Value

string

The name of the project.

static string getProjectTitle(string $directory)

Returns the project name from a Drupal info file.

Parameters

string $directory

Directory to search for the info file.

Return Value

string

The title of the project.

Exceptions

UpdaterException

protected array getInstallArgs(array $overrides = [])

Stores the default parameters for the Updater.

Parameters

array $overrides

An array of overrides for the default parameters.

Return Value

array

An array of configuration parameters for an update or install operation.

array update(FileTransfer $filetransfer, array $overrides = [])

Updates a Drupal project and returns a list of next actions.

Parameters

FileTransfer $filetransfer

Object that is a child of FileTransfer. Used for moving files to the server.

array $overrides

An array of settings to override defaults; see self::getInstallArgs().

Return Value

array

An array of links which the user may need to complete the update

Exceptions

UpdaterException
UpdaterFileTransferException

array install(FileTransfer $filetransfer, array $overrides = [])

Installs a Drupal project, returns a list of next actions.

Parameters

FileTransfer $filetransfer

Object that is a child of FileTransfer.

array $overrides

An array of settings to override defaults; see self::getInstallArgs().

Return Value

array

An array of links which the user may need to complete the install.

Exceptions

UpdaterFileTransferException

prepareInstallDirectory(FileTransfer $filetransfer, string $directory)

Makes sure the installation parent directory exists and is writable.

Parameters

FileTransfer $filetransfer

Object which is a child of FileTransfer.

string $directory

The installation directory to prepare.

Exceptions

UpdaterException

makeWorldReadable(FileTransfer $filetransfer, string $path, bool $recursive = TRUE)

Ensures that a given directory is world readable.

Parameters

FileTransfer $filetransfer

Object which is a child of FileTransfer.

string $path

The file path to make world readable.

bool $recursive

If the chmod should be applied recursively.

makeBackup(FileTransfer $filetransfer, string $from, string $to)

Performs a backup.

Not implemented: https://www.drupal.org/node/2474355

Parameters

FileTransfer $filetransfer

Object which is a child of FileTransfer.

string $from

The file path to copy from.

string $to

The file path to copy to.

getBackupDir()

Returns the full path to a directory where backups should be written.

postUpdate()

Performs actions after new code is updated.

postInstall()

Performs actions after installation.

array postInstallTasks()

Returns an array of links to pages that should be visited post operation.

Return Value

array

Links which provide actions to take after the install is finished.

array postUpdateTasks()

Returns an array of links to pages that should be visited post operation.

Return Value

array

Links which provide actions to take after the update is finished.