diff --git a/core/lib/Drupal/Core/Plugin/Mapper/ConfigMapper.php b/core/lib/Drupal/Core/Plugin/Mapper/ConfigMapper.php index 461236f..6c8d0b0 100644 --- a/core/lib/Drupal/Core/Plugin/Mapper/ConfigMapper.php +++ b/core/lib/Drupal/Core/Plugin/Mapper/ConfigMapper.php @@ -8,21 +8,27 @@ namespace Drupal\Core\Plugin\Mapper; use Drupal\Component\Plugin\Mapper\MapperInterface; +use Drupal\Component\Plugin\PluginManagerInterface; /** - * @todo. + * Retrieves plugin instances from the configuration system. */ class ConfigMapper implements MapperInterface { /** - * @todo. + * The plugin manager instance used by this mapper. + * + * @var \Drupal\Component\Plugin\PluginManagerInterface */ protected $manager; /** - * @todo. + * Constructs a \Drupal\Core\Plugin\Mapper\ConfigMapper object. + * + * @param \Drupal\Component\Plugin\PluginManagerInterface $manager + * The plugin manager instance to use for this mapper. */ - public function __construct($manager) { + public function __construct(PluginManagerInterface $manager) { $this->manager = $manager; } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/CategoryBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/CategoryBlock.php index f881ec9..4f0cbbd 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/CategoryBlock.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/CategoryBlock.php @@ -10,12 +10,14 @@ use Drupal\Component\Plugin\Derivative\DerivativeInterface; /** - * @todo. + * Provides block plugin definitions for aggregator categories. */ class CategoryBlock implements DerivativeInterface { /** - * @todo. + * List of derivative definitions. + * + * @var array */ protected $derivatives = array(); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/FeedBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/FeedBlock.php index 575a4a8..d32bf8e 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/FeedBlock.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/FeedBlock.php @@ -10,12 +10,14 @@ use Drupal\Component\Plugin\Derivative\DerivativeInterface; /** - * @todo. + * Provides block plugin definitions for aggregator feeds. */ class FeedBlock implements DerivativeInterface { /** - * @todo. + * List of derivative definitions. + * + * @var array */ protected $derivatives = array(); diff --git a/core/modules/block/custom_block/custom_block.admin.inc b/core/modules/block/custom_block/custom_block.admin.inc index a45a0bf..9b8bd52 100644 --- a/core/modules/block/custom_block/custom_block.admin.inc +++ b/core/modules/block/custom_block/custom_block.admin.inc @@ -2,11 +2,11 @@ /** * @file - * @todo. + * Admin page callbacks for the custom block module. */ /** - * @todo. + * Form constructor for the custom blocks admin page. */ function custom_block_admin_custom_block($form, &$form_state) { $destination = drupal_get_destination(); diff --git a/core/modules/block/custom_block/custom_block.install b/core/modules/block/custom_block/custom_block.install index f32a6f5..4a0e4b0 100644 --- a/core/modules/block/custom_block/custom_block.install +++ b/core/modules/block/custom_block/custom_block.install @@ -2,7 +2,7 @@ /** * @file - * @todo. + * Install, update and uninstall functions for the custom block module. */ /** diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index c70b285..b93b96e 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -2,7 +2,7 @@ /** * @file - * @todo. + * Allows the ability to create custom blocks through the block interface. */ /** 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 23cc00a..e3a5072 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 @@ -10,12 +10,14 @@ use Drupal\Component\Plugin\Derivative\DerivativeInterface; /** - * @todo. + * Provides block plugin definitions for all custom blocks. */ class CustomBlock implements DerivativeInterface { /** - * @todo. + * List of derivative definitions. + * + * @var array */ protected $derivatives = array(); diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index 58017ca..0a02775 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -8,7 +8,6 @@ namespace Drupal\block; use Drupal\Component\Plugin\PluginBase; -use Symfony\Component\Routing\RequestContext; /** * An abstract block implementation to be inherited from to take care of many @@ -17,11 +16,6 @@ abstract class BlockBase extends PluginBase implements BlockInterface { /** - * @todo. - */ - protected $context; - - /** * Implements \Drupal\block\BlockInterface::settingsWrapper(). */ public function settingsWrapper() { @@ -241,9 +235,9 @@ public function configureWrapper($form, &$form_state) { '#weight' => 0, ); - //@TODO remove this access check and inject it in some other way. - // In fact this entire visibility settings section probably needs a - // separate user interface in the near future. + // @todo remove this access check and inject it in some other way. In fact + // this entire visibility settings section probably needs a separate user + // interface in the near future. $access = user_access('use PHP for settings'); if (!empty($config['visibility']['path']['visibility']) && $config['visibility']['path']['visibility'] == BLOCK_VISIBILITY_PHP && !$access) { $form['visibility']['path']['visibility'] = array( @@ -291,8 +285,8 @@ public function configureWrapper($form, &$form_state) { // Fetch languages. $languages = language_list(LANGUAGE_ALL); foreach ($languages as $language) { - // @TODO $language->name is not wrapped with t(), it should be replaced - // by CMI translation implementation. + // @todo $language->name is not wrapped with t(), it should be replaced + // by CMI translation implementation. $langcodes_options[$language->langcode] = $language->name; } $form['visibility']['language'] = array( diff --git a/core/modules/block/lib/Drupal/block/Plugin/Derivative/BlockPluginUI.php b/core/modules/block/lib/Drupal/block/Plugin/Derivative/BlockPluginUI.php index da835aa..7762a7f 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Derivative/BlockPluginUI.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Derivative/BlockPluginUI.php @@ -9,12 +9,14 @@ use Drupal\Component\Plugin\Derivative\DerivativeInterface; /** - * @todo. + * Provides block plugin definitions for each theme. */ class BlockPluginUI implements DerivativeInterface { /** - * @todo. + * List of derivative definitions. + * + * @var array */ protected $derivatives = array(); 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 39b37c7..bf89cc4 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php @@ -14,12 +14,12 @@ use Drupal\Core\Plugin\Mapper\ConfigMapper; /** - * @todo. + * Manages discovery and instantiation of block plugins. */ class BlockManager extends PluginManagerBase { /** - * @todo. + * Constructs a new \Drupal\block\Plugin\Type\BlockManager object. */ public function __construct() { $this->discovery = new AlterDecorator(new DerivativeDiscoveryDecorator(new AnnotatedClassDiscovery('block', 'block')), 'block'); diff --git a/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php b/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php index 5f8c751..16358d5 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php +++ b/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php @@ -20,7 +20,7 @@ * menu = TRUE, * module = "block", * all_plugins = @Translation("All Blocks"), - * link_title = @Translation("Configure Block"), + * link_title = @Translation("Configure block"), * config_path = "admin/structure/block/manage", * path = "admin/structure/block/list", * suffix = "add", diff --git a/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php index c07bdba..4ae387f 100644 --- a/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php +++ b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php @@ -1,5 +1,10 @@ variable_get('block_test_content', '')); + return array( + '#children' => variable_get('block_test_content', ''), + ); } + } diff --git a/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestHtmlIdBlock.php b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestHtmlIdBlock.php index e7ca2f7..3f478d6 100644 --- a/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestHtmlIdBlock.php +++ b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestHtmlIdBlock.php @@ -1,5 +1,10 @@ configuration['block_mode'] = $form_state['values']['book_block_mode']; } /** - * Implements BlockInterface::build(). + * Overrides \Drupal\block\BlockBase::build(). */ public function build() { $current_bid = 0; @@ -109,4 +116,5 @@ public function build() { } return array(); } + } diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/block/block/RecentBlock.php b/core/modules/comment/lib/Drupal/comment/Plugin/block/block/RecentBlock.php index 6f151fc..8b81053 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/block/block/RecentBlock.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/block/block/RecentBlock.php @@ -1,5 +1,10 @@ 10, @@ -22,14 +32,14 @@ public function settings() { } /** - * Implements BlockInterface::access(). + * Overrides \Drupal\block\BlockBase::access(). */ public function access() { return user_access('access comments'); } /** - * Implements BlockInterface::configure(). + * Overrides \Drupal\block\BlockBase::configure(). */ public function configure($form, &$form_state) { $form['block_count'] = array( @@ -42,14 +52,14 @@ public function configure($form, &$form_state) { } /** - * Implements BlockInterface::configureSubmit(). + * Overrides \Drupal\block\BlockBase::configureSubmit(). */ public function configureSubmit($form, &$form_state) { $this->configuration['block_count'] = $form_state['values']['block_count']; } /** - * Implements BlockInterface::build(); + * Overrides \Drupal\block\BlockBase::build(); */ public function build() { return array( @@ -57,4 +67,5 @@ public function build() { '#number' => $this->configuration['block_count'], ); } + } diff --git a/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ActiveBlock.php b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ActiveBlock.php index 903ef1a..b74f7b3 100644 --- a/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ActiveBlock.php +++ b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ActiveBlock.php @@ -1,61 +1,28 @@ DRUPAL_CACHE_CUSTOM, - 'properties' => array( - 'administrative' => TRUE, - ), - 'block_count' => 5, - ); - } - - /** - * Implements BlockInterface::access(). - */ - public function access() { - return user_access('access content'); - } - - /** - * Implements BlockInterface::configure(). - */ - public function configure($form, &$form_state) { - $form['block_count'] = array( - '#type' => 'select', - '#title' => t('Number of topics'), - '#default_value' => $this->configuration['block_count'], - '#options' => drupal_map_assoc(range(2, 20))); - return $form; - } +class ActiveBlock extends ForumBlockBase { /** - * Implements BlockInterface::configureSubmit(). - */ - public function configureSubmit($form, &$form_state) { - $this->configuration['block_count'] = $form_state['values']['block_count']; - } - - /** - * Implements BlockInterface::build(). + * Overrides \Drupal\block\BlockBase::build(). */ public function build() { $query = db_select('forum_index', 'f') @@ -69,4 +36,5 @@ public function build() { drupal_render_cache_by_query($query, 'forum_block_view'), ); } + } diff --git a/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ForumBlockBase.php b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ForumBlockBase.php new file mode 100644 index 0000000..d11a9e4 --- /dev/null +++ b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ForumBlockBase.php @@ -0,0 +1,57 @@ + DRUPAL_CACHE_CUSTOM, + 'properties' => array( + 'administrative' => TRUE, + ), + 'block_count' => 5, + ); + } + + /** + * Overrides \Drupal\block\BlockBase::access(). + */ + public function access() { + return user_access('access content'); + } + + /** + * Overrides \Drupal\block\BlockBase::configure(). + */ + public function configure($form, &$form_state) { + $form['block_count'] = array( + '#type' => 'select', + '#title' => t('Number of topics'), + '#default_value' => $this->configuration['block_count'], + '#options' => drupal_map_assoc(range(2, 20)), + ); + return $form; + } + + /** + * Overrides \Drupal\block\BlockBase::configureSubmit(). + */ + public function configureSubmit($form, &$form_state) { + $this->configuration['block_count'] = $form_state['values']['block_count']; + } + +} diff --git a/core/modules/forum/lib/Drupal/forum/Plugin/block/block/NewBlock.php b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/NewBlock.php index 8aa0073..11e0313 100644 --- a/core/modules/forum/lib/Drupal/forum/Plugin/block/block/NewBlock.php +++ b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/NewBlock.php @@ -1,61 +1,28 @@ DRUPAL_CACHE_CUSTOM, - 'properties' => array( - 'administrative' => TRUE, - ), - 'block_count' => 5, - ); - } - - /** - * Implements BlockInterface::access(). - */ - public function access() { - return user_access('access content'); - } - - /** - * Implements BlockInterface::configure(). - */ - public function configure($form, &$form_state) { - $form['block_count'] = array( - '#type' => 'select', - '#title' => t('Number of topics'), - '#default_value' => $this->configuration['block_count'], - '#options' => drupal_map_assoc(range(2, 20))); - return $form; - } +class NewBlock extends ForumBlockBase { /** - * Implements BlockInterface::configureSubmit(). - */ - public function configureSubmit($form, &$form_state) { - $this->configuration['block_count'] = $form_state['values']['block_count']; - } - - /** - * Implements BlockInterface::build(). + * Overrides \Drupal\block\BlockBase::build(). */ public function build() { $query = db_select('forum_index', 'f') @@ -69,4 +36,5 @@ public function build() { drupal_render_cache_by_query($query, 'forum_block_view'), ); } + } diff --git a/core/modules/language/lib/Drupal/language/Plugin/Derivative/LanguageBlock.php b/core/modules/language/lib/Drupal/language/Plugin/Derivative/LanguageBlock.php index 0dff21a..827b9b5 100644 --- a/core/modules/language/lib/Drupal/language/Plugin/Derivative/LanguageBlock.php +++ b/core/modules/language/lib/Drupal/language/Plugin/Derivative/LanguageBlock.php @@ -1,14 +1,28 @@ derivatives) && !empty($this->derivatives[$derivative_id])) { @@ -19,7 +33,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin } /** - * Implements DerivativeInterface::getDerivativeDefinitions(). + * Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions(). */ public function getDerivativeDefinitions(array $base_plugin_definition) { include_once DRUPAL_ROOT . '/core/includes/language.inc'; @@ -31,4 +45,5 @@ public function getDerivativeDefinitions(array $base_plugin_definition) { } return $this->derivatives; } + } diff --git a/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php b/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php index a4d689c..1714748 100644 --- a/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php +++ b/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php @@ -1,5 +1,10 @@ ' : current_path(); @@ -32,11 +39,16 @@ function build() { $links = language_negotiation_get_switch_links($type, $path); if (isset($links->links)) { - $class = "language-switcher-{$links->method_id}"; - $variables = array('links' => $links->links, 'attributes' => array('class' => array($class))); return array( - '#children' => theme('links__language_block', $variables) + '#theme' => 'links__language_block', + '#links' => $links->links, + '#attributes' => array( + 'class' => array( + "language-switcher-{$links->method_id}", + ), + ), ); } } + } diff --git a/core/modules/menu/lib/Drupal/menu/Plugin/Derivative/MenuBlock.php b/core/modules/menu/lib/Drupal/menu/Plugin/Derivative/MenuBlock.php index 3285cbd..caa6931 100644 --- a/core/modules/menu/lib/Drupal/menu/Plugin/Derivative/MenuBlock.php +++ b/core/modules/menu/lib/Drupal/menu/Plugin/Derivative/MenuBlock.php @@ -10,12 +10,12 @@ use Drupal\system\Plugin\Derivative\SystemMenuBlock; /** - * @todo. + * Provides block plugin definitions for custom menus. */ class MenuBlock extends SystemMenuBlock { /** - * Implements DerivativeInterface::getDerivativeDefinitions(). + * Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions(). */ public function getDerivativeDefinitions(array $base_plugin_definition) { foreach (menu_get_menus(FALSE) as $menu => $name) { diff --git a/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php b/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php index c357958..5e16f14 100644 --- a/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php +++ b/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php @@ -1,5 +1,10 @@ configuration['block_count'] = $form_state['values']['block_count']; } /** - * Implements BlockInterface::build(); + * Overrides \Drupal\block\BlockBase::build(); */ public function build() { if ($nodes = node_get_recent($this->configuration['block_count'])) { @@ -67,4 +74,5 @@ public function build() { ); } } + } diff --git a/core/modules/node/lib/Drupal/node/Plugin/block/block/SyndicateBlock.php b/core/modules/node/lib/Drupal/node/Plugin/block/block/SyndicateBlock.php index 524b945..e7c962c 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/block/block/SyndicateBlock.php +++ b/core/modules/node/lib/Drupal/node/Plugin/block/block/SyndicateBlock.php @@ -1,5 +1,10 @@ 'rss.xml', ); } + } diff --git a/core/modules/poll/lib/Drupal/poll/Plugin/block/block/PollRecentBlock.php b/core/modules/poll/lib/Drupal/poll/Plugin/block/block/PollRecentBlock.php index 81ec76f..4db6d8a 100644 --- a/core/modules/poll/lib/Drupal/poll/Plugin/block/block/PollRecentBlock.php +++ b/core/modules/poll/lib/Drupal/poll/Plugin/block/block/PollRecentBlock.php @@ -1,5 +1,10 @@ execute()->fetchObject(); if ($record) { - $this->record = $record; + $this->record = $record->nid; return TRUE; } } @@ -52,10 +65,10 @@ public function access() { } /** - * Implements BlockInterface::build(). + * Overrides \Drupal\block\BlockBase::build(). */ public function build() { - $poll = node_load($this->record->nid); + $poll = node_load($this->record); if ($poll->nid) { $poll = poll_block_latest_poll_view($poll); return array( @@ -64,4 +77,5 @@ public function build() { } return array(); } -} \ No newline at end of file + +} diff --git a/core/modules/search/lib/Drupal/search/Plugin/block/block/SearchBlock.php b/core/modules/search/lib/Drupal/search/Plugin/block/block/SearchBlock.php index 008daa2..94cd343 100644 --- a/core/modules/search/lib/Drupal/search/Plugin/block/block/SearchBlock.php +++ b/core/modules/search/lib/Drupal/search/Plugin/block/block/SearchBlock.php @@ -1,5 +1,10 @@ t('Disabled')) + drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40)); $form['statistics_block_top_day_num'] = array( '#type' => 'select', '#title' => t("Number of day's top views to display"), '#default_value' => $this->configuration['top_day_num'], '#options' => $numbers, - '#description' => t('How many content items to display in "day" list.') + '#description' => t('How many content items to display in "day" list.'), ); $form['statistics_block_top_all_num'] = array( '#type' => 'select', '#title' => t('Number of all time views to display'), '#default_value' => $this->configuration['top_all_num'], '#options' => $numbers, - '#description' => t('How many content items to display in "all time" list.') + '#description' => t('How many content items to display in "all time" list.'), ); $form['statistics_block_top_last_num'] = array( '#type' => 'select', '#title' => t('Number of most recent views to display'), '#default_value' => $this->configuration['top_last_num'], '#options' => $numbers, - '#description' => t('How many content items to display in "recently viewed" list.') + '#description' => t('How many content items to display in "recently viewed" list.'), ); return $form; } /** - * Implements BlockInterface::configureSubmit(). + * Overrides \Drupal\block\BlockBase::configureSubmit(). */ public function configureSubmit($form, &$form_state) { $this->configuration['top_day_num'] = $form_state['values']['statistics_block_top_day_num']; @@ -91,7 +116,7 @@ public function configureSubmit($form, &$form_state) { } /** - * Implements BlockInterface::build(). + * Overrides \Drupal\block\BlockBase::build(). */ public function build() { $content = array(); diff --git a/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php index 9ab2455..bb2f0d7 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php @@ -1,14 +1,28 @@ derivatives) && !empty($this->derivatives[$derivative_id])) { @@ -19,7 +33,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin } /** - * Implements DerivativeInterface::getDerivativeDefinitions(). + * Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions(). */ public function getDerivativeDefinitions(array $base_plugin_definition) { foreach (menu_list_system_menus() as $menu => $name) { diff --git a/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php b/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php index fce8288..ce84dec 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php +++ b/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php @@ -1,10 +1,22 @@ getDefinition(); $manager = new $plugin_definition['manager'](); @@ -51,35 +63,64 @@ public function form($form, &$form_state, $plugin, $facet) { return $form; } - public function formValidate($form, &$form_state) {} + /** + * @todo. + */ + public function formValidate($form, &$form_state) { + } - public function formSubmit($form, &$form_state) {} + /** + * @todo. + */ + public function formSubmit($form, &$form_state) { + } + /** + * @todo. + */ public function excludeDefinitions($definitions) { return $definitions; } + /** + * @todo. + */ public function access($plugin_id) { $definition = $this->getDefinition($plugin_id); return call_user_func_array('user_access', $definition['access_arguments']); } + /** + * @todo. + */ public function row($plugin, $plugin_definition, $plugin_id, $config) { return array($config['title'], l($plugin_definition['link_title'], $plugin_definition['config_path'] . '/' . $plugin_id)); } + /** + * @todo. + */ public function facetLink($facet, $plugin, $plugin_definition, $plugin_id, $config, $key) { return array('title' => $config[$key], 'href' => $plugin_definition['path'] . '/' . $plugin . '/' . $facet . ':' . $config[$key]); } + /** + * @todo. + */ public function allPluginsUrl($plugin, $plugin_definition, $plugin_id, $config) { return $plugin_definition['path'] . '/' . $plugin . '/add'; } + /** + * @todo. + */ public function tableHeader() { return array(t('Title'), t('Operations')); } + /** + * @todo. + */ public function facetCompare($facet, $config) { list($facet_type, $option) = explode(':', $facet); return $option == $config[$facet_type]; diff --git a/core/modules/system/lib/Drupal/system/Plugin/PluginUIInterface.php b/core/modules/system/lib/Drupal/system/Plugin/PluginUIInterface.php index e05e90f..f90388c 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/PluginUIInterface.php +++ b/core/modules/system/lib/Drupal/system/Plugin/PluginUIInterface.php @@ -1,16 +1,32 @@ discovery = new DerivativeDiscoveryDecorator(new AnnotatedClassDiscovery('system', 'plugin_ui')); $this->factory = new ReflectionFactory($this); } + /** + * Overrides \Drupal\Component\Plugin\PluginManagerBase::processDefinition(). + */ protected function processDefinition(&$definition, $plugin_id) { $definition += array( 'default_task' => TRUE, @@ -20,4 +35,5 @@ protected function processDefinition(&$definition, $plugin_id) { 'task_suffix' => 'view', ); } -} \ No newline at end of file + +} diff --git a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemHelpBlock.php b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemHelpBlock.php index 7bfb5e2..0239e0a 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemHelpBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemHelpBlock.php @@ -1,5 +1,10 @@ help = menu_get_active_help(); - return $this->help ? TRUE : FALSE; + return (bool) $this->help; } /** - * Implements BlockInterface::build(). + * Overrides \Drupal\block\BlockBase::build(). */ public function build() { - if (empty($this->help)) { - $this->help = menu_get_active_help(); - } return array( '#children' => $this->help, ); } + } diff --git a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMainBlock.php b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMainBlock.php index 2fe6ce4..41d6487 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMainBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMainBlock.php @@ -1,5 +1,10 @@ getPluginId()); @@ -34,4 +41,5 @@ public function build() { $menu = substr($derivative, 5); return menu_tree($menu); } + } diff --git a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemPoweredByBlock.php b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemPoweredByBlock.php index 5c6e0b9..7faceea 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemPoweredByBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemPoweredByBlock.php @@ -1,5 +1,10 @@ theme('system_powered_by'), ); } + } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 049238e..6cc5b9d 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1124,41 +1124,27 @@ function system_menu() { } /** - * A simple wrapper function for proxying to the plugin class' form method. + * Proxies to the plugin class' form method. */ function system_plugin_ui_form($form, &$form_state, $plugin, $facet = NULL) { - $ui = drupal_container()->get('plugin.manager.system.plugin_ui')->createInstance($plugin); - $form = $ui->form($form, $form_state, $plugin, $facet); + $plugin_ui = drupal_container()->get('plugin.manager.system.plugin_ui')->createInstance($plugin); + $form = $plugin_ui->form($form, $form_state, $plugin, $facet); + $form['#validate'][] = array($plugin_ui, 'formValidate'); + $form['#submit'][] = array($plugin_ui, 'formSubmit'); return $form; } /** - * A simple wrapper function for proxying to the plugin class' validate method. - */ -function system_plugin_ui_form_validate($form, &$form_state) { - $form_state['values']['instance']->formValidate($form, $form_state); -} - -/** - * A simple wrapper function for proxying to the plugin class' submit method. - */ -function system_plugin_ui_form_submit($form, &$form_state) { - $form_state['values']['instance']->formSubmit($form, $form_state); -} - -/** - * A generic autocomplete page callback for any plugin system tied to a plugin - * ui plugin. + * Page callback: Autocomplete any plugin system tied to a plugin UI plugin. */ function system_plugin_autocomplete($plugin_id, $string = '') { $matches = array(); - $ui = drupal_container()->get('plugin.manager.system.plugin_ui')->getDefinition($plugin_id); - $manager = new $ui['manager'](); if ($string) { - $plugins = $manager->getDefinitions(); + $plugin_ui = drupal_container()->get('plugin.manager.system.plugin_ui')->getDefinition($plugin_id); + $manager = new $plugin_ui['manager'](); $titles = array(); - foreach($plugins as $plugin_id => $plugin) { - $titles[$plugin_id] = $plugin[$ui['title_attribute']]; + foreach($manager->getDefinitions() as $plugin_id => $plugin) { + $titles[$plugin_id] = $plugin[$plugin_ui['title_attribute']]; } $matches = preg_grep("/\b". $string . "/i", $titles); } @@ -1170,8 +1156,8 @@ 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 = drupal_container()->get('plugin.manager.system.plugin_ui')->createInstance($plugin); - return $ui->access($plugin, $facet); + $plugin_ui = drupal_container()->get('plugin.manager.system.plugin_ui')->createInstance($plugin); + return $plugin_ui->access($plugin, $facet); } /** @@ -2655,13 +2641,10 @@ function system_preprocess_block(&$variables) { } /** - * Processes variables for block-admin-display-form.tpl.php. + * Implements hook_preprocess_HOOK() for system-plugin-ui-form.tpl.php. * * The $variables array contains the following arguments: * - $form - * - * @see block-admin-display.tpl.php - * @see theme_block_admin_display() */ function template_preprocess_system_plugin_ui_form(&$variables) { drupal_add_css(drupal_get_path('module', 'system') . '/system.plugin.ui.css'); diff --git a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserLoginBlock.php b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserLoginBlock.php index d363ad1..42de0ad 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserLoginBlock.php +++ b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserLoginBlock.php @@ -1,5 +1,10 @@ uid && !(arg(0) == 'user' && !is_numeric(arg(1)))); + return (!$GLOBALS['user']->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))); } /** - * Implements BlockInterface::build(). + * Overrides \Drupal\block\BlockBase::build(). */ public function build() { $form = drupal_get_form('user_login_form'); @@ -58,4 +64,5 @@ public function build() { ), ); } + } diff --git a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserNewBlock.php b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserNewBlock.php index 33da17e..f75c070 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserNewBlock.php +++ b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserNewBlock.php @@ -1,5 +1,10 @@ configuration['whois_new_count'] = $form_state['values']['user_block_whois_new_count']; } /** - * Implements BlockInterface::build(). + * Overrides \Drupal\block\BlockBase::build(). */ public function build() { // Retrieve a list of new users who have subsequently accessed the site successfully. @@ -69,4 +76,5 @@ public function build() { } return $build; } + } diff --git a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserOnlineBlock.php b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserOnlineBlock.php index e38f1f8..f9d9245 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserOnlineBlock.php +++ b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserOnlineBlock.php @@ -1,5 +1,10 @@ configuration['seconds_online'] = $form_state['values']['user_block_seconds_online']; @@ -66,9 +73,9 @@ public function configureSubmit($form, &$form_state) { } /** - * Implements BlockInterface::build(). + * Overrides \Drupal\block\BlockBase::build(). * - * @todo: Move this block to statistics.module and remove dependency on + * @todo Move this block to statistics.module and remove dependency on * user.access. */ public function build() { diff --git a/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php b/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php index c513d0e..a4458d4 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php @@ -21,6 +21,13 @@ class UserBlocksTests extends WebTestBase { */ public static $modules = array('block'); + /** + * The admin user used in this test. + * + * @var \Drupal\user\Plugin\Core\Entity\User + */ + protected $adminUser; + public static function getInfo() { return array( 'name' => 'User blocks', @@ -32,8 +39,8 @@ public static function getInfo() { function setUp() { parent::setUp(); - $admin_user = $this->drupalCreateUser(array('administer blocks')); - $this->drupalLogin($admin_user); + $this->adminUser = $this->drupalCreateUser(array('administer blocks')); + $this->drupalLogin($this->adminUser); $block_id = 'user_login_block'; $default_theme = variable_get('theme_default', 'stark'); @@ -48,7 +55,7 @@ function setUp() { $this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block')); $this->assertText(t('The block configuration has been saved.'), 'User login block enabled'); $this->plugin_id = 'plugin.core.block.' . $default_theme . '.' . $block['machine_name']; - $this->drupalLogout($admin_user); + $this->drupalLogout($this->adminUser); } /** @@ -86,6 +93,10 @@ function testUserLoginBlock() { * Test the Who's Online block. */ function testWhosOnlineBlock() { + $plugin_id = 'plugin.core.block.' . variable_get('theme_default', 'stark') . '.online'; + $block = $this->container->get('plugin.manager.block')->getInstance(array('config' => $plugin_id)); + $config = $block->getConfig(); + // Generate users. $user1 = $this->drupalCreateUser(array()); $user2 = $this->drupalCreateUser(array()); @@ -95,19 +106,20 @@ function testWhosOnlineBlock() { $this->updateAccess($user1->uid); $this->updateAccess($user2->uid, REQUEST_TIME + 1); - // Insert an inactive user who should not be seen in the block. - $this->updateAccess($user3->uid, REQUEST_TIME - config('user.block')->get('seconds_online') - 1); - - // Test block output. TODO. Needs to be changed once user login form has - // gotten some work. - //$block = user_block_view('online'); - //$block['content'] = render($block['content']); - //$this->drupalSetContent($block['content']); - //$this->assertRaw(t('2 users'), 'Correct number of online users (2 users).'); - //$this->assertText($user1->name, 'Active user 1 found in online list.'); - //$this->assertText($user2->name, 'Active user 2 found in online list.'); - //$this->assertNoText($user3->name, 'Inactive user not found in online list.'); - //$this->assertTrue(strpos($this->drupalGetContent(), $user1->name) > strpos($this->drupalGetContent(), $user2->name), 'Online users are ordered correctly.'); + // Insert an inactive user who should not be seen in the block, and ensure + // that the admin user used in setUp() does not appear. + $inactive_time = REQUEST_TIME - $config['seconds_online'] - 1; + $this->updateAccess($user3->uid, $inactive_time); + $this->updateAccess($this->adminUser->uid, $inactive_time); + + // Test block output. + $content = $block->build(); + $this->drupalSetContent(render($content)); + $this->assertRaw(t('2 users'), 'Correct number of online users (2 users).'); + $this->assertText($user1->name, 'Active user 1 found in online list.'); + $this->assertText($user2->name, 'Active user 2 found in online list.'); + $this->assertNoText($user3->name, 'Inactive user not found in online list.'); + $this->assertTrue(strpos($this->drupalGetContent(), $user1->name) > strpos($this->drupalGetContent(), $user2->name), 'Online users are ordered correctly.'); } /** diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php index 8a3abb0..45db464 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php @@ -10,12 +10,14 @@ use Drupal\Component\Plugin\Derivative\DerivativeInterface; /** - * @todo. + * Provides block plugin definitions for all Views block displays. */ class ViewsBlock implements DerivativeInterface { /** - * @todo. + * List of derivative definitions. + * + * @var array */ protected $derivatives = array(); diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php index 98e67bd..f0408f9 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php @@ -1,14 +1,28 @@ derivatives) && !empty($this->derivatives[$derivative_id])) { @@ -19,7 +33,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin } /** - * Implements DerivativeInterface::getDerivativeDefinitions(). + * Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions(). */ public function getDerivativeDefinitions(array $base_plugin_definition) { foreach (views_get_all_views() as $view) { @@ -45,4 +59,5 @@ public function getDerivativeDefinitions(array $base_plugin_definition) { } return $this->derivatives; } + } diff --git a/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php index 1bd243f..5b7a26e 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php @@ -2,7 +2,7 @@ /** * @file - * Contains Drupal\views\Plugin\block\block\ViewsBlock. + * Contains \Drupal\views\Plugin\block\block\ViewsBlock. */ namespace Drupal\views\Plugin\block\block; @@ -13,6 +13,8 @@ use Drupal\Component\Plugin\Discovery\DiscoveryInterface; /** + * @todo. + * * @Plugin( * id = "views_block", * subject = @Translation("Views Block"), @@ -23,29 +25,30 @@ class ViewsBlock extends BlockBase { /** - * @todo. + * The View executable object. + * + * @var \Drupal\views\ViewExecutable */ protected $view; /** - * @todo. + * The display ID being used for this View. + * + * @var string */ - protected $display_id; + protected $displayID; /** * Overrides \Drupal\Component\Plugin\PluginBase::__construct(). */ public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) { parent::__construct($configuration, $plugin_id, $discovery); - list($plugin, $delta) = explode(':', $this->getPluginId()); - - $start = microtime(TRUE); - list($name, $display_id) = explode('-', $delta, 2); - $this->display_id = $display_id; - // Load the view + list($plugin, $delta) = explode(':', $this->getPluginId()); + list($name, $this->displayID) = explode('-', $delta, 2); + // Load the view. $this->view = views_get_view($name); - $this->view->setDisplay($display_id); + $this->view->setDisplay($this->displayID); } /** @@ -64,17 +67,17 @@ public function configureWrapper($form, &$form_state) { * Overrides \Drupal\block\BlockBase::access(). */ public function access() { - return $this->view->access($this->display_id); + return $this->view->access($this->displayID); } /** * Overrides \Drupal\block\BlockBase::build(). */ public function build() { - $output = $this->view->executeDisplay($this->display_id); + $output = $this->view->executeDisplay($this->displayID); // Before returning the block output, convert it to a renderable array // with contextual links. - views_add_block_contextual_links($output, $this->view, $this->display_id); + views_add_block_contextual_links($output, $this->view, $this->displayID); $this->view->destroy(); return $output; } diff --git a/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsExposedFilterBlock.php b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsExposedFilterBlock.php index ef9feae..e172e05 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsExposedFilterBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsExposedFilterBlock.php @@ -1,11 +1,18 @@ view->destroy(); return $output; } + } diff --git a/core/profiles/testing/config/plugin.core.block.stark.online.yml b/core/profiles/testing/config/plugin.core.block.stark.online.yml new file mode 100644 index 0000000..3b3f5c5 --- /dev/null +++ b/core/profiles/testing/config/plugin.core.block.stark.online.yml @@ -0,0 +1,23 @@ +id: user_online_block +properties: + administrative: '1' +seconds_online: '900' +max_list_count: '10' +status: '1' +cache: '-1' +subject: 'Who''s online' +visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + poll: '0' + visibility__active_tab: edit-visibility-path +module: user +region: sidebar_first +weight: '0'