class Theme extends Updater implements UpdaterInterface (View source)

Defines a class for updating themes using Drupal\Core\FileTransfer\FileTransfer classes via authorize.php.

Properties

string $source

Directory to install from.

from  Updater
protected string $root

The root directory under which new projects will be copied.

from  Updater

Methods

__construct(string $source, string $root)

Constructs a new updater.

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

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

from  Updater
static string
getUpdaterFromDirectory(string $directory)

Determines which Updater class can operate on the given directory.

from  Updater
static string
findInfoFile(string $directory)

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

from  Updater
static array
getExtensionInfo(string $directory)

Get Extension information from directory.

from  Updater
static string
getProjectName(string $directory)

Gets the name of the project directory (basename).

from  Updater
static string
getProjectTitle(string $directory)

Returns the project name from a Drupal info file.

from  Updater
array
getInstallArgs(array $overrides = [])

Stores the default parameters for the Updater.

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

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

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

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

from  Updater
prepareInstallDirectory(FileTransfer $filetransfer, string $directory)

Makes sure the installation parent directory exists and is writable.

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

Ensures that a given directory is world readable.

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

Performs a backup.

from  Updater
getBackupDir()

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

from  Updater
postUpdate()

Performs actions after new code is updated.

from  Updater
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.

from  Updater
string
getInstallDirectory()

Returns the directory where a theme should be installed.

static string
getRootDirectoryRelativePath()

Returns the name of the root directory under which projects will be copied.

bool
isInstalled()

Checks if the project is installed.

static bool
canUpdateDirectory(string $directory)

Determines if the Updater can handle the project provided in $directory.

static bool
canUpdate(string $project_name)

Determines whether this class can update the specified project.

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

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.

string getInstallDirectory()

Returns the directory where a theme should be installed.

If the theme is already installed, drupal_get_path() will return a valid path and we should install it there. If we're installing a new theme, we always want it to go into /themes, since that's where all the documentation recommends users install their themes, and there's no way that can conflict on a multi-site installation, since the Update manager won't let you install a new theme if it's already found on your system, and if there was a copy in the top-level we'd see it.

Return Value

string

An absolute path to the default install location.

static string getRootDirectoryRelativePath()

Returns the name of the root directory under which projects will be copied.

Return Value

string

A relative path to the root directory.

bool isInstalled()

Checks if the project is installed.

Return Value

bool

static bool canUpdateDirectory(string $directory)

Determines if the Updater can handle the project provided in $directory.

Parameters

string $directory

Return Value

bool

TRUE if the project is installed, FALSE if not.

static bool canUpdate(string $project_name)

Determines whether this class can update the specified project.

Parameters

string $project_name

The project to check.

Return Value

bool