Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
115
core/lib/Drupal/Core/Updater/Module.php
Normal file
115
core/lib/Drupal/Core/Updater/Module.php
Normal file
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Updater\Module.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Updater;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
|
||||
/**
|
||||
* Defines a class for updating modules using
|
||||
* Drupal\Core\FileTransfer\FileTransfer classes via authorize.php.
|
||||
*/
|
||||
class Module extends Updater implements UpdaterInterface {
|
||||
|
||||
/**
|
||||
* Returns the directory where a module should be installed.
|
||||
*
|
||||
* If the module is already installed, drupal_get_path() will return
|
||||
* a valid path and we should install it there (although we need to use an
|
||||
* absolute path, so we prepend DRUPAL_ROOT). If we're installing a new
|
||||
* module, we always want it to go into /modules, since that's
|
||||
* where all the documentation recommends users install their modules, and
|
||||
* there's no way that can conflict on a multi-site installation, since
|
||||
* the Update manager won't let you install a new module if it's already
|
||||
* found on your system, and if there was a copy in the top-level we'd see it.
|
||||
*
|
||||
* @return string
|
||||
* A directory path.
|
||||
*/
|
||||
public function getInstallDirectory() {
|
||||
if ($relative_path = drupal_get_path('module', $this->name)) {
|
||||
$relative_path = dirname($relative_path);
|
||||
}
|
||||
else {
|
||||
$relative_path = 'modules';
|
||||
}
|
||||
return DRUPAL_ROOT . '/' . $relative_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Drupal\Core\Updater\UpdaterInterface::isInstalled().
|
||||
*/
|
||||
public function isInstalled() {
|
||||
return (bool) drupal_get_path('module', $this->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Drupal\Core\Updater\UpdaterInterface::canUpdateDirectory().
|
||||
*/
|
||||
public static function canUpdateDirectory($directory) {
|
||||
$info = static::getExtensionInfo($directory);
|
||||
|
||||
return (isset($info['type']) && $info['type'] == 'module');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether this class can update the specified project.
|
||||
*
|
||||
* @param string $project_name
|
||||
* The project to check.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function canUpdate($project_name) {
|
||||
return (bool) drupal_get_path('module', $project_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns available database schema updates once a new version is installed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSchemaUpdates() {
|
||||
require_once DRUPAL_ROOT . '/core/includes/install.inc';
|
||||
require_once DRUPAL_ROOT . '/core/includes/update.inc';
|
||||
|
||||
if (!self::canUpdate($this->name)) {
|
||||
return array();
|
||||
}
|
||||
module_load_include('install', $this->name);
|
||||
|
||||
if (!$updates = drupal_get_schema_versions($this->name)) {
|
||||
return array();
|
||||
}
|
||||
$modules_with_updates = update_get_update_list();
|
||||
if ($updates = $modules_with_updates[$this->name]) {
|
||||
if ($updates['start']) {
|
||||
return $updates['pending'];
|
||||
}
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\Core\Updater\Updater::postInstallTasks().
|
||||
*/
|
||||
public function postInstallTasks() {
|
||||
return array(
|
||||
\Drupal::l(t('Install another module'), new Url('update.module_install')),
|
||||
\Drupal::l(t('Enable newly added modules'), new Url('system.modules_list')),
|
||||
\Drupal::l(t('Administration pages'), new Url('system.admin')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\Core\Updater\Updater::postUpdateTasks().
|
||||
*/
|
||||
public function postUpdateTasks() {
|
||||
// We don't want to check for DB updates here, we do that once for all
|
||||
// updated modules on the landing page.
|
||||
}
|
||||
}
|
89
core/lib/Drupal/Core/Updater/Theme.php
Normal file
89
core/lib/Drupal/Core/Updater/Theme.php
Normal file
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Updater\Theme.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Updater;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
|
||||
/**
|
||||
* Defines a class for updating themes using
|
||||
* Drupal\Core\FileTransfer\FileTransfer classes via authorize.php.
|
||||
*/
|
||||
class Theme extends Updater implements UpdaterInterface {
|
||||
|
||||
/**
|
||||
* 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 (although we need to use an
|
||||
* absolute path, so we prepend DRUPAL_ROOT). 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 string
|
||||
* A directory path.
|
||||
*/
|
||||
public function getInstallDirectory() {
|
||||
if ($relative_path = drupal_get_path('theme', $this->name)) {
|
||||
$relative_path = dirname($relative_path);
|
||||
}
|
||||
else {
|
||||
$relative_path = 'themes';
|
||||
}
|
||||
return DRUPAL_ROOT . '/' . $relative_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Drupal\Core\Updater\UpdaterInterface::isInstalled().
|
||||
*/
|
||||
public function isInstalled() {
|
||||
return (bool) drupal_get_path('theme', $this->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Drupal\Core\Updater\UpdaterInterface::canUpdateDirectory().
|
||||
*/
|
||||
static function canUpdateDirectory($directory) {
|
||||
$info = static::getExtensionInfo($directory);
|
||||
|
||||
return (isset($info['type']) && $info['type'] == 'theme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether this class can update the specified project.
|
||||
*
|
||||
* @param string $project_name
|
||||
* The project to check.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function canUpdate($project_name) {
|
||||
return (bool) drupal_get_path('theme', $project_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\Core\Updater\Updater::postInstall().
|
||||
*/
|
||||
public function postInstall() {
|
||||
// Update the theme info.
|
||||
clearstatcache();
|
||||
\Drupal::service('theme_handler')->rebuildThemeData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\Core\Updater\Updater::postInstallTasks().
|
||||
*/
|
||||
public function postInstallTasks() {
|
||||
return array(
|
||||
\Drupal::l(t('Install newly added themes'), new Url('system.themes_page')),
|
||||
\Drupal::l(t('Administration pages'), new Url('system.admin')),
|
||||
);
|
||||
}
|
||||
}
|
402
core/lib/Drupal/Core/Updater/Updater.php
Normal file
402
core/lib/Drupal/Core/Updater/Updater.php
Normal file
|
@ -0,0 +1,402 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Updater\Updater.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Updater;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\FileTransfer\FileTransferException;
|
||||
use Drupal\Core\FileTransfer\FileTransfer;
|
||||
|
||||
/**
|
||||
* Defines the base class for Updaters used in Drupal.
|
||||
*/
|
||||
class Updater {
|
||||
|
||||
/**
|
||||
* Directory to install from.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $source;
|
||||
|
||||
/**
|
||||
* Constructs a new updater.
|
||||
*
|
||||
* @param string $source
|
||||
* Directory to install from.
|
||||
*/
|
||||
public function __construct($source) {
|
||||
$this->source = $source;
|
||||
$this->name = self::getProjectName($source);
|
||||
$this->title = self::getProjectTitle($source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Updater of the appropriate type depending on the source.
|
||||
*
|
||||
* If a directory is provided which contains a module, will return a
|
||||
* ModuleUpdater.
|
||||
*
|
||||
* @param string $source
|
||||
* Directory of a Drupal project.
|
||||
*
|
||||
* @return \Drupal\Core\Updater\Updater
|
||||
* A new Drupal\Core\Updater\Updater object.
|
||||
*
|
||||
* @throws \Drupal\Core\Updater\UpdaterException
|
||||
*/
|
||||
public static function factory($source) {
|
||||
if (is_dir($source)) {
|
||||
$updater = self::getUpdaterFromDirectory($source);
|
||||
}
|
||||
else {
|
||||
throw new UpdaterException(t('Unable to determine the type of the source directory.'));
|
||||
}
|
||||
return new $updater($source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which Updater class can operate on the given directory.
|
||||
*
|
||||
* @param string $directory
|
||||
* Extracted Drupal project.
|
||||
*
|
||||
* @return string
|
||||
* The class name which can work with this project type.
|
||||
*
|
||||
* @throws \Drupal\Core\Updater\UpdaterException
|
||||
*/
|
||||
public static function getUpdaterFromDirectory($directory) {
|
||||
// Gets a list of possible implementing classes.
|
||||
$updaters = drupal_get_updaters();
|
||||
foreach ($updaters as $updater) {
|
||||
$class = $updater['class'];
|
||||
if (call_user_func(array($class, 'canUpdateDirectory'), $directory)) {
|
||||
return $class;
|
||||
}
|
||||
}
|
||||
throw new UpdaterException(t('Cannot determine the type of project.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param string $directory
|
||||
* Directory to search in.
|
||||
*
|
||||
* @return string
|
||||
* Path to the info file.
|
||||
*/
|
||||
public static function findInfoFile($directory) {
|
||||
$info_files = file_scan_directory($directory, '/.*\.info.yml$/');
|
||||
if (!$info_files) {
|
||||
return FALSE;
|
||||
}
|
||||
foreach ($info_files as $info_file) {
|
||||
if (Unicode::substr($info_file->filename, 0, -9) == drupal_basename($directory)) {
|
||||
// Info file Has the same name as the directory, return it.
|
||||
return $info_file->uri;
|
||||
}
|
||||
}
|
||||
// Otherwise, return the first one.
|
||||
$info_file = array_shift($info_files);
|
||||
return $info_file->uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Extension information from directory.
|
||||
*
|
||||
* @param string $directory
|
||||
* Directory to search in.
|
||||
*
|
||||
* @return array
|
||||
* Extension info.
|
||||
*
|
||||
* @throws \Drupal\Core\Updater\UpdaterException
|
||||
* If the info parser does not provide any info.
|
||||
*/
|
||||
protected static function getExtensionInfo($directory) {
|
||||
$info_file = static::findInfoFile($directory);
|
||||
$info = \Drupal::service('info_parser')->parse($info_file);
|
||||
if (empty($info)) {
|
||||
throw new UpdaterException(t('Unable to parse info file: %info_file.', ['%info_file' => $info_file]));
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the project directory (basename).
|
||||
*
|
||||
* @todo It would be nice, if projects contained an info file which could
|
||||
* provide their canonical name.
|
||||
*
|
||||
* @param string $directory
|
||||
*
|
||||
* @return string
|
||||
* The name of the project.
|
||||
*/
|
||||
public static function getProjectName($directory) {
|
||||
return drupal_basename($directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the project name from a Drupal info file.
|
||||
*
|
||||
* @param string $directory
|
||||
* Directory to search for the info file.
|
||||
*
|
||||
* @return string
|
||||
* The title of the project.
|
||||
*
|
||||
* @throws \Drupal\Core\Updater\UpdaterException
|
||||
*/
|
||||
public static function getProjectTitle($directory) {
|
||||
$info_file = self::findInfoFile($directory);
|
||||
$info = \Drupal::service('info_parser')->parse($info_file);
|
||||
if (empty($info)) {
|
||||
throw new UpdaterException(t('Unable to parse info file: %info_file.', array('%info_file' => $info_file)));
|
||||
}
|
||||
return $info['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the default parameters for the Updater.
|
||||
*
|
||||
* @param array $overrides
|
||||
* An array of overrides for the default parameters.
|
||||
*
|
||||
* @return array
|
||||
* An array of configuration parameters for an update or install operation.
|
||||
*/
|
||||
protected function getInstallArgs($overrides = array()) {
|
||||
$args = array(
|
||||
'make_backup' => FALSE,
|
||||
'install_dir' => $this->getInstallDirectory(),
|
||||
'backup_dir' => $this->getBackupDir(),
|
||||
);
|
||||
return array_merge($args, $overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a Drupal project and returns a list of next actions.
|
||||
*
|
||||
* @param \Drupal\Core\FileTransfer\FileTransfer $filetransfer
|
||||
* Object that is a child of FileTransfer. Used for moving files
|
||||
* to the server.
|
||||
* @param array $overrides
|
||||
* An array of settings to override defaults; see self::getInstallArgs().
|
||||
*
|
||||
* @return array
|
||||
* An array of links which the user may need to complete the update
|
||||
*
|
||||
* @throws \Drupal\Core\Updater\UpdaterException
|
||||
* @throws \Drupal\Core\Updater\UpdaterFileTransferException
|
||||
*/
|
||||
public function update(&$filetransfer, $overrides = array()) {
|
||||
try {
|
||||
// Establish arguments with possible overrides.
|
||||
$args = $this->getInstallArgs($overrides);
|
||||
|
||||
// Take a Backup.
|
||||
if ($args['make_backup']) {
|
||||
$this->makeBackup($filetransfer, $args['install_dir'], $args['backup_dir']);
|
||||
}
|
||||
|
||||
if (!$this->name) {
|
||||
// This is bad, don't want to delete the install directory.
|
||||
throw new UpdaterException(t('Fatal error in update, cowardly refusing to wipe out the install directory.'));
|
||||
}
|
||||
|
||||
// Make sure the installation parent directory exists and is writable.
|
||||
$this->prepareInstallDirectory($filetransfer, $args['install_dir']);
|
||||
|
||||
// Note: If the project is installed in the top-level, it will not be
|
||||
// deleted. It will be installed in sites/default as that will override
|
||||
// the top-level reference and not break other sites which are using it.
|
||||
if (is_dir($args['install_dir'] . '/' . $this->name)) {
|
||||
// Remove the existing installed file.
|
||||
$filetransfer->removeDirectory($args['install_dir'] . '/' . $this->name);
|
||||
}
|
||||
|
||||
// Copy the directory in place.
|
||||
$filetransfer->copyDirectory($this->source, $args['install_dir']);
|
||||
|
||||
// Make sure what we just installed is readable by the web server.
|
||||
$this->makeWorldReadable($filetransfer, $args['install_dir'] . '/' . $this->name);
|
||||
|
||||
// Run the updates.
|
||||
// @todo Decide if we want to implement this.
|
||||
$this->postUpdate();
|
||||
|
||||
// For now, just return a list of links of things to do.
|
||||
return $this->postUpdateTasks();
|
||||
}
|
||||
catch (FileTransferException $e) {
|
||||
throw new UpdaterFileTransferException(t('File Transfer failed, reason: !reason', array('!reason' => strtr($e->getMessage(), $e->arguments))));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs a Drupal project, returns a list of next actions.
|
||||
*
|
||||
* @param \Drupal\Core\FileTransfer\FileTransfer $filetransfer
|
||||
* Object that is a child of FileTransfer.
|
||||
* @param array $overrides
|
||||
* An array of settings to override defaults; see self::getInstallArgs().
|
||||
*
|
||||
* @return array
|
||||
* An array of links which the user may need to complete the install.
|
||||
*
|
||||
* @throws \Drupal\Core\Updater\UpdaterFileTransferException
|
||||
*/
|
||||
public function install(&$filetransfer, $overrides = array()) {
|
||||
try {
|
||||
// Establish arguments with possible overrides.
|
||||
$args = $this->getInstallArgs($overrides);
|
||||
|
||||
// Make sure the installation parent directory exists and is writable.
|
||||
$this->prepareInstallDirectory($filetransfer, $args['install_dir']);
|
||||
|
||||
// Copy the directory in place.
|
||||
$filetransfer->copyDirectory($this->source, $args['install_dir']);
|
||||
|
||||
// Make sure what we just installed is readable by the web server.
|
||||
$this->makeWorldReadable($filetransfer, $args['install_dir'] . '/' . $this->name);
|
||||
|
||||
// Potentially enable something?
|
||||
// @todo Decide if we want to implement this.
|
||||
$this->postInstall();
|
||||
// For now, just return a list of links of things to do.
|
||||
return $this->postInstallTasks();
|
||||
}
|
||||
catch (FileTransferException $e) {
|
||||
throw new UpdaterFileTransferException(t('File Transfer failed, reason: !reason', array('!reason' => strtr($e->getMessage(), $e->arguments))));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure the installation parent directory exists and is writable.
|
||||
*
|
||||
* @param \Drupal\Core\FileTransfer\FileTransfer $filetransfer
|
||||
* Object which is a child of FileTransfer.
|
||||
* @param string $directory
|
||||
* The installation directory to prepare.
|
||||
*
|
||||
* @throws \Drupal\Core\Updater\UpdaterException
|
||||
*/
|
||||
public function prepareInstallDirectory(&$filetransfer, $directory) {
|
||||
// Make the parent dir writable if need be and create the dir.
|
||||
if (!is_dir($directory)) {
|
||||
$parent_dir = dirname($directory);
|
||||
if (!is_writable($parent_dir)) {
|
||||
@chmod($parent_dir, 0755);
|
||||
// It is expected that this will fail if the directory is owned by the
|
||||
// FTP user. If the FTP user == web server, it will succeed.
|
||||
try {
|
||||
$filetransfer->createDirectory($directory);
|
||||
$this->makeWorldReadable($filetransfer, $directory);
|
||||
}
|
||||
catch (FileTransferException $e) {
|
||||
// Probably still not writable. Try to chmod and do it again.
|
||||
// @todo Make a new exception class so we can catch it differently.
|
||||
try {
|
||||
$old_perms = substr(sprintf('%o', fileperms($parent_dir)), -4);
|
||||
$filetransfer->chmod($parent_dir, 0755);
|
||||
$filetransfer->createDirectory($directory);
|
||||
$this->makeWorldReadable($filetransfer, $directory);
|
||||
// Put the permissions back.
|
||||
$filetransfer->chmod($parent_dir, intval($old_perms, 8));
|
||||
}
|
||||
catch (FileTransferException $e) {
|
||||
$message = t($e->getMessage(), $e->arguments);
|
||||
$throw_message = t('Unable to create %directory due to the following: %reason', array('%directory' => $directory, '%reason' => $message));
|
||||
throw new UpdaterException($throw_message);
|
||||
}
|
||||
}
|
||||
// Put the parent directory back.
|
||||
@chmod($parent_dir, 0555);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that a given directory is world readable.
|
||||
*
|
||||
* @param \Drupal\Core\FileTransfer\FileTransfer $filetransfer
|
||||
* Object which is a child of FileTransfer.
|
||||
* @param string $path
|
||||
* The file path to make world readable.
|
||||
* @param bool $recursive
|
||||
* If the chmod should be applied recursively.
|
||||
*/
|
||||
public function makeWorldReadable(&$filetransfer, $path, $recursive = TRUE) {
|
||||
if (!is_executable($path)) {
|
||||
// Set it to read + execute.
|
||||
$new_perms = substr(sprintf('%o', fileperms($path)), -4, -1) . "5";
|
||||
$filetransfer->chmod($path, intval($new_perms, 8), $recursive);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a backup.
|
||||
*
|
||||
* @param \Drupal\Core\FileTransfer\FileTransfer $filetransfer
|
||||
* Object which is a child of FileTransfer.
|
||||
* @param string $from
|
||||
* The file path to copy from.
|
||||
* @param string $to
|
||||
* The file path to copy to.
|
||||
*
|
||||
* @todo Not implemented: https://www.drupal.org/node/2474355
|
||||
*/
|
||||
public function makeBackup(FileTransfer $filetransfer, $from, $to) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full path to a directory where backups should be written.
|
||||
*/
|
||||
public function getBackupDir() {
|
||||
return file_stream_wrapper_get_instance_by_scheme('temporary')->getDirectoryPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs actions after new code is updated.
|
||||
*/
|
||||
public function postUpdate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs actions after installation.
|
||||
*/
|
||||
public function postInstall() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of links to pages that should be visited post operation.
|
||||
*
|
||||
* @return array
|
||||
* Links which provide actions to take after the install is finished.
|
||||
*/
|
||||
public function postInstallTasks() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of links to pages that should be visited post operation.
|
||||
*
|
||||
* @return array
|
||||
* Links which provide actions to take after the update is finished.
|
||||
*/
|
||||
public function postUpdateTasks() {
|
||||
return array();
|
||||
}
|
||||
}
|
18
core/lib/Drupal/Core/Updater/UpdaterException.php
Normal file
18
core/lib/Drupal/Core/Updater/UpdaterException.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Updater\UpdaterException.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Updater;
|
||||
|
||||
/**
|
||||
* Defines a Exception class for the Drupal\Core\Updater\Updater class
|
||||
* hierarchy.
|
||||
*
|
||||
* This is identical to the base Exception class, we just give it a more
|
||||
* specific name so that call sites that want to tell the difference can
|
||||
* specifically catch these exceptions and treat them differently.
|
||||
*/
|
||||
class UpdaterException extends \Exception {}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Updater\UpdaterFileTransferException.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Updater;
|
||||
|
||||
/**
|
||||
* Defines a child class of Drupal\Core\Updater\UpdaterException that indicates
|
||||
* a Drupal\Core\FileTransfer\FileTransfer exception.
|
||||
*
|
||||
* We have to catch Drupal\Core\FileTransfer\FileTransfer exceptions
|
||||
* and wrap those in t(), since Drupal\Core\FileTransfer\FileTransfer
|
||||
* is so low-level that it doesn't use any Drupal APIs and none of the strings
|
||||
* are translated.
|
||||
*/
|
||||
class UpdaterFileTransferException extends UpdaterException {
|
||||
}
|
64
core/lib/Drupal/Core/Updater/UpdaterInterface.php
Normal file
64
core/lib/Drupal/Core/Updater/UpdaterInterface.php
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Updater\UpdaterInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Updater;
|
||||
|
||||
/**
|
||||
* Defines an interface for a class which can update a Drupal project.
|
||||
*
|
||||
* An Updater currently serves the following purposes:
|
||||
* - It can take a given directory, and determine if it can operate on it.
|
||||
* - It can move the contents of that directory into the appropriate place
|
||||
* on the system using FileTransfer classes.
|
||||
* - It can return a list of "next steps" after an update or install.
|
||||
* - In the future, it will most likely perform some of those steps as well.
|
||||
*/
|
||||
interface UpdaterInterface {
|
||||
|
||||
/**
|
||||
* Checks if the project is installed.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isInstalled();
|
||||
|
||||
/**
|
||||
* Returns the system name of the project.
|
||||
*
|
||||
* @param string $directory
|
||||
* A directory containing a project.
|
||||
*/
|
||||
public static function getProjectName($directory);
|
||||
|
||||
/**
|
||||
* Returns the path to the default install location.
|
||||
*
|
||||
* @return string
|
||||
* An absolute path to the default install location.
|
||||
*/
|
||||
public function getInstallDirectory();
|
||||
|
||||
/**
|
||||
* Determines if the Updater can handle the project provided in $directory.
|
||||
*
|
||||
* @param string $directory
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the project is installed, FALSE if not.
|
||||
*/
|
||||
public static function canUpdateDirectory($directory);
|
||||
|
||||
/**
|
||||
* Actions to run after an install has occurred.
|
||||
*/
|
||||
public function postInstall();
|
||||
|
||||
/**
|
||||
* Actions to run after an update has occurred.
|
||||
*/
|
||||
public function postUpdate();
|
||||
}
|
Reference in a new issue