diff --git a/core/modules/update/lib/Drupal/update/Access/UpdateManagerAccess.php b/core/modules/update/lib/Drupal/update/Access/UpdateManagerAccess.php index d75610c..36d715f 100644 --- a/core/modules/update/lib/Drupal/update/Access/UpdateManagerAccess.php +++ b/core/modules/update/lib/Drupal/update/Access/UpdateManagerAccess.php @@ -2,7 +2,7 @@ /** * @file - * Definition of \Drupal\update\Form\UpdateManagerAccess. + * Contains \Drupal\update\Form\UpdateManagerAccess. */ namespace Drupal\update\Access; @@ -11,6 +11,7 @@ use Symfony\Component\HttpFoundation\Request; use Drupal\Core\Entity\EntityManager; use Drupal\Core\Access\AccessCheckInterface; +use Drupal\Component\Utility\Settings; /** @@ -19,17 +20,34 @@ class UpdateManagerAccess implements AccessCheckInterface { /** - * Implements AccessCheckInterface::applies(). + * The settings array. + * + * @var \Drupal\Component\Utility\Settings + */ + protected $settings; + + /** + * Constructs UpdateManagerAccess object. + * + * @param \Drupal\Component\Utility\Settings $settings + * The settings array. + */ + public function __construct(Settings $settings) { + $this->settings = $settings; + } + + /** + * {@inheritdoc} */ public function applies(Route $route) { return array_key_exists('_update_manager_access', $route->getRequirements()); } /** - * Implements AccessCheckInterface::access(). + * {@inheritdoc} */ public function access(Route $route, Request $request) { - if (settings()->get('allow_authorize_operations', TRUE)) { + if ($this->settings->get('allow_authorize_operations', TRUE)) { return TRUE; } diff --git a/core/modules/update/lib/Drupal/update/Form/UpdateManagerInstall.php b/core/modules/update/lib/Drupal/update/Form/UpdateManagerInstall.php index e51626d..b506a35 100644 --- a/core/modules/update/lib/Drupal/update/Form/UpdateManagerInstall.php +++ b/core/modules/update/lib/Drupal/update/Form/UpdateManagerInstall.php @@ -23,14 +23,14 @@ class UpdateManagerInstall implements FormInterface, ControllerInterface { * Constructs a new UpdateManagerInstall. * * @param \Drupal\Core\Extension\ModuleHandlerInterface $handler - * The module hendler. + * The Module Handler. */ public function __construct(ModuleHandlerInterface $handler) { $this->handler = $handler; } /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'update_manager_install_form'; @@ -46,7 +46,7 @@ public static function create(ContainerInterface $container) { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { $this->handler->loadInclude('update', 'inc', 'update.manager'); @@ -93,7 +93,7 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::validateForm(). + * {@inheritdoc} */ public function validateForm(array &$form, array &$form_state) { if (!($form_state['values']['project_url'] XOR !empty($_FILES['files']['name']['project_upload']))) { @@ -102,7 +102,7 @@ public function validateForm(array &$form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { if ($form_state['values']['project_url']) { diff --git a/core/modules/update/lib/Drupal/update/Form/UpdateManagerUpdate.php b/core/modules/update/lib/Drupal/update/Form/UpdateManagerUpdate.php index 29d0717..26eba58 100644 --- a/core/modules/update/lib/Drupal/update/Form/UpdateManagerUpdate.php +++ b/core/modules/update/lib/Drupal/update/Form/UpdateManagerUpdate.php @@ -22,14 +22,14 @@ class UpdateManagerUpdate implements FormInterface, ControllerInterface { * Constructs a new UpdateManagerUpdate object. * * @param \Drupal\Core\Extension\CachedModuleHandler $handler - * The database connection. + * The Module Handler. */ public function __construct(ModuleHandlerInterface $handler) { $this->handler = $handler; } /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'update_manager_update_form'; @@ -45,7 +45,7 @@ public static function create(ContainerInterface $container) { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { $this->handler->loadInclude('update', 'inc', 'update.manager'); @@ -63,8 +63,9 @@ public function buildForm(array $form, array &$form_state) { return $form; } - $form['#attached']['css'][] = drupal_get_path('module', 'update') . '/update.css'; - + $element['#attached']['library'] = array( + array('update', 'drupal.update') + ); // This will be a nested array. The first key is the kind of project, which // can be either 'enabled', 'disabled', 'manual' (projects which require // manual updates, such as core). Then, each subarray is an array of @@ -88,14 +89,14 @@ public function buildForm(array $form, array &$form_state) { $project_name = l($project['title'], $project['link']); } else { - $project_name = check_plain($project['title']); + $project_name = String::checkPlain($project['title']); } } elseif (!empty($project['info']['name'])) { - $project_name = check_plain($project['info']['name']); + $project_name = String::checkPlain($project['info']['name']); } else { - $project_name = check_plain($name); + $project_name = String::checkPlain($name); } if ($project['project_type'] == 'theme' || $project['project_type'] == 'theme-disabled') { $project_name .= ' ' . t('(Theme)'); @@ -235,20 +236,15 @@ public function buildForm(array $form, array &$form_state) { '#type' => 'submit', '#value' => t('Download these updates'), ); - $form['#validate'][] = 'update_manager_update_form_validate'; } if (!empty($projects['manual'])) { $prefix = '

' . t('Manual updates required') . '

'; $prefix .= '

' . t('Updates of Drupal core are not supported at this time.') . '

'; - $table = array( - '#theme' => 'table', - '#header' => $headers, - '#rows' => $projects['manual'], - ); $form['manual_updates'] = array( - '#type' => 'markup', - '#markup' => drupal_render($table), + '#theme' => 'table', + '#header' => $headers, + '#rows' => $projects['manual'], '#prefix' => $prefix, '#weight' => 120, ); @@ -258,7 +254,7 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::validateForm(). + * {@inheritdoc} */ public function validateForm(array &$form, array &$form_state) { if (!empty($form_state['values']['projects'])) { @@ -273,7 +269,7 @@ public function validateForm(array &$form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $this->handler->loadInclude('update', 'inc', 'update.manager'); diff --git a/core/modules/update/lib/Drupal/update/Form/UpdateReady.php b/core/modules/update/lib/Drupal/update/Form/UpdateReady.php index 5d735e4..abff598 100644 --- a/core/modules/update/lib/Drupal/update/Form/UpdateReady.php +++ b/core/modules/update/lib/Drupal/update/Form/UpdateReady.php @@ -43,7 +43,7 @@ public function __construct(ModuleHandlerInterface $handler, ConfigFactory $conf } /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'update_manager_update_ready_form'; @@ -61,9 +61,10 @@ public static function create(ContainerInterface $container) { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { + drupal_set_title(t('Ready to update')); $this->handler->loadInclude('update', 'inc', 'update.manager'); if (!_update_manager_check_backends($form, 'update')) { return $form; @@ -90,15 +91,9 @@ public function buildForm(array $form, array &$form_state) { return parent::buildForm($form, $form_state); } - /** - * Implements \Drupal\Core\Form\FormInterface::validateForm(). - */ - public function validateForm(array &$form, array &$form_state) { - parent::validateForm($form, $form_state); - } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc index 9777dc5..7b0d6d9 100644 --- a/core/modules/update/update.manager.inc +++ b/core/modules/update/update.manager.inc @@ -88,6 +88,23 @@ function update_manager_download_batch_finished($success, $results) { * Provides a user interface to install new code. */ +/** + * Returns HTML for the first page in the process of updating projects. + * + * @param $variables + * An associative array containing: + * - form: A render element representing the form. + * + * @ingroup themeable + */ +function theme_update_manager_update_form($variables) { + $form = $variables['form']; + $last = state()->get('update.last_check') ?: 0; + $output = theme('update_last_check', array('last' => $last)); + $output .= drupal_render_children($form); + return $output; +} + /** * Checks for file transfer backends and prepares a form fragment about them. diff --git a/core/modules/update/update.module b/core/modules/update/update.module index 43adf1d..43f2ada 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -150,6 +150,24 @@ function update_init() { } /** + * Implements hook_library_info(). + */ +function update_library_info() { + $module_path = drupal_get_path('module', 'update'); + + $libraries['drupal.update'] = array( + 'title' => 'Update', + 'website' => 'https://drupal.org/documentation/modules/update', + 'version' => '1.0', + 'css' => array( + $module_path . '/update.css' => array(), + ), + ); + + return $libraries; +} + +/** * Implements hook_menu(). */ function update_menu() { @@ -211,15 +229,6 @@ function update_menu() { $items['admin/modules/install'] += array('title' => 'Install new module'); $items['admin/appearance/install'] += array('title' => 'Install new theme'); - // Menu callback used for the confirmation page after all the releases - // have been downloaded, asking you to backup before installing updates. - $items['admin/update/ready'] = array( - 'title' => 'Ready to update', - 'route_name' => 'update_ready', - 'type' => MENU_CALLBACK, - - ); - return $items; } diff --git a/core/modules/update/update.routing.yml b/core/modules/update/update.routing.yml index 17b4100..0865039 100644 --- a/core/modules/update/update.routing.yml +++ b/core/modules/update/update.routing.yml @@ -11,7 +11,7 @@ update_status: _content: '\Drupal\update\Controller\UpdateController::updateStatus' requirements: _permission: 'administer site configuration' - + update_ready: pattern: '/admin/update/ready' defaults: @@ -23,7 +23,7 @@ update_ready: update_report_install: pattern: '/admin/reports/updates/install' defaults: - _form: '\Drupal\update\Form\UpdateManagerInstall' + _form: '\Drupal\update\Form\UpdateManagerInstall' requirements: _permission: 'administer software updates' _update_manager_access: 'TRUE' @@ -35,7 +35,7 @@ update_module_install: requirements: _permission: 'administer software updates' _update_manager_access: 'TRUE' - + update_theme_install: pattern: '/admin/appearance/install' defaults: @@ -59,7 +59,7 @@ update_module_update: requirements: _permission: 'administer software updates' _update_manager_access: 'TRUE' - + update_theme_update: pattern: '/admin/appearance/update' defaults: diff --git a/core/modules/update/update.services.yml b/core/modules/update/update.services.yml index 8d0ca02..017d8a3 100644 --- a/core/modules/update/update.services.yml +++ b/core/modules/update/update.services.yml @@ -1,5 +1,6 @@ services: update.manager_access: class: Drupal\update\Access\UpdateManagerAccess + arguments: ['@settings'] tags: - { name: access_check }