diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index d33d1ee..2298c9b 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1989,6 +1989,8 @@ function _current_path($path = NULL) { * The component specified by $index, or NULL if the specified component was * not found. If called without arguments, it returns an array containing all * the components of the current path. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. */ function arg($index = NULL, $path = NULL) { // Even though $arguments doesn't need to be resettable for any functional diff --git a/core/includes/theme.inc b/core/includes/theme.inc index e44f13d..28cd44c 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1984,8 +1984,9 @@ function template_preprocess_html(&$variables) { $body_classes[] = $variables['logged_in'] ? 'logged-in' : 'not-logged-in'; $variables['attributes']['class'] = $body_classes; + $path_args = explode('/', current_path()); // Populate the body classes. - if ($suggestions = theme_get_suggestions(arg(), 'page', '-')) { + if ($suggestions = theme_get_suggestions($path_args, 'page', '-')) { foreach ($suggestions as $suggestion) { if ($suggestion != 'page-front') { // Add current suggestion to page classes to make it possible to theme @@ -2067,7 +2068,7 @@ function template_preprocess_html(&$variables) { * inside "modules/system/page.html.twig". Look in there for the full list of * variables. * - * Uses the arg() function to generate a series of page template suggestions + * Uses the request object to generate a series of page template suggestions * based on the current path. * * @see drupal_render_page() @@ -2186,7 +2187,7 @@ function template_preprocess_page(&$variables) { * additional suggestions or classes on the path of the current page. * * @param $args - * An array of path arguments, such as from function arg(). + * An array of path arguments. * @param $base * A string identifying the base 'thing' from which more specific suggestions * are derived. For example, 'page' or 'html'. diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedForm.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedForm.php index 1770f03..675627c 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/FeedForm.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedForm.php @@ -66,12 +66,7 @@ public function save(array $form, array &$form_state) { $feed->save(); if ($insert) { drupal_set_message($this->t('The feed %feed has been updated.', array('%feed' => $feed->label()))); - if (arg(0) == 'admin') { - $form_state['redirect_route']['route_name'] = 'aggregator.admin_overview'; - } - else { - $form_state['redirect_route'] = $feed->urlInfo('canonical'); - } + $form_state['redirect_route'] = $feed->urlInfo('canonical'); } else { watchdog('aggregator', 'Feed %feed added.', array('%feed' => $feed->label()), WATCHDOG_NOTICE, l($this->t('View'), 'admin/config/services/aggregator')); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php index 7cc3827..aa21ea2 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php @@ -44,12 +44,7 @@ public function submit(array $form, array &$form_state) { $this->entity->delete(); watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $this->entity->label())); drupal_set_message($this->t('The feed %feed has been deleted.', array('%feed' => $this->entity->label()))); - if (arg(0) == 'admin') { - $form_state['redirect_route']['route_name'] = 'aggregator.admin_overview'; - } - else { - $form_state['redirect_route']['route_name'] = 'aggregator.sources'; - } + $form_state['redirect_route']['route_name'] = 'aggregator.sources'; } } diff --git a/core/modules/dblog/dblog.libraries.yml b/core/modules/dblog/dblog.libraries.yml new file mode 100644 index 0000000..d871d09 --- /dev/null +++ b/core/modules/dblog/dblog.libraries.yml @@ -0,0 +1,5 @@ +drupal.dblog: + version: VERSION + css: + component: + css/dblog.module.css: {} diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module index 56ce643..80e4700 100644 --- a/core/modules/dblog/dblog.module +++ b/core/modules/dblog/dblog.module @@ -54,15 +54,6 @@ function dblog_menu_link_defaults_alter(&$links) { } /** - * Implements hook_page_build(). - */ -function dblog_page_build(&$page) { - if (arg(0) == 'admin' && arg(1) == 'reports') { - $page['#attached']['css'][] = drupal_get_path('module', 'dblog') . '/css/dblog.module.css'; - } -} - -/** * Implements hook_cron(). * * Controls the size of the log table, paring it to 'dblog_row_limit' messages. diff --git a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php index 72ddf22..1f9f48d 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php +++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php @@ -210,6 +210,9 @@ public function overview() { '#rows' => $rows, '#attributes' => array('id' => 'admin-dblog', 'class' => array('admin-dblog')), '#empty' => $this->t('No log messages available.'), + '#attached' => array( + 'library' => array('dblog/drupal.dblog'), + ), ); $build['dblog_pager'] = array('#theme' => 'pager'); @@ -283,6 +286,9 @@ public function eventDetails($event_id) { '#type' => 'table', '#rows' => $rows, '#attributes' => array('class' => array('dblog-event')), + '#attached' => array( + 'library' => array('dblog/drupal.dblog'), + ), ); } @@ -383,6 +389,9 @@ public function topLogMessages($type) { '#header' => $header, '#rows' => $rows, '#empty' => $this->t('No log messages available.'), + '#attached' => array( + 'library' => array('dblog/drupal.dblog'), + ), ); $build['dblog_top_pager'] = array('#theme' => 'pager'); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 8feb47b..1090887 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -651,14 +651,16 @@ function system_element_info() { * Implements hook_theme_suggestions_HOOK(). */ function system_theme_suggestions_html(array $variables) { - return theme_get_suggestions(arg(), 'html'); + $path_args = explode('/', current_path()); + return theme_get_suggestions($path_args, 'html'); } /** * Implements hook_theme_suggestions_HOOK(). */ function system_theme_suggestions_page(array $variables) { - return theme_get_suggestions(arg(), 'page'); + $path_args = explode('/', current_path()); + return theme_get_suggestions($path_args, 'page'); } /** diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php index 33b35a8..f7a097d 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Plugin\views\argument_default; +use Drupal\taxonomy\TermInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase; @@ -159,8 +160,8 @@ public function submitOptionsForm(&$form, &$form_state, &$options = array()) { public function getArgument() { // Load default argument from taxonomy page. if (!empty($this->options['term_page'])) { - if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) { - return arg(2); + if (($taxonomy_term = $this->request->attributes->get('taxonomy_term')) && $taxonomy_term instanceof TermInterface) { + return $taxonomy_term->id(); } } // Load default argument from node. diff --git a/core/modules/update/lib/Drupal/update/Tests/UpdateCoreTest.php b/core/modules/update/lib/Drupal/update/Tests/UpdateCoreTest.php index 7928455..00782b8 100644 --- a/core/modules/update/lib/Drupal/update/Tests/UpdateCoreTest.php +++ b/core/modules/update/lib/Drupal/update/Tests/UpdateCoreTest.php @@ -29,7 +29,7 @@ public static function getInfo() { function setUp() { parent::setUp(); - $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer modules')); + $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer modules', 'administer themes')); $this->drupalLogin($admin_user); } diff --git a/core/modules/update/update.module b/core/modules/update/update.module index 6341857..ee2f107 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -12,6 +12,7 @@ */ use Drupal\Core\Site\Settings; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Component\HttpFoundation\Request; // These are internally used constants for this code, do not modify. @@ -97,8 +98,11 @@ function update_help($route_name, Request $request) { * Implements hook_page_build(). */ function update_page_build() { - if (arg(0) == 'admin' && user_access('administer site configuration')) { - switch (current_path()) { + /** @var \Drupal\Core\Routing\AdminContext $admin_context */ + $admin_context = \Drupal::service('router.admin_context'); + if ($admin_context->isAdminRoute(\Drupal::request()->attributes->get(RouteObjectInterface::ROUTE_OBJECT)) && \Drupal::currentUser()->hasPermission('administer site configuration')) { + $current_path = current_path(); + switch ($current_path) { // These pages don't need additional nagging. case 'admin/appearance/update': case 'admin/appearance/install': diff --git a/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php b/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php index b2cff4c..3466c21 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php +++ b/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php @@ -9,6 +9,7 @@ use Drupal\Core\Session\AccountInterface; use Drupal\block\BlockBase; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; /** * Provides a 'User login' block. @@ -25,7 +26,8 @@ class UserLoginBlock extends BlockBase { * {@inheritdoc} */ public function access(AccountInterface $account) { - return (!$account->id() && !(arg(0) == 'user' && !is_numeric(arg(1)))); + $route_name = \Drupal::request()->attributes->get(RouteObjectInterface::ROUTE_NAME); + return ($account->isAnonymous() && !in_array($route_name, array('user.register', 'user.login', 'user.logout'))); } /** diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index 750546f..493c765 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -16,6 +16,7 @@ use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\PluginBase; use Drupal\views\Views; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Component\DependencyInjection\Exception\RuntimeException as DependencyInjectionRuntimeException; /** @@ -2399,8 +2400,9 @@ public function getSpecialBlocks() { * The rendered exposed form as string or NULL otherwise. */ public function viewExposedFormBlocks() { - // avoid interfering with the admin forms. - if (arg(0) == 'admin' && arg(1) == 'structure' && arg(2) == 'views') { + // Avoid interfering with the admin forms. + $route_name = \Drupal::request()->attributes->get(RouteObjectInterface::ROUTE_NAME); + if (strpos($route_name, 'views_ui.') === 0) { return; } $this->view->initHandlers();