Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023

This commit is contained in:
Pantheon Automation 2015-09-04 13:20:09 -07:00 committed by Greg Anderson
parent 2720a9ec4b
commit f3791f1da3
1898 changed files with 54300 additions and 11481 deletions

View file

@ -18,33 +18,44 @@ 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.
* If the module is already installed, drupal_get_path() will return a valid
* path and we should install it there. 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.
* The absolute path of the directory.
*/
public function getInstallDirectory() {
if ($relative_path = drupal_get_path('module', $this->name)) {
$relative_path = dirname($relative_path);
if ($this->isInstalled() && ($relative_path = drupal_get_path('module', $this->name))) {
// The return value of drupal_get_path() is always relative to the site,
// so prepend DRUPAL_ROOT.
return DRUPAL_ROOT . '/' . dirname($relative_path);
}
else {
$relative_path = 'modules';
// When installing a new module, prepend the requested root directory.
return $this->root . '/' . $this->getRootDirectoryRelativePath();
}
return DRUPAL_ROOT . '/' . $relative_path;
}
/**
* {@inheritdoc}
*/
public static function getRootDirectoryRelativePath() {
return 'modules';
}
/**
* Implements Drupal\Core\Updater\UpdaterInterface::isInstalled().
*/
public function isInstalled() {
return (bool) drupal_get_path('module', $this->name);
// Check if the module exists in the file system, regardless of whether it
// is enabled or not.
$modules = \Drupal::state()->get('system.module.files', array());
return isset($modules[$this->name]);
}
/**
@ -98,11 +109,31 @@ class Module extends Updater implements UpdaterInterface {
* 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')),
);
// Since this is being called outsite of the primary front controller,
// the base_url needs to be set explicitly to ensure that links are
// relative to the site root.
// @todo Simplify with https://www.drupal.org/node/2548095
$default_options = [
'#type' => 'link',
'#options' => [
'absolute' => TRUE,
'base_url' => $GLOBALS['base_url'],
],
];
return [
$default_options + [
'#url' => Url::fromRoute('update.module_install'),
'#title' => t('Install another module'),
],
$default_options + [
'#url' => Url::fromRoute('system.modules_list'),
'#title' => t('Enable newly added modules'),
],
$default_options + [
'#url' => Url::fromRoute('system.admin'),
'#title' => t('Administration pages'),
],
];
}
/**

View file

@ -18,33 +18,44 @@ 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.
* 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 string
* A directory path.
* The absolute path of the directory.
*/
public function getInstallDirectory() {
if ($relative_path = drupal_get_path('theme', $this->name)) {
$relative_path = dirname($relative_path);
if ($this->isInstalled() && ($relative_path = drupal_get_path('theme', $this->name))) {
// The return value of drupal_get_path() is always relative to the site,
// so prepend DRUPAL_ROOT.
return DRUPAL_ROOT . '/' . dirname($relative_path);
}
else {
$relative_path = 'themes';
// When installing a new theme, prepend the requested root directory.
return $this->root . '/' . $this->getRootDirectoryRelativePath();
}
return DRUPAL_ROOT . '/' . $relative_path;
}
/**
* {@inheritdoc}
*/
public static function getRootDirectoryRelativePath() {
return 'themes';
}
/**
* Implements Drupal\Core\Updater\UpdaterInterface::isInstalled().
*/
public function isInstalled() {
return (bool) drupal_get_path('theme', $this->name);
// Check if the theme exists in the file system, regardless of whether it
// is enabled or not.
$themes = \Drupal::state()->get('system.theme.files', array());
return isset($themes[$this->name]);
}
/**
@ -81,9 +92,26 @@ class Theme extends Updater implements UpdaterInterface {
* 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')),
);
// Since this is being called outsite of the primary front controller,
// the base_url needs to be set explicitly to ensure that links are
// relative to the site root.
// @todo Simplify with https://www.drupal.org/node/2548095
$default_options = [
'#type' => 'link',
'#options' => [
'absolute' => TRUE,
'base_url' => $GLOBALS['base_url'],
],
];
return [
$default_options + [
'#url' => Url::fromRoute('system.themes_page'),
'#title' => t('Install newly added themes'),
],
$default_options + [
'#url' => Url::fromRoute('system.admin'),
'#title' => t('Administration pages'),
],
];
}
}

View file

@ -23,14 +23,26 @@ class Updater {
*/
public $source;
/**
* The root directory under which new projects will be copied.
*
* @var string
*/
protected $root;
/**
* Constructs a new updater.
*
* @param string $source
* Directory to install from.
* @param 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).
*/
public function __construct($source) {
public function __construct($source, $root) {
$this->source = $source;
$this->root = $root;
$this->name = self::getProjectName($source);
$this->title = self::getProjectTitle($source);
}
@ -43,20 +55,24 @@ class Updater {
*
* @param string $source
* Directory of a Drupal project.
* @param 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 \Drupal\Core\Updater\Updater
* A new Drupal\Core\Updater\Updater object.
*
* @throws \Drupal\Core\Updater\UpdaterException
*/
public static function factory($source) {
public static function factory($source, $root) {
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);
return new $updater($source, $root);
}
/**

View file

@ -35,13 +35,21 @@ interface UpdaterInterface {
public static function getProjectName($directory);
/**
* Returns the path to the default install location.
* Returns the path to the default install location for the current project.
*
* @return string
* An absolute path to the default install location.
*/
public function getInstallDirectory();
/**
* Returns the name of the root directory under which projects will be copied.
*
* @return string
* A relative path to the root directory.
*/
public static function getRootDirectoryRelativePath();
/**
* Determines if the Updater can handle the project provided in $directory.
*