diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 2fa1796..1eb63b6 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2493,9 +2493,6 @@ function drupal_container(Container $new_container = NULL, $rebuild = FALSE) { // Register the EntityManager. $container->register('plugin.manager.entity', 'Drupal\Core\Entity\EntityManager'); - - // Register the Plugin UI. - $container->register('plugin.manager.system.plugin_ui', 'Drupal\system\Plugin\Type\PluginUIManager'); } return $container; } diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index b429d6c..072e109 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -204,12 +204,6 @@ public function updateModules(array $module_list, array $module_paths = array()) // list will take effect when boot() is called. If we have already booted, // then reboot in order to refresh the bundle list and container. if ($this->booted) { - // @todo Determine if there is another way to prevent old containers from - // being used. - // Explicitly prevent old compiled containers from being used. - if ($this->compilationIndexCache) { - $this->compilationIndexCache->flush(); - } drupal_container(NULL, TRUE); $this->booted = FALSE; $this->boot(); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/FeedBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/FeedBlock.php index 963e3b1..909f676 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/FeedBlock.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/FeedBlock.php @@ -63,8 +63,8 @@ public function configureSubmit($form, &$form_state) { * Overrides \Drupal\block\BlockBase::build(). */ public function build() { - // Plugin ids look something like this: aggregator_feed_block:1. - $id = substr($this->getPluginId(), 22); + // Plugin IDs look something like this: aggregator_feed_block:1. + list(, $id) = explode(':', $this->getPluginId()); if ($feed = db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = :fid', array(':fid' => $id))->fetchObject()) { $result = db_query_range("SELECT * FROM {aggregator_item} WHERE fid = :fid ORDER BY timestamp DESC, iid DESC", 0, $this->configuration['block_count'], array(':fid' => $id)); $read_more = theme('more_link', array('url' => 'aggregator/sources/' . $feed->fid, 'title' => t("View this feed's recent news."))); diff --git a/core/modules/block/block.module b/core/modules/block/block.module index a2bfdef..5ce5a21 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -141,7 +141,7 @@ function block_menu() { // Block administration is actually tied to theme and plugin definition so // that the plugin can appropriately attach to this url structure. $themes = list_themes(); - foreach (system_plugin_manager('plugin_ui')->getDefinitions() as $plugin_id => $plugin) { + 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]; @@ -461,13 +461,6 @@ function block_list($region) { } /** - * Returns the block plugin manager from the dependency injection container. - */ -function block_manager() { - return drupal_container()->get('plugin.manager.block'); -} - -/** * Loads a block object from the database. * * @param string $plugin_id @@ -480,11 +473,12 @@ function block_manager() { * A block object. */ function block_load($plugin_id, array $conf = array()) { + $manager = drupal_container()->get('plugin.manager.block'); try { - $block = block_manager()->getInstance(array('config' => $plugin_id)); + $block = $manager->getInstance(array('config' => $plugin_id)); } catch (Drupal\Component\Plugin\Exception\PluginException $e) { - $block = block_manager()->createInstance($plugin_id, $conf); + $block = $manager->createInstance($plugin_id, $conf); } return $block; } @@ -499,7 +493,7 @@ function _block_load_blocks() { global $theme; $blocks = array(); $instances = config_get_storage_names_with_prefix('plugin.core.block.' . $theme); - $manager = block_manager(); + $manager = drupal_container()->get('plugin.manager.block'); foreach ($instances as $plugin_id) { $block = $manager->getInstance(array('config' => $plugin_id)); $config = $block->getConfig(); @@ -540,6 +534,8 @@ function _block_get_renderable_block($element) { /** * Wrapper for $block->build to allow altering of blocks. * + * @todo Move the alter invocation into a plugin method. + * * @param \Drupal\block\BlockInterface $block * The block instance. * diff --git a/core/modules/block/custom_block/custom_block.admin.inc b/core/modules/block/custom_block/custom_block.admin.inc index 1d9c7d0..a45a0bf 100644 --- a/core/modules/block/custom_block/custom_block.admin.inc +++ b/core/modules/block/custom_block/custom_block.admin.inc @@ -21,9 +21,7 @@ function custom_block_admin_custom_block($form, &$form_state) { ); $header = array(t('Administrative Title'), t('Operations')); $options = array(); - $results = db_select('block_custom', 'cb') - ->fields('cb') - ->execute(); + $results = db_query('SELECT * FROM {block_custom}'); foreach ($results as $result) { $options[$result->bid] = array( array( diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index 83e15d8..c70b285 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -10,7 +10,7 @@ */ function custom_block_menu() { $items = array(); - foreach (system_plugin_manager('plugin_ui')->getDefinitions() as $plugin_id => $plugin) { + foreach (drupal_container()->get('plugin.manager.system.plugin_ui')->getDefinitions() as $plugin_id => $plugin) { // We only need this menu item for the block_plugin_ui derivatives. if (strpos($plugin_id, 'block_plugin_ui') === 0) { list(, $theme) = explode(':', $plugin_id); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php index 71531e2..23cc00a 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php @@ -34,20 +34,16 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin * Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions(). */ public function getDerivativeDefinitions(array $base_plugin_definition) { - $results = db_select('block_custom', 'b') - ->fields('b') - ->execute(); - if ($results) { - foreach ($results as $result) { - $this->derivatives[$result->bid] = $base_plugin_definition; - $this->derivatives[$result->bid]['settings'] = array( - 'info' => $result->info, - 'body' => $result->body, - 'format' => $result->format, - ) + $base_plugin_definition['settings']; - $this->derivatives[$result->bid]['subject'] = $result->info; - unset($this->derivatives[$result->bid]['custom']); - } + $results = db_query('SELECT * FROM {block_custom}'); + foreach ($results as $result) { + $this->derivatives[$result->bid] = $base_plugin_definition; + $this->derivatives[$result->bid]['settings'] = array( + 'info' => $result->info, + 'body' => $result->body, + 'format' => $result->format, + ) + $base_plugin_definition['settings']; + $this->derivatives[$result->bid]['subject'] = $result->info; + unset($this->derivatives[$result->bid]['custom']); } $this->derivatives['custom_block'] = $base_plugin_definition; return $this->derivatives; diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php index 4078132..c72236d 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php @@ -42,7 +42,7 @@ function testBlockThemeHookSuggestions() { ); // $block3 = block_load('system_powered_by_block', $data3); - $block = block_manager()->createInstance('system_menu_block:menu-admin', $data); + $block = drupal_container()->get('plugin.manager.block')->createInstance('system_menu_block:menu-admin', $data); $variables = array(); $variables['elements']['#block'] = $block; $variables['elements']['#children'] = ''; diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php index 1dec612..8686a25 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php @@ -258,7 +258,7 @@ function testBlockRehash() { $this->assertTrue(module_exists('block_test'), 'Test block module enabled.'); // Add a test block. - $plugin = block_manager()->getDefinition('test_cache'); + $plugin = drupal_container()->get('plugin.manager.block')->getDefinition('test_cache'); $block = array(); $block['id'] = 'test_cache'; diff --git a/core/modules/system/system.module b/core/modules/system/system.module index be4f7fa..461afb8 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1079,7 +1079,7 @@ function system_menu() { ); } - foreach (system_plugin_manager('plugin_ui')->getDefinitions() as $plugin_id => $plugin) { + 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'], @@ -1129,7 +1129,7 @@ function system_menu() { * A simple wrapper function for proxying to the plugin class' form method. */ function system_plugin_ui_form($form, &$form_state, $plugin, $facet = NULL) { - $ui = system_plugin_manager('plugin_ui')->createInstance($plugin); + $ui = drupal_container()->get('plugin.manager.system.plugin_ui')->createInstance($plugin); $form = $ui->form($form, $form_state, $plugin, $facet); return $form; } @@ -1154,7 +1154,7 @@ function system_plugin_ui_form_submit($form, &$form_state) { */ function system_plugin_autocomplete($plugin_id, $string = '') { $matches = array(); - $ui = system_plugin_manager('plugin_ui')->getDefinition($plugin_id); + $ui = drupal_container()->get('plugin.manager.system.plugin_ui')->getDefinition($plugin_id); $manager = new $ui['manager'](); if ($string) { $plugins = $manager->getDefinitions(); @@ -1172,23 +1172,16 @@ function system_plugin_autocomplete($plugin_id, $string = '') { * A simple wrapper function for proxying to the plugin class' access method. */ function system_plugin_ui_access($plugin, $facet = NULL) { - $ui = system_plugin_manager('plugin_ui')->createInstance($plugin); + $ui = drupal_container()->get('plugin.manager.system.plugin_ui')->createInstance($plugin); return $ui->access($plugin, $facet); } /** - * A simple function for retreiving system plugin type managers from the DIC. - */ -function system_plugin_manager($plugin_type) { - return drupal_container()->get("plugin.manager.system.$plugin_type"); -} - -/** * Implements hook_forms(). */ function system_forms() { $forms = array(); - foreach (system_plugin_manager('plugin_ui')->getDefinitions() as $plugin_id => $plugin) { + 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'; }