diff --git a/core/modules/block/block.module b/core/modules/block/block.module index b6f7fed..8eeb57f 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -137,17 +137,17 @@ function block_menu() { // hook_menu_local_tasks() to check for the untranslated tab_parent path. // @see http://drupal.org/node/1067408 foreach (list_themes() as $key => $theme) { - $items['admin/structure/block/list/' . $key] = array( + $items["admin/structure/block/list/$key"] = array( 'title' => check_plain($theme->info['name']), 'type' => $key == $default_theme ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, - 'route_name' => 'block_admin_display.' . $key, + 'route_name' => "block_admin_display.$key", ); - $items['admin/structure/block/list/' . $key . '/add'] = array( + $items["admin/structure/block/list/$key/add"] = array( 'title' => 'Place blocks', 'type' => MENU_LOCAL_ACTION, - 'route_name' => 'block_plugin_ui.' . $key, + 'route_name' => "block_plugin_ui.$key", ); - $items['admin/structure/block/demo/' . $key] = array( + $items["admin/structure/block/demo/$key"] = array( 'title' => check_plain($theme->info['name']), 'page callback' => 'block_admin_demo', 'page arguments' => array($key), diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockAutocompleteController.php b/core/modules/block/lib/Drupal/block/Controller/BlockAutocompleteController.php index 7eb6dda..539a8c1 100644 --- a/core/modules/block/lib/Drupal/block/Controller/BlockAutocompleteController.php +++ b/core/modules/block/lib/Drupal/block/Controller/BlockAutocompleteController.php @@ -28,7 +28,7 @@ class BlockAutocompleteController implements ControllerInterface { protected $manager; /** - * Constructs a new PlaceBlocksForm object. + * Constructs a new BlockAutocompleteController object. * * @param \Drupal\Component\Plugin\PluginManagerInterface $manager * The block plugin manager. diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockListController.php b/core/modules/block/lib/Drupal/block/Controller/BlockListController.php index c1fa2b5..b699903 100644 --- a/core/modules/block/lib/Drupal/block/Controller/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/Controller/BlockListController.php @@ -64,8 +64,8 @@ public static function create(ContainerInterface $container) { * A render array as expected by drupal_render(). */ public function listing($theme = NULL) { - $default_theme = $theme ?: $this->configFactory->get('system.theme')->get('default'); - return $this->blockListController->render($default_theme); + $theme = $theme ?: $this->configFactory->get('system.theme')->get('default'); + return $this->blockListController->render($theme); } } diff --git a/core/modules/block/lib/Drupal/block/Form/PlaceBlocksForm.php b/core/modules/block/lib/Drupal/block/Form/PlaceBlocksForm.php index ad661ac..ffc4b9e 100644 --- a/core/modules/block/lib/Drupal/block/Form/PlaceBlocksForm.php +++ b/core/modules/block/lib/Drupal/block/Form/PlaceBlocksForm.php @@ -8,6 +8,7 @@ namespace Drupal\block\Form; use Drupal\Component\Plugin\PluginManagerInterface; +use Drupal\Component\Utility\String; use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Form\FormInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -25,6 +26,8 @@ class PlaceBlocksForm implements FormInterface, ControllerInterface { protected $manager; /** + * The theme this block will be placed into. + * * @var string */ protected $theme; @@ -63,13 +66,13 @@ public function buildForm(array $form, array &$form_state, $theme = NULL, $categ $form['#theme'] = 'system_plugin_ui_form'; $rows = array(); $categories = array(); - foreach ($this->manager->getDefinitions() as $plugin_id => $display_plugin_definition) { - if (empty($category) || $display_plugin_definition['category'] == $category) { - $rows[$plugin_id] = $this->row($plugin_id, $display_plugin_definition); + foreach ($this->manager->getDefinitions() as $plugin_id => $plugin_definition) { + if (empty($category) || $plugin_definition['category'] == $category) { + $rows[$plugin_id] = $this->row($plugin_id, $plugin_definition); } - $categories[$display_plugin_definition['category']] = array( - 'title' => $display_plugin_definition['category'], - 'href' => 'admin/structure/block/list/' . $this->theme . '/add/' . $display_plugin_definition['category'], + $categories[$plugin_definition['category']] = array( + 'title' => $plugin_definition['category'], + 'href' => 'admin/structure/block/list/' . $this->theme . '/add/' . $plugin_definition['category'], ); } @@ -112,23 +115,23 @@ public function buildForm(array $form, array &$form_state, $theme = NULL, $categ /** * Generates the row data for a single block plugin. * - * @param string $display_plugin_id + * @param string $plugin_id * The plugin ID. - * @param array $display_plugin_definition + * @param array $plugin_definition * The plugin definition. * * @return array * The row data for a single block plugin. */ - public function row($display_plugin_id, array $display_plugin_definition) { + protected function row($plugin_id, array $plugin_definition) { $row = array(); - $row[] = check_plain($display_plugin_definition['admin_label']); + $row[] = String::checkPlain($plugin_definition['admin_label']); $row[] = array('data' => array( '#type' => 'operations', '#links' => array( 'configure' => array( 'title' => t('Place block'), - 'href' => 'admin/structure/block/add/' . $display_plugin_id . '/' . $this->theme, + 'href' => 'admin/structure/block/add/' . $plugin_id . '/' . $this->theme, ), ), )); diff --git a/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php b/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php index 2cc0c5e..de32cd1 100644 --- a/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php +++ b/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php @@ -39,22 +39,28 @@ public function routes(RouteBuildEvent $event) { $collection = $event->getRouteCollection(); foreach (list_themes(TRUE) as $key => $theme) { // The block entity listing page. - $route = new Route('admin/structure/block/list/' . $key, array( - '_controller' => '\Drupal\block\Controller\BlockListController::listing', - 'theme' => $key, - ), array( - '_block_themes_access' => 'TRUE', - )); + $route = new Route( + "admin/structure/block/list/$key", + array( + '_controller' => '\Drupal\block\Controller\BlockListController::listing', + 'theme' => $key, + ), + array( + '_block_themes_access' => 'TRUE', + ) + ); $collection->add("block_admin_display.$key", $route); // The block plugin listing page. - $route = new Route('admin/structure/block/list/' . $key . '/add/{category}', array( - '_form' => '\Drupal\block\Form\PlaceBlocksForm', - 'category' => NULL, - 'theme' => $key, - ), array( - '_block_themes_access' => 'TRUE', - )); + $route = new Route( + "admin/structure/block/list/$key/add/{category}", + array( + '_form' => '\Drupal\block\Form\PlaceBlocksForm', + 'category' => NULL, + 'theme' => $key, + ), + array('_block_themes_access' => 'TRUE') + ); $collection->add("block_plugin_ui.$key", $route); } }