Issue #2315333 by tim.plunkett: Move block plugin code out of block.module.
parent
f3c0bc05d7
commit
7f2710bea8
|
@ -274,6 +274,9 @@ services:
|
|||
entity.form_builder:
|
||||
class: Drupal\Core\Entity\EntityFormBuilder
|
||||
arguments: ['@entity.manager', '@form_builder']
|
||||
plugin.manager.block:
|
||||
class: Drupal\Core\Block\BlockManager
|
||||
parent: default_plugin_manager
|
||||
plugin.manager.field.field_type:
|
||||
class: Drupal\Core\Field\FieldTypePluginManager
|
||||
arguments: ['@container.namespaces', '@cache.discovery', '@module_handler']
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\block\Annotation\Block.
|
||||
* Contains \Drupal\Core\Block\Annotation\Block.
|
||||
*/
|
||||
|
||||
namespace Drupal\block\Annotation;
|
||||
namespace Drupal\Core\Block\Annotation;
|
||||
|
||||
use Drupal\Component\Annotation\Plugin;
|
||||
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\block\BlockBase.
|
||||
* Contains \Drupal\Core\Block\BlockBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\block;
|
||||
namespace Drupal\Core\Block;
|
||||
|
||||
use Drupal\block\BlockInterface;
|
||||
use Drupal\block\Event\BlockConditionContextEvent;
|
||||
use Drupal\block\Event\BlockEvents;
|
||||
use Drupal\Component\Plugin\ContextAwarePluginInterface;
|
||||
|
@ -198,7 +199,7 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginIn
|
|||
* BlockBase::blockForm(). Most block plugins should not override this
|
||||
* method unless they need to alter the generic form elements.
|
||||
*
|
||||
* @see \Drupal\block\BlockBase::blockForm()
|
||||
* @see \Drupal\Core\Block\BlockBase::blockForm()
|
||||
*/
|
||||
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
|
||||
$definition = $this->getPluginDefinition();
|
||||
|
@ -335,7 +336,7 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginIn
|
|||
* Most block plugins should not override this method. To add validation
|
||||
* for a specific block type, override BlockBase::blockValdiate().
|
||||
*
|
||||
* @see \Drupal\block\BlockBase::blockValidate()
|
||||
* @see \Drupal\Core\Block\BlockBase::blockValidate()
|
||||
*/
|
||||
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
|
||||
// Remove the admin_label form item element value so it will not persist.
|
||||
|
@ -369,7 +370,7 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginIn
|
|||
* Most block plugins should not override this method. To add submission
|
||||
* handling for a specific block type, override BlockBase::blockSubmit().
|
||||
*
|
||||
* @see \Drupal\block\BlockBase::blockSubmit()
|
||||
* @see \Drupal\Core\Block\BlockBase::blockSubmit()
|
||||
*/
|
||||
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
|
||||
// Process the block's submission handling if no errors occurred only.
|
|
@ -2,16 +2,15 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\block\BlockManager.
|
||||
* Contains \Drupal\Core\Block\BlockManager.
|
||||
*/
|
||||
|
||||
namespace Drupal\block;
|
||||
namespace Drupal\Core\Block;
|
||||
|
||||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Plugin\Context\ContextAwarePluginManagerTrait;
|
||||
use Drupal\Core\Plugin\DefaultPluginManager;
|
||||
use Drupal\Core\StringTranslation\TranslationInterface;
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +18,7 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
|
|||
*
|
||||
* @todo Add documentation to this class.
|
||||
*
|
||||
* @see \Drupal\block\BlockPluginInterface
|
||||
* @see \Drupal\Core\Block\BlockPluginInterface
|
||||
*/
|
||||
class BlockManager extends DefaultPluginManager implements BlockManagerInterface {
|
||||
|
||||
|
@ -34,7 +33,7 @@ class BlockManager extends DefaultPluginManager implements BlockManagerInterface
|
|||
protected $moduleData;
|
||||
|
||||
/**
|
||||
* Constructs a new \Drupal\block\BlockManager object.
|
||||
* Constructs a new \Drupal\Core\Block\BlockManager object.
|
||||
*
|
||||
* @param \Traversable $namespaces
|
||||
* An object that implements \Traversable which contains the root paths
|
||||
|
@ -43,15 +42,12 @@ class BlockManager extends DefaultPluginManager implements BlockManagerInterface
|
|||
* Cache backend instance to use.
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The module handler to invoke the alter hook with.
|
||||
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
|
||||
* The translation manager.
|
||||
*/
|
||||
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, TranslationInterface $string_translation) {
|
||||
parent::__construct('Plugin/Block', $namespaces, $module_handler, 'Drupal\block\Annotation\Block');
|
||||
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
|
||||
parent::__construct('Plugin/Block', $namespaces, $module_handler, 'Drupal\Core\Block\Annotation\Block');
|
||||
|
||||
$this->alterInfo('block');
|
||||
$this->setCacheBackend($cache_backend, 'block_plugins');
|
||||
$this->stringTranslation = $string_translation;
|
||||
}
|
||||
|
||||
/**
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\block\BlockManagerInterface.
|
||||
* Contains \Drupal\Core\Block\BlockManagerInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\block;
|
||||
namespace Drupal\Core\Block;
|
||||
|
||||
use Drupal\Core\Plugin\Context\ContextAwarePluginManagerInterface;
|
||||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\block\BlockPluginInterface.
|
||||
* Contains \Drupal\Core\Block\BlockPluginInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\block;
|
||||
namespace Drupal\Core\Block;
|
||||
|
||||
use Drupal\Component\Plugin\Context\ContextInterface;
|
||||
use Drupal\Component\Plugin\DerivativeInspectionInterface;
|
||||
|
@ -109,8 +109,8 @@ interface BlockPluginInterface extends ConfigurablePluginInterface, PluginFormIn
|
|||
* @param \Drupal\Core\Form\FormStateInterface $form_state
|
||||
* The current state of the form.
|
||||
*
|
||||
* @see \Drupal\block\BlockPluginInterface::blockForm()
|
||||
* @see \Drupal\block\BlockPluginInterface::blockSubmit()
|
||||
* @see \Drupal\Core\Block\BlockPluginInterface::blockForm()
|
||||
* @see \Drupal\Core\Block\BlockPluginInterface::blockSubmit()
|
||||
*/
|
||||
public function blockValidate($form, FormStateInterface $form_state);
|
||||
|
||||
|
@ -126,8 +126,8 @@ interface BlockPluginInterface extends ConfigurablePluginInterface, PluginFormIn
|
|||
* @param \Drupal\Core\Form\FormStateInterface $form_state
|
||||
* The current state of the form.
|
||||
*
|
||||
* @see \Drupal\block\BlockPluginInterface::blockForm()
|
||||
* @see \Drupal\block\BlockPluginInterface::blockValidate()
|
||||
* @see \Drupal\Core\Block\BlockPluginInterface::blockForm()
|
||||
* @see \Drupal\Core\Block\BlockPluginInterface::blockValidate()
|
||||
*/
|
||||
public function blockSubmit($form, FormStateInterface $form_state);
|
||||
|
|
@ -131,4 +131,12 @@ interface ThemeHandlerInterface {
|
|||
*/
|
||||
public function getName($theme);
|
||||
|
||||
/**
|
||||
* Returns the default theme.
|
||||
*
|
||||
* @return string
|
||||
* The default theme.
|
||||
*/
|
||||
public function getDefault();
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\aggregator\Plugin\Block;
|
|||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\aggregator\FeedStorageInterface;
|
||||
use Drupal\aggregator\ItemStorageInterface;
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Entity\Query\QueryInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
*
|
||||
* To define a block in a module you need to:
|
||||
* - Define a Block plugin by creating a new class that implements the
|
||||
* \Drupal\block\BlockPluginInterface, in namespace Plugin\Block under your
|
||||
* \Drupal\Core\Block\BlockPluginInterface, in namespace Plugin\Block under your
|
||||
* module namespace. For more information about creating plugins, see the
|
||||
* @link plugin_api Plugin API topic. @endlink
|
||||
* - Usually you will want to extend the \Drupal\block\BlockBase class, which
|
||||
* - Usually you will want to extend the \Drupal\Core\Block\BlockBase class, which
|
||||
* provides a common configuration form and utility methods for getting and
|
||||
* setting configuration in the block configuration entity.
|
||||
* - Block plugins use the annotations defined by
|
||||
* \Drupal\block\Annotation\Block. See the
|
||||
* \Drupal\Core\Block\Annotation\Block. See the
|
||||
* @link annotation Annotations topic @endlink for more information about
|
||||
* annotations.
|
||||
*
|
||||
|
@ -61,7 +61,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Alter the result of \Drupal\block\BlockBase::build().
|
||||
* Alter the result of \Drupal\Core\Block\BlockBase::build().
|
||||
*
|
||||
* This hook is called after the content has been assembled in a structured
|
||||
* array and may be used for doing processing which requires that the complete
|
||||
|
@ -81,7 +81,7 @@
|
|||
* A renderable array of data, as returned from the build() implementation of
|
||||
* the plugin that defined the block:
|
||||
* - #title: The default localized title of the block.
|
||||
* @param \Drupal\block\BlockPluginInterface $block
|
||||
* @param \Drupal\Core\Block\BlockPluginInterface $block
|
||||
* The block plugin instance.
|
||||
*
|
||||
* @see hook_block_view_BASE_BLOCK_ID_alter()
|
||||
|
@ -89,7 +89,7 @@
|
|||
*
|
||||
* @ingroup block_api
|
||||
*/
|
||||
function hook_block_view_alter(array &$build, \Drupal\block\BlockPluginInterface $block) {
|
||||
function hook_block_view_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {
|
||||
// Remove the contextual links on all blocks that provide them.
|
||||
if (isset($build['#contextual_links'])) {
|
||||
unset($build['#contextual_links']);
|
||||
|
@ -111,7 +111,7 @@ function hook_block_view_alter(array &$build, \Drupal\block\BlockPluginInterface
|
|||
* A renderable array of data, as returned from the build() implementation of
|
||||
* the plugin that defined the block:
|
||||
* - #title: The default localized title of the block.
|
||||
* @param \Drupal\block\BlockPluginInterface $block
|
||||
* @param \Drupal\Core\Block\BlockPluginInterface $block
|
||||
* The block plugin instance.
|
||||
*
|
||||
* @see hook_block_view_alter()
|
||||
|
@ -119,7 +119,7 @@ function hook_block_view_alter(array &$build, \Drupal\block\BlockPluginInterface
|
|||
*
|
||||
* @ingroup block_api
|
||||
*/
|
||||
function hook_block_view_BASE_BLOCK_ID_alter(array &$build, \Drupal\block\BlockPluginInterface $block) {
|
||||
function hook_block_view_BASE_BLOCK_ID_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {
|
||||
// Change the title of the specific block.
|
||||
$build['#title'] = t('New title of the block');
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
services:
|
||||
plugin.manager.block:
|
||||
class: Drupal\block\BlockManager
|
||||
arguments: ['@container.namespaces', '@cache.discovery', '@module_handler', '@string_translation']
|
||||
theme.negotiator.block.admin_demo:
|
||||
class: Drupal\block\Theme\AdminDemoNegotiator
|
||||
tags:
|
||||
|
|
|
@ -27,7 +27,7 @@ interface BlockInterface extends ConfigEntityInterface {
|
|||
/**
|
||||
* Returns the plugin instance.
|
||||
*
|
||||
* @return \Drupal\block\BlockPluginInterface
|
||||
* @return \Drupal\Core\Block\BlockPluginInterface
|
||||
* The plugin instance for this block.
|
||||
*/
|
||||
public function getPlugin();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\block;
|
||||
|
||||
use Drupal\block\BlockManagerInterface;
|
||||
use Drupal\Core\Block\BlockManagerInterface;
|
||||
use Drupal\Component\Serialization\Json;
|
||||
use Drupal\Component\Utility\String;
|
||||
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
|
||||
|
@ -50,7 +50,7 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
|
|||
/**
|
||||
* The block manager.
|
||||
*
|
||||
* @var \Drupal\block\BlockManagerInterface
|
||||
* @var \Drupal\Core\Block\BlockManagerInterface
|
||||
*/
|
||||
protected $blockManager;
|
||||
|
||||
|
@ -61,7 +61,7 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
|
|||
* The entity type definition.
|
||||
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
|
||||
* The entity storage class.
|
||||
* @param \Drupal\block\BlockManagerInterface $block_manager
|
||||
* @param \Drupal\Core\Block\BlockManagerInterface $block_manager
|
||||
* The block manager.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, BlockManagerInterface $block_manager) {
|
||||
|
|
|
@ -45,7 +45,7 @@ class BlockPluginBag extends DefaultSinglePluginBag {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return \Drupal\block\BlockPluginInterface
|
||||
* @return \Drupal\Core\Block\BlockPluginInterface
|
||||
*/
|
||||
public function &get($instance_id) {
|
||||
return parent::get($instance_id);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\block\Controller;
|
||||
|
||||
use Drupal\block\BlockManagerInterface;
|
||||
use Drupal\Core\Block\BlockManagerInterface;
|
||||
use Drupal\Component\Utility\String;
|
||||
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
@ -22,14 +22,14 @@ class CategoryAutocompleteController implements ContainerInjectionInterface {
|
|||
/**
|
||||
* The block manager.
|
||||
*
|
||||
* @var \Drupal\block\BlockManagerInterface
|
||||
* @var \Drupal\Core\Block\BlockManagerInterface
|
||||
*/
|
||||
protected $blockManager;
|
||||
|
||||
/**
|
||||
* Constructs a new CategoryAutocompleteController.
|
||||
*
|
||||
* @param \Drupal\block\BlockManagerInterface $block_manager
|
||||
* @param \Drupal\Core\Block\BlockManagerInterface $block_manager
|
||||
* The block manager.
|
||||
*/
|
||||
public function __construct(BlockManagerInterface $block_manager) {
|
||||
|
|
|
@ -30,7 +30,7 @@ class BlockConditionContextEvent extends Event {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return \Drupal\block\BlockPluginInterface
|
||||
* @return \Drupal\Core\Block\BlockPluginInterface
|
||||
*/
|
||||
public function getConditions() {
|
||||
return $this->conditions;
|
||||
|
|
|
@ -15,7 +15,7 @@ final class BlockEvents {
|
|||
/**
|
||||
* Name of the event when gathering condition context for a block plugin.
|
||||
*
|
||||
* @see \Drupal\block\BlockBase::getConditionContexts()
|
||||
* @see \Drupal\Core\Block\BlockBase::getConditionContexts()
|
||||
* @see \Drupal\block\Event\BlockConditionContextEvent
|
||||
*/
|
||||
const CONDITION_CONTEXT = 'block.condition_context';
|
||||
|
|
|
@ -47,7 +47,7 @@ class BlockConfigSchemaTest extends KernelTestBase {
|
|||
/**
|
||||
* The block manager.
|
||||
*
|
||||
* @var \Drupal\block\BlockManagerInterface
|
||||
* @var \Drupal\Core\Block\BlockManagerInterface
|
||||
*/
|
||||
protected $blockManager;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class BlockInterfaceTest extends DrupalUnitTestBase {
|
|||
'display_message' => 'no message set',
|
||||
);
|
||||
// Initial configuration of the block at construction time.
|
||||
/** @var $display_block \Drupal\block\BlockPluginInterface */
|
||||
/** @var $display_block \Drupal\Core\Block\BlockPluginInterface */
|
||||
$display_block = $manager->createInstance('test_block_instantiation', $configuration);
|
||||
$this->assertIdentical($display_block->getConfiguration(), $expected_configuration, 'The block was configured correctly.');
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Provide test blocks.
|
||||
*/
|
||||
|
||||
use Drupal\block\BlockPluginInterface;
|
||||
use Drupal\Core\Block\BlockPluginInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_block_alter().
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\block_test\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\block_test\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
|
||||
/**
|
||||
* Provides a block to test caching.
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\block_test\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
|
||||
/**
|
||||
* Provides a context-aware block.
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\block_test\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
|
||||
/**
|
||||
* Provides a block to test HTML.
|
||||
|
|
|
@ -26,7 +26,7 @@ class CategoryAutocompleteTest extends UnitTestCase {
|
|||
protected $autocompleteController;
|
||||
|
||||
protected function setUp() {
|
||||
$block_manager = $this->getMock('Drupal\block\BlockManagerInterface');
|
||||
$block_manager = $this->getMock('Drupal\Core\Block\BlockManagerInterface');
|
||||
$block_manager->expects($this->any())
|
||||
->method('getCategories')
|
||||
->will($this->returnValue(array('Comment', 'Node', 'None & Such', 'User')));
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
namespace Drupal\block_content\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\block\BlockManagerInterface;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Block\BlockManagerInterface;
|
||||
use Drupal\Core\Entity\EntityManager;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
@ -32,7 +32,7 @@ class BlockContentBlock extends BlockBase implements ContainerFactoryPluginInter
|
|||
/**
|
||||
* The Plugin Block Manager.
|
||||
*
|
||||
* @var \Drupal\block\BlockManagerInterface.
|
||||
* @var \Drupal\Core\Block\BlockManagerInterface.
|
||||
*/
|
||||
protected $blockManager;
|
||||
|
||||
|
@ -66,7 +66,7 @@ class BlockContentBlock extends BlockBase implements ContainerFactoryPluginInter
|
|||
* The plugin ID for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\block\BlockManagerInterface
|
||||
* @param \Drupal\Core\Block\BlockManagerInterface
|
||||
* The Plugin Block Manager.
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager service.
|
||||
|
@ -117,7 +117,7 @@ class BlockContentBlock extends BlockBase implements ContainerFactoryPluginInter
|
|||
}
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\block\BlockBase::blockForm().
|
||||
* Overrides \Drupal\Core\Block\BlockBase::blockForm().
|
||||
*
|
||||
* Adds body and description fields to the block configuration form.
|
||||
*/
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\book\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\book\BookManagerInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\forum\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
|
|
|
@ -203,21 +203,3 @@ function template_preprocess_language_content_settings_table(&$variables) {
|
|||
function theme_language_content_settings_table($variables) {
|
||||
return '<h4>' . $variables['build']['#title'] . '</h4>' . drupal_render($variables['build']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to disable the language switcher blocks.
|
||||
*
|
||||
* @param array $language_types
|
||||
* Array containing all language types whose language switchers need to be
|
||||
* disabled.
|
||||
*/
|
||||
function _language_disable_language_switcher(array $language_types) {
|
||||
$blocks = _block_rehash();
|
||||
foreach ($language_types as $language_type) {
|
||||
foreach ($blocks as $block) {
|
||||
if (strpos($block->id, 'language_switcher_' . substr($language_type, 9)) !== FALSE) {
|
||||
$block->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,13 @@
|
|||
|
||||
namespace Drupal\language\Form;
|
||||
|
||||
use Drupal\block\BlockManagerInterface;
|
||||
use Drupal\Core\Block\BlockManagerInterface;
|
||||
use Drupal\Component\Utility\String;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Extension\ThemeHandlerInterface;
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\language\ConfigurableLanguageManagerInterface;
|
||||
|
@ -49,10 +50,24 @@ class NegotiationConfigureForm extends FormBase {
|
|||
/**
|
||||
* The block manager.
|
||||
*
|
||||
* @var \Drupal\block\BlockManagerInterface
|
||||
* @var \Drupal\Core\Block\BlockManagerInterface
|
||||
*/
|
||||
protected $blockManager;
|
||||
|
||||
/**
|
||||
* The block storage.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityStorageInterface|null
|
||||
*/
|
||||
protected $blockStorage;
|
||||
|
||||
/**
|
||||
* The theme handler.
|
||||
*
|
||||
* @var \Drupal\Core\Extension\ThemeHandlerInterface
|
||||
*/
|
||||
protected $themeHandler;
|
||||
|
||||
/**
|
||||
* Constructs a NegotiationConfigureForm object.
|
||||
*
|
||||
|
@ -62,25 +77,35 @@ class NegotiationConfigureForm extends FormBase {
|
|||
* The language manager.
|
||||
* @param \Drupal\language\LanguageNegotiatorInterface $negotiator
|
||||
* The language negotiation methods manager.
|
||||
* @param \Drupal\block\BlockManagerInterface $block_manager
|
||||
* The block manager, or NULL if not available.
|
||||
* @param \Drupal\Core\Block\BlockManagerInterface $block_manager
|
||||
* The block manager.
|
||||
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
|
||||
* The theme handler.
|
||||
* @param \Drupal\Core\Entity\EntityStorageInterface $block_storage
|
||||
* The block storage, or NULL if not available.
|
||||
*/
|
||||
public function __construct(ConfigFactoryInterface $config_factory, ConfigurableLanguageManagerInterface $language_manager, LanguageNegotiatorInterface $negotiator, BlockManagerInterface $block_manager = NULL) {
|
||||
public function __construct(ConfigFactoryInterface $config_factory, ConfigurableLanguageManagerInterface $language_manager, LanguageNegotiatorInterface $negotiator, BlockManagerInterface $block_manager, ThemeHandlerInterface $theme_handler, EntityStorageInterface $block_storage = NULL) {
|
||||
$this->languageTypes = $config_factory->get('language.types');
|
||||
$this->languageManager = $language_manager;
|
||||
$this->negotiator = $negotiator;
|
||||
$this->blockManager = $block_manager;
|
||||
$this->themeHandler = $theme_handler;
|
||||
$this->blockStorage = $block_storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
$entity_manager = $container->get('entity.manager');
|
||||
$block_storage = $entity_manager->hasController('block', 'storage') ? $entity_manager->getStorage('block') : NULL;
|
||||
return new static(
|
||||
$container->get('config.factory'),
|
||||
$container->get('language_manager'),
|
||||
$container->get('language_negotiator'),
|
||||
$container->has('plugin.manager.block') ? $container->get('plugin.manager.block') : NULL
|
||||
$container->get('plugin.manager.block'),
|
||||
$container->get('theme_handler'),
|
||||
$block_storage
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -152,7 +177,7 @@ class NegotiationConfigureForm extends FormBase {
|
|||
}
|
||||
|
||||
$method_weights_type[$type] = $method_weights;
|
||||
$this->config('language.types')->set('negotiation.' . $type . '.method_weights', $method_weights_input)->save();
|
||||
$this->languageTypes->set('negotiation.' . $type . '.method_weights', $method_weights_input)->save();
|
||||
}
|
||||
|
||||
// Update non-configurable language types and the related language
|
||||
|
@ -166,13 +191,13 @@ class NegotiationConfigureForm extends FormBase {
|
|||
|
||||
// Clear block definitions cache since the available blocks and their names
|
||||
// may have been changed based on the configurable types.
|
||||
if ($this->blockManager) {
|
||||
if ($this->blockStorage) {
|
||||
// If there is an active language switcher for a language type that has
|
||||
// been made not configurable, deactivate it first.
|
||||
$non_configurable = array_keys(array_diff($customized, array_filter($customized)));
|
||||
$this->disableLanguageSwitcher($non_configurable);
|
||||
$this->blockManager->clearCachedDefinitions();
|
||||
}
|
||||
$this->blockManager->clearCachedDefinitions();
|
||||
|
||||
$form_state->setRedirect('language.negotiation');
|
||||
drupal_set_message($this->t('Language negotiation configuration saved.'));
|
||||
|
@ -214,8 +239,8 @@ class NegotiationConfigureForm extends FormBase {
|
|||
}
|
||||
|
||||
$negotiation_info = $form['#language_negotiation_info'];
|
||||
$enabled_methods = $this->config('language.types')->get('negotiation.' . $type . '.enabled') ?: array();
|
||||
$methods_weight = $this->config('language.types')->get('negotiation.' . $type . '.method_weights') ?: array();
|
||||
$enabled_methods = $this->languageTypes->get('negotiation.' . $type . '.enabled') ?: array();
|
||||
$methods_weight = $this->languageTypes->get('negotiation.' . $type . '.method_weights') ?: array();
|
||||
|
||||
// Add missing data to the methods lists.
|
||||
foreach ($negotiation_info as $method_id => $method) {
|
||||
|
@ -296,7 +321,8 @@ class NegotiationConfigureForm extends FormBase {
|
|||
* be disabled.
|
||||
*/
|
||||
protected function disableLanguageSwitcher(array $language_types) {
|
||||
$blocks = _block_rehash();
|
||||
$theme = $this->themeHandler->getDefault();
|
||||
$blocks = $this->blockStorage->loadByProperties(array('theme' => $theme));
|
||||
foreach ($language_types as $language_type) {
|
||||
foreach ($blocks as $block) {
|
||||
if (strpos($block->id, 'language_switcher_' . substr($language_type, 9)) !== FALSE) {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\language\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
*/
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\block\BlockPluginInterface;
|
||||
use Drupal\Core\Block\BlockPluginInterface;
|
||||
use Drupal\Core\Menu\MenuLinkInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Render\Element;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\node\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Drupal\search\Plugin\Block;
|
||||
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\shortcut\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
|
||||
/**
|
||||
* Provides a 'Shortcut' block.
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\statistics\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ class PerformanceForm extends ConfigFormBase {
|
|||
'#open' => TRUE,
|
||||
);
|
||||
// Identical options to the ones for block caching.
|
||||
// @see \Drupal\block\BlockBase::buildConfigurationForm()
|
||||
// @see \Drupal\Core\Block\BlockBase::buildConfigurationForm()
|
||||
$period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400);
|
||||
$period = array_map(array($this->dateFormatter, 'formatInterval'), array_combine($period, $period));
|
||||
$period[0] = '<' . t('no caching') . '>';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Drupal\system\Plugin\Block;
|
||||
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\system\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\system\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\system\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Drupal\system\Plugin\Block;
|
||||
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\Menu\MenuActiveTrailInterface;
|
||||
use Drupal\Core\Menu\MenuLinkTreeInterface;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\system\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ use Drupal\Core\Routing\RouteMatchInterface;
|
|||
use Drupal\Core\StringTranslation\TranslationWrapper;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Menu\MenuTreeParameters;
|
||||
use Drupal\block\BlockPluginInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Core\Block\BlockPluginInterface;
|
||||
use Drupal\user\UserInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\form_test\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Form\FormBuilderInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Drupal\user\Plugin\Block;
|
||||
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\views\Plugin\Block;
|
||||
|
||||
use Drupal\block\BlockBase;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\views\ViewExecutableFactory;
|
||||
|
|
|
@ -2,17 +2,14 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Definition of Drupal\views\Plugin\views\display\Block.
|
||||
* Definition of Drupal\block\Plugin\views\display\Block.
|
||||
* Contains \Drupal\views\Plugin\views\display\Block.
|
||||
*/
|
||||
|
||||
namespace Drupal\block\Plugin\views\display;
|
||||
namespace Drupal\views\Plugin\views\display;
|
||||
|
||||
use Drupal\Component\Utility\String;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\views\Plugin\Block\ViewsBlock;
|
||||
use Drupal\views\Plugin\views\display\DisplayPluginBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* The plugin that handles a block.
|
|
@ -10,7 +10,6 @@ namespace Drupal\views\Tests\Plugin\Block {
|
|||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\views\Plugin\Block\ViewsBlock;
|
||||
use Drupal\block\Plugin\views\display\Block;
|
||||
|
||||
// @todo Remove this once the constant got converted.
|
||||
if (!defined('BLOCK_LABEL_VISIBLE')) {
|
||||
|
@ -80,7 +79,7 @@ class ViewsBlockTest extends UnitTestCase {
|
|||
->with('block_1')
|
||||
->will($this->returnValue(TRUE));
|
||||
|
||||
$this->executable->display_handler = $this->getMockBuilder('Drupal\block\Plugin\views\display\Block')
|
||||
$this->executable->display_handler = $this->getMockBuilder('Drupal\views\Plugin\views\display\Block')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(NULL)
|
||||
->getMock();
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\block\Tests\Plugin\views\display\BlockTest.
|
||||
* Contains \Drupal\views\Tests\Plugin\views\display\BlockTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\block\Tests\Plugin\views\display;
|
||||
namespace Drupal\views\Tests\Plugin\views\display;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\block\Plugin\views\display\Block
|
||||
* @coversDefaultClass \Drupal\views\Plugin\views\display\Block
|
||||
* @group block
|
||||
*/
|
||||
class BlockTest extends UnitTestCase {
|
||||
|
@ -32,7 +32,7 @@ class BlockTest extends UnitTestCase {
|
|||
/**
|
||||
* The tested block display plugin.
|
||||
*
|
||||
* @var \Drupal\block\Plugin\views\display\Block|\PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \Drupal\views\Plugin\views\display\Block|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $blockDisplay;
|
||||
|
||||
|
@ -51,7 +51,7 @@ class BlockTest extends UnitTestCase {
|
|||
->with('block_1')
|
||||
->will($this->returnValue(TRUE));
|
||||
|
||||
$this->blockDisplay = $this->executable->display_handler = $this->getMockBuilder('Drupal\block\Plugin\views\display\Block')
|
||||
$this->blockDisplay = $this->executable->display_handler = $this->getMockBuilder('Drupal\views\Plugin\views\display\Block')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(NULL)
|
||||
->getMock();
|
|
@ -2,17 +2,17 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\block\Tests\BlockBaseTest.
|
||||
* Contains \Drupal\Tests\Core\Block\BlockBaseTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\block\Tests;
|
||||
namespace Drupal\Tests\Core\Block;
|
||||
|
||||
use Drupal\block_test\Plugin\Block\TestBlockInstantiation;
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\block\BlockBase
|
||||
* @coversDefaultClass \Drupal\Core\Block\BlockBase
|
||||
* @group block
|
||||
*/
|
||||
class BlockBaseTest extends UnitTestCase {
|
||||
|
@ -20,7 +20,7 @@ class BlockBaseTest extends UnitTestCase {
|
|||
/**
|
||||
* Tests the machine name suggestion.
|
||||
*
|
||||
* @see \Drupal\block\BlockBase::getMachineNameSuggestion().
|
||||
* @see \Drupal\Core\Block\BlockBase::getMachineNameSuggestion().
|
||||
*/
|
||||
public function testGetMachineNameSuggestion() {
|
||||
$transliteraton = $this->getMockBuilder('Drupal\Core\Transliteration\PHPTransliteration')
|
|
@ -157,7 +157,7 @@ abstract class UnitTestCase extends \PHPUnit_Framework_TestCase {
|
|||
* The mocked block.
|
||||
*/
|
||||
protected function getBlockMockWithMachineName($machine_name) {
|
||||
$plugin = $this->getMockBuilder('Drupal\block\BlockBase')
|
||||
$plugin = $this->getMockBuilder('Drupal\Core\Block\BlockBase')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$plugin->expects($this->any())
|
||||
|
|
Loading…
Reference in New Issue