diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 9820348e66b1..8eeb57f00550 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -61,14 +61,14 @@ function block_help($path, $arg) { $output .= '
' . t('Blocks can be configured to be visible only on certain pages, only to users of certain roles, or only on pages displaying certain content types. Some dynamic blocks, such as those generated by modules, will be displayed only on certain pages.', array('@content-type' => url('admin/structure/types'), '@user' => url('user'))) . '
'; if (module_exists('custom_block')) { $output .= '
' . t('Creating custom blocks') . '
'; - $output .= '
' . t('Users with the Administer blocks permission can add custom blocks, which are then listed on the Blocks administration page. Once created, custom blocks behave just like default and module-generated blocks.', array('@blocks' => url('admin/structure/block'), '@block-add' => url('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add/custom_blocks'))) . '
'; + $output .= '
' . t('Users with the Administer blocks permission can add custom blocks, which are then listed on the Blocks administration page. Once created, custom blocks behave just like default and module-generated blocks.', array('@blocks' => url('admin/structure/block'), '@block-add' => url('admin/structure/block/list/' . config('system.theme')->get('default') . '/add/custom_blocks'))) . '
'; } $output .= ''; return $output; } if ($arg[0] == 'admin' && $arg[1] == 'structure' && $arg['2'] == 'block' && (empty($arg[3]) || $arg[3] == 'list') && empty($arg[5])) { if (!empty($arg[4])) { - list(, $demo_theme) = explode(':', $arg[4]); + $demo_theme = $arg[4]; } else { $demo_theme = config('system.theme')->get('default'); @@ -136,28 +136,28 @@ function block_menu() { // and plugin IDs to decouple the routes from these dependencies and allow // hook_menu_local_tasks() to check for the untranslated tab_parent path. // @see http://drupal.org/node/1067408 - $themes = list_themes(); - foreach (drupal_container()->get('plugin.manager.system.plugin_ui')->getDefinitions() as $plugin_id => $plugin) { - list($plugin_base, $key) = explode(':', $plugin_id); - if ($plugin_base == 'block_plugin_ui') { - $theme = $themes[$key]; - $items['admin/structure/block/list/' . $plugin_id] = array( - 'title' => check_plain($theme->info['name']), - 'type' => $key == $default_theme ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, - 'route_name' => 'block_admin_display.' . $plugin_id - ); - $items['admin/structure/block/demo/' . $key] = array( - 'title' => check_plain($theme->info['name']), - 'page callback' => 'block_admin_demo', - 'page arguments' => array($key), - 'type' => MENU_CALLBACK, - 'access callback' => '_block_themes_access', - 'access arguments' => array($key), - 'theme callback' => '_block_custom_theme', - 'theme arguments' => array($key), - 'file' => 'block.admin.inc', - ); - } + foreach (list_themes() as $key => $theme) { + $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", + ); + $items["admin/structure/block/list/$key/add"] = array( + 'title' => 'Place blocks', + 'type' => MENU_LOCAL_ACTION, + 'route_name' => "block_plugin_ui.$key", + ); + $items["admin/structure/block/demo/$key"] = array( + 'title' => check_plain($theme->info['name']), + 'page callback' => 'block_admin_demo', + 'page arguments' => array($key), + 'type' => MENU_CALLBACK, + 'access callback' => '_block_themes_access', + 'access arguments' => array($key), + 'theme callback' => '_block_custom_theme', + 'theme arguments' => array($key), + 'file' => 'block.admin.inc', + ); } return $items; } diff --git a/core/modules/block/block.routing.yml b/core/modules/block/block.routing.yml index cabd4cbc1482..669e0a21239a 100644 --- a/core/modules/block/block.routing.yml +++ b/core/modules/block/block.routing.yml @@ -26,3 +26,10 @@ block_admin_add: _content: '\Drupal\block\Controller\BlockAddController::blockAddConfigureForm' requirements: _permission: 'administer blocks' + +block_autocomplete: + pattern: '/block/autocomplete' + defaults: + _controller: '\Drupal\block\Controller\BlockAutocompleteController::autocomplete' + requirements: + _permission: 'administer blocks' diff --git a/core/modules/block/block.services.yml b/core/modules/block/block.services.yml index 9b6b40d0e2a9..b361dba6b3e6 100644 --- a/core/modules/block/block.services.yml +++ b/core/modules/block/block.services.yml @@ -13,7 +13,6 @@ services: class: Drupal\block\Routing\RouteSubscriber tags: - { name: event_subscriber} - arguments: ['@plugin.manager.system.plugin_ui'] block.theme_access_check: class: Drupal\block\Access\BlockThemeAccessCheck tags: diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index 0386277e0449..6041b2c99f70 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -283,7 +283,7 @@ class BlockFormController extends EntityFormController implements EntityControll drupal_set_message(t('The block configuration has been saved.')); cache_invalidate_tags(array('content' => TRUE)); - $form_state['redirect'] = 'admin/structure/block/list/block_plugin_ui:' . $entity->get('theme'); + $form_state['redirect'] = 'admin/structure/block/list/' . $entity->get('theme'); } /** diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockAutocompleteController.php b/core/modules/block/lib/Drupal/block/Controller/BlockAutocompleteController.php new file mode 100644 index 000000000000..539a8c193d91 --- /dev/null +++ b/core/modules/block/lib/Drupal/block/Controller/BlockAutocompleteController.php @@ -0,0 +1,78 @@ +manager = $manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('plugin.manager.block') + ); + } + + /** + * Autocompletes a block plugin ID. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * The request object. + * + * @return \Symfony\Component\HttpFoundation\JsonResponse + * The matched plugins as JSON. + */ + public function autocomplete(Request $request) { + $string_typed = $request->query->get('q'); + // The passed string may be comma or space separated. + $string_typed = Tags::explode($string_typed); + // Take the last result and lowercase it. + $string = Unicode::strtolower(array_pop($string_typed)); + $matches = array(); + if ($string) { + $titles = array(); + // Gather all block plugins and their admin titles. + foreach($this->manager->getDefinitions() as $plugin_id => $plugin) { + $titles[$plugin_id] = $plugin['admin_label']; + } + // Find any matching block plugin IDs. + $matches = preg_grep("/\b". $string . "/i", $titles); + } + + return new JsonResponse($matches); + } + +} diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockListController.php b/core/modules/block/lib/Drupal/block/Controller/BlockListController.php index 832aaedea329..f31e652527d0 100644 --- a/core/modules/block/lib/Drupal/block/Controller/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/Controller/BlockListController.php @@ -18,17 +18,15 @@ class BlockListController extends EntityListController { /** * Shows the block administration page. * - * @param string $entity_type - * Entity type of list page. * @param string|null $theme * Theme key of block list. * * @return array * A render array as expected by drupal_render(). */ - public function listing($entity_type, $theme = NULL) { - $default_theme = $theme ?: $this->config('system.theme')->get('default'); - return $this->entityManager()->getListController($entity_type)->render($default_theme); + public function listing($theme = NULL) { + $theme = $theme ?: $this->config('system.theme')->get('default'); + return $this->entityManager()->getListController('block')->render($theme); } } diff --git a/core/modules/block/lib/Drupal/block/Form/PlaceBlocksForm.php b/core/modules/block/lib/Drupal/block/Form/PlaceBlocksForm.php new file mode 100644 index 000000000000..ffc4b9ef695c --- /dev/null +++ b/core/modules/block/lib/Drupal/block/Form/PlaceBlocksForm.php @@ -0,0 +1,157 @@ +manager = $manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('plugin.manager.block') + ); + } + + /** + * {@inheritdoc} + */ + public function getFormID() { + return 'block_plugin_ui'; + } + + /** + * {@inheritdoc} + */ + public function buildForm(array $form, array &$form_state, $theme = NULL, $category = NULL) { + $this->theme = $theme; + $form['#theme'] = 'system_plugin_ui_form'; + $rows = array(); + $categories = array(); + 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[$plugin_definition['category']] = array( + 'title' => $plugin_definition['category'], + 'href' => 'admin/structure/block/list/' . $this->theme . '/add/' . $plugin_definition['category'], + ); + } + + $form['right']['block'] = array( + '#type' => 'textfield', + '#title' => t('Search'), + '#autocomplete_path' => 'block/autocomplete', + ); + $form['right']['submit'] = array( + '#type' => 'submit', + '#button_type' => 'primary', + '#value' => t('Next'), + ); + $form['right']['all_plugins'] = array( + '#type' => 'link', + '#title' => t('All blocks'), + '#href' => 'admin/structure/block/list/' . $this->theme . '/add', + ); + if (!empty($categories)) { + $form['right']['categories'] = array( + '#theme' => 'links', + '#heading' => array( + 'text' => t('Categories'), + 'level' => 'h3', + ), + '#links' => $categories, + ); + } + + // Sort rows alphabetically. + asort($rows); + $form['left']['plugin_library'] = array( + '#theme' => 'table', + '#header' => array(t('Subject'), t('Operations')), + '#rows' => $rows, + ); + return $form; + } + + /** + * Generates the row data for a single block plugin. + * + * @param string $plugin_id + * The plugin ID. + * @param array $plugin_definition + * The plugin definition. + * + * @return array + * The row data for a single block plugin. + */ + protected function row($plugin_id, array $plugin_definition) { + $row = array(); + $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/' . $plugin_id . '/' . $this->theme, + ), + ), + )); + return $row; + } + + /** + * {@inheritdoc} + */ + public function validateForm(array &$form, array &$form_state) { + if (!$this->manager->getDefinition($form_state['values']['block'])) { + form_set_error('block', t('You must select a valid block.')); + } + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, array &$form_state) { + $form_state['redirect'] = 'admin/structure/block/add/' . $form_state['values']['block'] . '/' . $this->theme; + } + +} diff --git a/core/modules/block/lib/Drupal/block/Plugin/Derivative/BlockPluginUI.php b/core/modules/block/lib/Drupal/block/Plugin/Derivative/BlockPluginUI.php deleted file mode 100644 index aaeef6e2b1b2..000000000000 --- a/core/modules/block/lib/Drupal/block/Plugin/Derivative/BlockPluginUI.php +++ /dev/null @@ -1,29 +0,0 @@ - $theme) { - $this->derivatives[$key] = $base_plugin_definition; - } - return parent::getDerivativeDefinitions($base_plugin_definition); - } -} diff --git a/core/modules/block/lib/Drupal/block/Plugin/PluginUI/BlockPluginUI.php b/core/modules/block/lib/Drupal/block/Plugin/PluginUI/BlockPluginUI.php deleted file mode 100644 index de7e0791087a..000000000000 --- a/core/modules/block/lib/Drupal/block/Plugin/PluginUI/BlockPluginUI.php +++ /dev/null @@ -1,229 +0,0 @@ -getPluginId()); - $plugin_definition = $this->getPluginDefinition(); - // @todo Find out how to let the manager be injected into the class. - $manager = drupal_container()->get($plugin_definition['manager']); - $plugins = $manager->getDefinitions(); - $form['#theme'] = 'system_plugin_ui_form'; - $form['theme'] = array( - '#type' => 'value', - '#value' => $theme, - ); - $form['manager'] = array( - '#type' => 'value', - '#value' => $manager, - ); - $form['instance'] = array( - '#type' => 'value', - '#value' => $this, - ); - $form['right']['block'] = array( - '#type' => 'textfield', - '#title' => t('Search'), - '#autocomplete_path' => 'system/autocomplete/' . $this->getPluginId(), - ); - $form['right']['submit'] = array( - '#type' => 'submit', - '#value' => t('Next'), - ); - $rows = array(); - foreach ($plugins as $plugin_id => $display_plugin_definition) { - if (empty($facet) || $this->facetCompare($facet, $display_plugin_definition)) { - $rows[$plugin_id] = $this->row($plugin_id, $display_plugin_definition); - } - foreach ($plugin_definition['facets'] as $key => $title) { - $facets[$key][$display_plugin_definition[$key]] = $this->facetLink($key, $plugin_id, $display_plugin_definition); - } - $form['right']['all_plugins'] = array( - '#type' => 'link', - '#title' => $plugin_definition['all_plugins'], - '#href' => $this->allPluginsUrl($plugin_id, $display_plugin_definition), - ); - foreach ($facets as $group => $values) { - $form['right'][$group] = array( - '#theme' => 'links', - '#heading' => array( - 'text' => $plugin_definition['facets'][$group], - 'level' => 'h3', - ), - '#links' => $values, - ); - } - } - // Sort rows alphabetically. - asort($rows); - $form['left']['plugin_library'] = array( - '#theme' => 'table', - '#header' => $this->tableHeader(), - '#rows' => $rows, - ); - return $form; - } - - /** - * Overrides \Drupal\system\Plugin\PluginUIBase::formValidate(). - */ - public function formValidate($form, &$form_state) { - $definitions = $form_state['values']['manager']->getDefinitions(); - if (!isset($definitions[$form_state['values']['block']])) { - form_set_error('block', t('You must select a valid block.')); - } - } - - /** - * Overrides \Drupal\system\Plugin\PluginUIBase::formSubmit(). - */ - public function formSubmit($form, &$form_state) { - $form_state['redirect'] = 'admin/structure/block/add/' . $form_state['values']['block'] . '/' . $form_state['values']['theme']; - } - - /** - * Overrides \Drupal\system\Plugin\PluginUIBase::access(). - */ - public function access() { - list($plugin, $theme) = explode(':', $this->getPluginId()); - return _block_themes_access($theme); - } - - /** - * Overrides \Drupal\system\Plugin\PluginUIBase::tableHeader(). - */ - public function tableHeader() { - return array(t('Subject'), t('Operations')); - } - - /** - * Overrides \Drupal\system\Plugin\PluginUIBase::row(). - */ - public function row($display_plugin_id, array $display_plugin_definition) { - $plugin_definition = $this->getPluginDefinition(); - list($plugin, $theme) = explode(':', $this->getPluginId()); - $row = array(); - $row[] = check_plain($display_plugin_definition['admin_label']); - $row[] = array('data' => array( - '#type' => 'operations', - '#links' => array( - 'configure' => array( - 'title' => $plugin_definition['link_title'], - 'href' => $plugin_definition['config_path'] . '/' . $display_plugin_id . '/' . $theme, - ), - ), - )); - return $row; - } - - /** - * Creates a facet link for a given facet of a display plugin. - * - * Provides individually formatted links for the faceting that happens within - * the user interface. Since this is a faceting style procedure, each plugin - * may be parsed multiple times in order to extract all facets and their - * appropriate labels. - * - * The $display_plugin_id and $display_plugin_definition are provided for - * convenience when overriding this method. - * - * @param string $facet - * A simple string indicating what element of the $display_plugin_definition - * to utilize for faceting. - * @param string $display_plugin_id - * The plugin ID of the plugin we are currently parsing a facet link from. - * @param array $display_plugin_definition - * The plugin definition we are parsing. - * - * @return array - * Returns a row array comaptible with theme_links(). - */ - protected function facetLink($facet, $display_plugin_id, array $display_plugin_definition) { - $plugin_definition = $this->getPluginDefinition(); - return array( - 'title' => $display_plugin_definition[$facet], - 'href' => $plugin_definition['path'] . '/' . $this->getPluginId() . '/' . $facet . ':' . $display_plugin_definition[$facet], - ); - } - - /** - * Determines whether a given facet should be displayed for a plugin. - * - * Compares a given plugin definition with the selected facet to determine if - * the plugin should be displayed in the user interface. - * - * @param string $facet - * A colon separated string representing the key/value paring of a selected - * facet. - * @param array $display_plugin_definition - * The plugin definition to be compared. - * - * @return bool - * Returns TRUE if the selected facet matches this plugin. - */ - protected function facetCompare($facet, $display_plugin_definition) { - list($facet_type, $option) = explode(':', $facet); - return $option == $display_plugin_definition[$facet_type]; - } - - /** - * Provides an "all" style link to reset the facets. - * - * The $display_plugin_id and $display_plugin_definition are provided for - * convenience when overriding this method. - * - * @param string $display_plugin_id - * The plugin ID of the plugin we are currently parsing a facet link from. - * @param array $display_plugin_definition - * The plugin definition we are parsing. - * - * @return string - * Returns a simple URL string for use within l(). - */ - protected function allPluginsUrl($display_plugin_id, $display_plugin_definition) { - $plugin_definition = $this->getPluginDefinition(); - return $plugin_definition['path'] . '/' . $this->getPluginId() . '/add'; - } - -} diff --git a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php index 34daaca738f6..7a50351836af 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php @@ -1,6 +1,7 @@ alterInfo($module_handler, 'block'); $this->setCacheBackend($cache_backend, $language_manager, 'block_plugins'); } + + /** + * {@inheritdoc} + */ + public function processDefinition(&$definition, $plugin_id) { + parent::processDefinition($definition, $plugin_id); + + // Ensure that every block has a category. + $definition += array( + 'category' => $definition['provider'], + ); + } + } diff --git a/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php b/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php index deea1f4018d8..de32cd162728 100644 --- a/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php +++ b/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php @@ -1,4 +1,5 @@ pluginManager = $plugin_manager; - } - /** * Implements EventSubscriberInterface::getSubscribedEvents(). */ @@ -55,18 +37,32 @@ class RouteSubscriber implements EventSubscriberInterface { */ public function routes(RouteBuildEvent $event) { $collection = $event->getRouteCollection(); - foreach ($this->pluginManager->getDefinitions() as $plugin_id => $plugin) { - list($plugin_base, $key) = explode(':', $plugin_id); - if ($plugin_base == 'block_plugin_ui') { - $route = new Route('admin/structure/block/list/' . $plugin_id, array( + 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', - 'entity_type' => 'block', 'theme' => $key, - ), array( + ), + array( '_block_themes_access' => 'TRUE', - )); - $collection->add('block_admin_display.' . $plugin_id, $route); - } + ) + ); + $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') + ); + $collection->add("block_plugin_ui.$key", $route); } } + } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php index 8c64ac879ba1..c3a220f4d4db 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php @@ -38,14 +38,14 @@ class BlockAdminThemeTest extends WebTestBase { $this->drupalLogin($admin_user); // Ensure that access to block admin page is denied when theme is disabled. - $this->drupalGet('admin/structure/block/list/block_plugin_ui:bartik'); + $this->drupalGet('admin/structure/block/list/bartik'); $this->assertResponse(403); // Enable admin theme and confirm that tab is accessible. theme_enable(array('bartik')); $edit['admin_theme'] = 'bartik'; $this->drupalPost('admin/appearance', $edit, t('Save configuration')); - $this->drupalGet('admin/structure/block/list/block_plugin_ui:bartik'); + $this->drupalGet('admin/structure/block/list/bartik'); $this->assertResponse(200); } } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockLibrarySearchTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockLibrarySearchTest.php index 22f47e8c6b46..8dcfeaa13fe8 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockLibrarySearchTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockLibrarySearchTest.php @@ -49,11 +49,11 @@ class BlockLibrarySearchTest extends WebTestBase { */ function testBlockLibrarySearch() { // Check that the block plugin is valid. - $this->drupalPost('admin/structure/block/list/block_plugin_ui:stark/add', array('block' => 'invalid_block'), t('Next')); + $this->drupalPost('admin/structure/block/list/stark/add', array('block' => 'invalid_block'), t('Next')); $this->assertText('You must select a valid block.'); // Check that the block search form redirects to the correct block form. - $this->drupalPost('admin/structure/block/list/block_plugin_ui:stark/add', array('block' => 'system_main_block'), t('Next')); + $this->drupalPost('admin/structure/block/list/stark/add', array('block' => 'system_main_block'), t('Next')); $this->assertUrl('admin/structure/block/add/system_main_block/stark'); } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php index e665609d976e..c766053042e9 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php @@ -274,7 +274,7 @@ class BlockTest extends BlockTestBase { } // Ensure that the disabled module's block plugin is no longer available. - $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add'); + $this->drupalGet('admin/structure/block/list/' . config('system.theme')->get('default') . '/add'); $this->assertNoText(t('Test block caching')); // Confirm that the block is no longer displayed on the front page. diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php index 6562545c527d..3036ecd81ea0 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php @@ -45,7 +45,7 @@ class BlockTitleXSSTest extends WebTestBase { $this->drupalLogin($this->drupalCreateUser(array('administer blocks', 'access administration pages'))); $default_theme = config('system.theme')->get('default'); - $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . $default_theme . '/add'); + $this->drupalGet('admin/structure/block/list/' . $default_theme . '/add'); $this->assertNoRaw("", 'The block title was properly sanitized in Block Plugin UI Admin page.'); } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php index 7ad84e19e891..62d24981a055 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php @@ -110,7 +110,7 @@ class BlockUiTest extends WebTestBase { */ function testBlockSearch() { $block = t('Administration'); - $blocks = drupal_json_decode($this->drupalGet('system/autocomplete/block_plugin_ui:stark', array('query' => array('q' => $block)))); + $blocks = drupal_json_decode($this->drupalGet('block/autocomplete', array('query' => array('q' => $block)))); $this->assertEqual($blocks['system_menu_block:menu-admin'], $block, t('Can search for block with name !block.', array('!block' => $block))); } diff --git a/core/modules/block/lib/Drupal/block/Tests/NonDefaultBlockAdminTest.php b/core/modules/block/lib/Drupal/block/Tests/NonDefaultBlockAdminTest.php index 7cf114c877fd..72f3d1d116cb 100644 --- a/core/modules/block/lib/Drupal/block/Tests/NonDefaultBlockAdminTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/NonDefaultBlockAdminTest.php @@ -34,7 +34,7 @@ class NonDefaultBlockAdminTest extends WebTestBase { $this->drupalLogin($admin_user); $new_theme = 'bartik'; theme_enable(array($new_theme)); - $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . $new_theme); + $this->drupalGet('admin/structure/block/list/' . $new_theme); $this->assertText('Bartik(' . t('active tab') . ')', 'Tab for non-default theme found.'); } } diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php index 1303f4365b69..0ae93d41e500 100644 --- a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php +++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php @@ -161,7 +161,7 @@ class MenuTest extends MenuWebTestBase { // Enable the custom menu block. $menu_name = 'menu-' . $menu_name; // Drupal prepends the name with 'menu-'. // Confirm that the custom menu block is available. - $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add'); + $this->drupalGet('admin/structure/block/list/' . config('system.theme')->get('default') . '/add'); $this->assertText($label); // Enable the block. @@ -379,7 +379,7 @@ class MenuTest extends MenuWebTestBase { // Make sure menu shows up with new name in block addition. $default_theme = variable_get('theme_default', 'stark'); - $this->drupalget('admin/structure/block/list/block_plugin_ui:' . $default_theme . '/add'); + $this->drupalget('admin/structure/block/list/' . $default_theme . '/add'); $this->assertText($edit['label']); } diff --git a/core/modules/system/lib/Drupal/system/Access/SystemPluginUiCheck.php b/core/modules/system/lib/Drupal/system/Access/SystemPluginUiCheck.php deleted file mode 100644 index db13644f9617..000000000000 --- a/core/modules/system/lib/Drupal/system/Access/SystemPluginUiCheck.php +++ /dev/null @@ -1,55 +0,0 @@ -pluginUiManager = $plugin_ui_manager; - } - - /** - * {@inheritdoc} - */ - public function applies(Route $route) { - return array_key_exists('_access_system_plugin_ui', $route->getRequirements()); - } - - /** - * {@inheritdoc} - */ - public function access(Route $route, Request $request) { - if ($request->attributes->get('plugin_id')) { - // Checks access for a given plugin using the plugin's access() method. - $plugin_ui = $this->pluginUiManager->createInstance($request->attributes->get('plugin_id'), array()); - return $plugin_ui->access(NULL) ? static::ALLOW : static::DENY; - } - } - -} diff --git a/core/modules/system/lib/Drupal/system/Controller/SystemController.php b/core/modules/system/lib/Drupal/system/Controller/SystemController.php deleted file mode 100644 index bd71353d88b8..000000000000 --- a/core/modules/system/lib/Drupal/system/Controller/SystemController.php +++ /dev/null @@ -1,56 +0,0 @@ -query->get('q'); - $string_typed = Tags::explode($string_typed); - $string = Unicode::strtolower(array_pop($string_typed)); - $matches = array(); - if ($string) { - $plugin_ui = $this->container->get('plugin.manager.system.plugin_ui')->getDefinition($plugin_id); - $manager = $this->container->get($plugin_ui['manager']); - $titles = array(); - foreach($manager->getDefinitions() as $plugin_id => $plugin) { - $titles[$plugin_id] = $plugin[$plugin_ui['title_attribute']]; - } - $matches = preg_grep("/\b". $string . "/i", $titles); - } - - return new JsonResponse($matches); - } - -} diff --git a/core/modules/system/lib/Drupal/system/Plugin/Type/PluginUIManager.php b/core/modules/system/lib/Drupal/system/Plugin/Type/PluginUIManager.php deleted file mode 100644 index 9328a5c3394d..000000000000 --- a/core/modules/system/lib/Drupal/system/Plugin/Type/PluginUIManager.php +++ /dev/null @@ -1,51 +0,0 @@ -discovery = new AnnotatedClassDiscovery('Plugin/PluginUI', $namespaces); - $this->discovery = new DerivativeDiscoveryDecorator($this->discovery); - $this->discovery = new AlterDecorator($this->discovery, 'plugin_ui'); - $this->discovery = new CacheDecorator($this->discovery, 'plugin_ui'); - $this->factory = new DefaultFactory($this->discovery); - } - - /** - * Overrides \Drupal\Component\Plugin\PluginManagerBase::processDefinition(). - */ - public function processDefinition(&$definition, $plugin_id) { - $definition += array( - 'default_task' => TRUE, - 'task_title' => t('View'), - 'task_suffix' => 'view', - 'access_callback' => 'user_access', - ); - } - -} diff --git a/core/modules/system/system.module b/core/modules/system/system.module index fc7bb6df23fe..1935f5c5c90d 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -964,83 +964,9 @@ function system_menu() { ); } - foreach (drupal_container()->get('plugin.manager.system.plugin_ui')->getDefinitions() as $plugin_id => $plugin) { - if ($plugin['menu'] === TRUE) { - $items[$plugin['path'] . '/' . $plugin_id . '/' . $plugin['suffix']] = array( - 'title' => $plugin['title'], - 'page callback' => 'drupal_get_form', - 'page arguments' => array($plugin['id'], $plugin_id), - 'access callback' => 'system_plugin_ui_access', - 'access arguments' => array($plugin_id), - 'type' => $plugin['type'], - ); - if (!empty($plugin['default_task'])) { - $items[$plugin['path'] . '/' . $plugin_id . '/' . $plugin['suffix'] . '/' . $plugin['task_suffix']] = array( - 'title' => $plugin['task_title'], - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, - ); - } - $items[$plugin['path'] . '/' . $plugin_id . '/%'] = array( - 'title' => $plugin['title'], - 'page callback' => 'drupal_get_form', - 'page arguments' => array($plugin['id'], $plugin_id, (count(explode('/', $plugin['path'])) + 1)), - 'access callback' => 'system_plugin_ui_access', - 'access arguments' => array($plugin_id, (count(explode('/', $plugin['path'])) + 1)), - 'type' => MENU_CALLBACK, - ); - if (!empty($plugin['file'])) { - $items[$plugin['path'] . '/' . $plugin_id . '/' . $plugin['suffix']]['file'] = $plugin['file']; - $items[$plugin['path'] . '/' . $plugin_id . '/%']['file'] = $plugin['file']; - if (!empty($plugin['file_path'])) { - $items[$plugin['path'] . '/' . $plugin_id . '/' . $plugin['suffix']]['file path'] = $plugin['file_path']; - $items[$plugin['path'] . '/' . $plugin_id . '/%']['file path'] = $plugin['file_path']; - } - } - } - } - return $items; } -/** - * Proxies to the plugin class' form method. - * - * @todo This needs more explanation, an @see or two, and parameter - * documentation. Also "proxies" is a weird word to use. - */ -function system_plugin_ui_form($form, &$form_state, $plugin, $facet = NULL) { - $plugin_ui = drupal_container()->get('plugin.manager.system.plugin_ui')->createInstance($plugin); - $form = $plugin_ui->form($form, $form_state, $facet); - $form['#validate'][] = array($plugin_ui, 'formValidate'); - $form['#submit'][] = array($plugin_ui, 'formSubmit'); - return $form; -} - -/** - * Checks access for a given plugin using the plugin's access() method. - * - * @todo This needs more explanation, some @see, and parameter documentation. - * @todo What the heck kind of parameter name is "facet"? - */ -function system_plugin_ui_access($plugin, $facet = NULL) { - $plugin_ui = drupal_container()->get('plugin.manager.system.plugin_ui')->createInstance($plugin); - return $plugin_ui->access($facet); -} - -/** - * Implements hook_forms(). - */ -function system_forms() { - $forms = array(); - foreach (drupal_container()->get('plugin.manager.system.plugin_ui')->getDefinitions() as $plugin_id => $plugin) { - if (empty($forms[$plugin['id']])) { - $forms[$plugin['id']]['callback'] = 'system_plugin_ui_form'; - } - } - return $forms; -} - /** * Theme callback for the default batch page. */ diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index 61363d6cda3e..017d4868c455 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -213,10 +213,3 @@ system_timezone: _controller: '\Drupal\system\Controller\TimezoneController::getTimezone' requirements: _access: 'TRUE' - -system_plugin_autocomplete: - pattern: '/system/autocomplete/{plugin_id}' - defaults: - _controller: 'Drupal\system\Controller\SystemController::autocomplete' - requirements: - _access_system_plugin_ui: 'TRUE' diff --git a/core/modules/system/system.services.yml b/core/modules/system/system.services.yml index 0c770d364b98..08d67adf70bd 100644 --- a/core/modules/system/system.services.yml +++ b/core/modules/system/system.services.yml @@ -3,14 +3,6 @@ services: class: Drupal\system\Access\CronAccessCheck tags: - { name: access_check } - access_check.system_plugin_ui: - class: Drupal\system\Access\SystemPluginUiCheck - tags: - - { name: access_check } - arguments: ['@plugin.manager.system.plugin_ui'] - plugin.manager.system.plugin_ui: - class: Drupal\system\Plugin\Type\PluginUIManager - arguments: ['@container.namespaces'] system.manager: class: Drupal\system\SystemManager arguments: ['@module_handler', '@database'] diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php index 0a8f18eba7cb..8f3f4eb26833 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php @@ -122,7 +122,7 @@ class BasicTest extends WizardTestBase { $this->assertLinkByHref(url($view3['page[path]'])); // Confirm that the block is available in the block administration UI. - $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add'); + $this->drupalGet('admin/structure/block/list/' . config('system.theme')->get('default') . '/add'); $this->assertText('View: ' . $view3['label']); // Place the block. diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php index e6808c74c505..485f048c1363 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php @@ -75,7 +75,7 @@ class ItemsPerPageTest extends WizardTestBase { $this->assertTrue($pos5 < $pos4 && $pos4 < $pos3 && $pos3 < $pos2, 'The nodes appear in the expected order in the page display.'); // Confirm that the block is listed in the block administration UI. - $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add'); + $this->drupalGet('admin/structure/block/list/' . config('system.theme')->get('default') . '/add'); $this->assertText('View: ' . $view['label']); // Place the block, visit a page that displays the block, and check that the diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/OverrideDisplaysTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/OverrideDisplaysTest.php index 38b3d36b4b8a..1dab1f66a97b 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/OverrideDisplaysTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/OverrideDisplaysTest.php @@ -54,7 +54,7 @@ class OverrideDisplaysTest extends UITestBase { $this->assertText($original_title); // Confirm that the view block is available in the block administration UI. - $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add'); + $this->drupalGet('admin/structure/block/list/' . config('system.theme')->get('default') . '/add'); $this->assertText('View: ' . $view['label']); // Place the block. @@ -112,7 +112,7 @@ class OverrideDisplaysTest extends UITestBase { $this->assertNoText($view['block[title]']); // Confirm that the block is available in the block administration UI. - $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add'); + $this->drupalGet('admin/structure/block/list/' . config('system.theme')->get('default') . '/add'); $this->assertText('View: ' . $view['label']); // Put the block into the first sidebar region, and make sure it will not