updated core to 8.6.1 via composer
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Drupal\block;
|
||||
|
||||
use Drupal\Component\Plugin\Exception\ContextException;
|
||||
use Drupal\Component\Plugin\Exception\MissingValueContextException;
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Cache\CacheableDependencyInterface;
|
||||
@@ -67,7 +68,6 @@ class BlockAccessControlHandler extends EntityAccessControlHandler implements En
|
||||
$this->contextRepository = $context_repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -84,12 +84,16 @@ class BlockAccessControlHandler extends EntityAccessControlHandler implements En
|
||||
else {
|
||||
$conditions = [];
|
||||
$missing_context = FALSE;
|
||||
$missing_value = FALSE;
|
||||
foreach ($entity->getVisibilityConditions() as $condition_id => $condition) {
|
||||
if ($condition instanceof ContextAwarePluginInterface) {
|
||||
try {
|
||||
$contexts = $this->contextRepository->getRuntimeContexts(array_values($condition->getContextMapping()));
|
||||
$this->contextHandler->applyContextMapping($condition, $contexts);
|
||||
}
|
||||
catch (MissingValueContextException $e) {
|
||||
$missing_value = TRUE;
|
||||
}
|
||||
catch (ContextException $e) {
|
||||
$missing_context = TRUE;
|
||||
}
|
||||
@@ -100,14 +104,15 @@ class BlockAccessControlHandler extends EntityAccessControlHandler implements En
|
||||
if ($missing_context) {
|
||||
// If any context is missing then we might be missing cacheable
|
||||
// metadata, and don't know based on what conditions the block is
|
||||
// accessible or not. For example, blocks that have a node type
|
||||
// condition will have a missing context on any non-node route like the
|
||||
// frontpage.
|
||||
// @todo Avoid setting max-age 0 for some or all cases, for example by
|
||||
// treating available contexts without value differently in
|
||||
// https://www.drupal.org/node/2521956.
|
||||
// accessible or not. Make sure the result cannot be cached.
|
||||
$access = AccessResult::forbidden()->setCacheMaxAge(0);
|
||||
}
|
||||
elseif ($missing_value) {
|
||||
// The contexts exist but have no value. Deny access without
|
||||
// disabling caching. For example the node type condition will have a
|
||||
// missing context on any non-node route like the frontpage.
|
||||
$access = AccessResult::forbidden();
|
||||
}
|
||||
elseif ($this->resolveConditions($conditions, 'and') !== FALSE) {
|
||||
// Delegate to the plugin.
|
||||
$block_plugin = $entity->getPlugin();
|
||||
@@ -118,12 +123,15 @@ class BlockAccessControlHandler extends EntityAccessControlHandler implements En
|
||||
}
|
||||
$access = $block_plugin->access($account, TRUE);
|
||||
}
|
||||
catch (MissingValueContextException $e) {
|
||||
// The contexts exist but have no value. Deny access without
|
||||
// disabling caching.
|
||||
$access = AccessResult::forbidden();
|
||||
}
|
||||
catch (ContextException $e) {
|
||||
// Setting access to forbidden if any context is missing for the same
|
||||
// reasons as with conditions (described in the comment above).
|
||||
// @todo Avoid setting max-age 0 for some or all cases, for example by
|
||||
// treating available contexts without value differently in
|
||||
// https://www.drupal.org/node/2521956.
|
||||
// If any context is missing then we might be missing cacheable
|
||||
// metadata, and don't know based on what conditions the block is
|
||||
// accessible or not. Make sure the result cannot be cached.
|
||||
$access = AccessResult::forbidden()->setCacheMaxAge(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +239,8 @@ class BlockForm extends EntityForm {
|
||||
// @todo Allow list of conditions to be configured in
|
||||
// https://www.drupal.org/node/2284687.
|
||||
$visibility = $this->entity->getVisibility();
|
||||
foreach ($this->manager->getDefinitionsForContexts($form_state->getTemporaryValue('gathered_contexts')) as $condition_id => $definition) {
|
||||
$definitions = $this->manager->getFilteredDefinitions('block_ui', $form_state->getTemporaryValue('gathered_contexts'), ['block' => $this->entity]);
|
||||
foreach ($definitions as $condition_id => $definition) {
|
||||
// Don't display the current theme condition.
|
||||
if ($condition_id == 'current_theme') {
|
||||
continue;
|
||||
@@ -359,7 +360,7 @@ class BlockForm extends EntityForm {
|
||||
// Save the settings of the plugin.
|
||||
$entity->save();
|
||||
|
||||
drupal_set_message($this->t('The block configuration has been saved.'));
|
||||
$this->messenger()->addStatus($this->t('The block configuration has been saved.'));
|
||||
$form_state->setRedirect(
|
||||
'block.admin_display_theme',
|
||||
[
|
||||
|
||||
@@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Form\FormBuilderInterface;
|
||||
use Drupal\Core\Form\FormInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Messenger\MessengerInterface;
|
||||
use Drupal\Core\Theme\ThemeManagerInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
@@ -56,6 +57,13 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
|
||||
*/
|
||||
protected $limit = FALSE;
|
||||
|
||||
/**
|
||||
* The messenger.
|
||||
*
|
||||
* @var \Drupal\Core\Messenger\MessengerInterface
|
||||
*/
|
||||
protected $messenger;
|
||||
|
||||
/**
|
||||
* Constructs a new BlockListBuilder object.
|
||||
*
|
||||
@@ -68,11 +76,12 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
|
||||
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
|
||||
* The form builder.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, ThemeManagerInterface $theme_manager, FormBuilderInterface $form_builder) {
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, ThemeManagerInterface $theme_manager, FormBuilderInterface $form_builder, MessengerInterface $messenger) {
|
||||
parent::__construct($entity_type, $storage);
|
||||
|
||||
$this->themeManager = $theme_manager;
|
||||
$this->formBuilder = $form_builder;
|
||||
$this->messenger = $messenger;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +92,8 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
|
||||
$entity_type,
|
||||
$container->get('entity.manager')->getStorage($entity_type->id()),
|
||||
$container->get('theme.manager'),
|
||||
$container->get('form_builder')
|
||||
$container->get('form_builder'),
|
||||
$container->get('messenger')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -212,7 +222,7 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
|
||||
'#theme_wrappers' => [
|
||||
'container' => [
|
||||
'#attributes' => ['class' => 'region-title__action'],
|
||||
]
|
||||
],
|
||||
],
|
||||
'#prefix' => $title,
|
||||
'#type' => 'link',
|
||||
@@ -367,7 +377,7 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
|
||||
$entity->setRegion($entity_values['region']);
|
||||
$entity->save();
|
||||
}
|
||||
drupal_set_message(t('The block settings have been updated.'));
|
||||
$this->messenger->addStatus($this->t('The block settings have been updated.'));
|
||||
|
||||
// Remove any previously set block placement.
|
||||
$this->request->query->remove('block-placement');
|
||||
|
||||
@@ -53,7 +53,7 @@ class BlockController extends ControllerBase {
|
||||
*/
|
||||
public function performOperation(BlockInterface $block, $op) {
|
||||
$block->$op()->save();
|
||||
drupal_set_message($this->t('The block settings have been updated.'));
|
||||
$this->messenger()->addStatus($this->t('The block settings have been updated.'));
|
||||
return $this->redirect('block.admin_display');
|
||||
}
|
||||
|
||||
|
||||
@@ -101,8 +101,14 @@ class BlockLibraryController extends ControllerBase {
|
||||
['data' => $this->t('Operations')],
|
||||
];
|
||||
|
||||
$region = $request->query->get('region');
|
||||
$weight = $request->query->get('weight');
|
||||
|
||||
// Only add blocks which work without any available context.
|
||||
$definitions = $this->blockManager->getDefinitionsForContexts($this->contextRepository->getAvailableContexts());
|
||||
$definitions = $this->blockManager->getFilteredDefinitions('block_ui', $this->contextRepository->getAvailableContexts(), [
|
||||
'theme' => $theme,
|
||||
'region' => $region,
|
||||
]);
|
||||
// Order by category, and then by admin label.
|
||||
$definitions = $this->blockManager->getSortedDefinitions($definitions);
|
||||
// Filter out definitions that are not intended to be placed by the UI.
|
||||
@@ -110,8 +116,6 @@ class BlockLibraryController extends ControllerBase {
|
||||
return empty($definition['_block_ui_hidden']);
|
||||
});
|
||||
|
||||
$region = $request->query->get('region');
|
||||
$weight = $request->query->get('weight');
|
||||
$rows = [];
|
||||
foreach ($definitions as $plugin_id => $plugin_definition) {
|
||||
$row = [];
|
||||
|
||||
@@ -48,7 +48,8 @@ class BlockListController extends EntityListController {
|
||||
* The current request.
|
||||
*
|
||||
* @return array
|
||||
* A render array as expected by drupal_render().
|
||||
* A render array as expected by
|
||||
* \Drupal\Core\Render\RendererInterface::render().
|
||||
*/
|
||||
public function listing($theme = NULL, Request $request = NULL) {
|
||||
$theme = $theme ?: $this->config('system.theme')->get('default');
|
||||
|
||||
@@ -17,6 +17,13 @@ use Drupal\Core\Entity\EntityStorageInterface;
|
||||
* @ConfigEntityType(
|
||||
* id = "block",
|
||||
* label = @Translation("Block"),
|
||||
* label_collection = @Translation("Blocks"),
|
||||
* label_singular = @Translation("block"),
|
||||
* label_plural = @Translation("blocks"),
|
||||
* label_count = @PluralTranslation(
|
||||
* singular = "@count block",
|
||||
* plural = "@count blocks",
|
||||
* ),
|
||||
* handlers = {
|
||||
* "access" = "Drupal\block\BlockAccessControlHandler",
|
||||
* "view_builder" = "Drupal\block\BlockViewBuilder",
|
||||
|
||||
@@ -115,7 +115,7 @@ class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPlugi
|
||||
// anything else -- the block will simply have no PHP or request_path
|
||||
// visibility configuration.
|
||||
elseif ($this->skipPHP) {
|
||||
throw new MigrateSkipRowException();
|
||||
throw new MigrateSkipRowException(sprintf("The block with bid '%d' from module '%s' will have no PHP or request_path visibility configuration.", $row->getSourceProperty('bid'), $row->getSourceProperty('module'), $destination_property));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\block\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\block\Plugin\migrate\source\Block;
|
||||
use Drupal\migrate\Plugin\migrate\source\SourcePluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Gets i18n block data from source database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_block_translation",
|
||||
* source_module = "i18nblocks"
|
||||
* )
|
||||
*/
|
||||
class BlockTranslation extends Block {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Let the parent set the block table to use, but do not use the parent
|
||||
// query. Instead build a query so can use an inner join to the selected
|
||||
// block table.
|
||||
parent::query();
|
||||
$query = $this->select('i18n_blocks', 'i18n')
|
||||
->fields('i18n')
|
||||
->fields('b', ['bid', 'module', 'delta', 'theme', 'title']);
|
||||
$query->innerJoin($this->blockTable, 'b', ('b.module = i18n.module AND b.delta = i18n.delta'));
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'bid' => $this->t('The block numeric identifier.'),
|
||||
'ibid' => $this->t('The i18n_blocks block numeric identifier.'),
|
||||
'module' => $this->t('The module providing the block.'),
|
||||
'delta' => $this->t("The block's delta."),
|
||||
'type' => $this->t('Block type'),
|
||||
'language' => $this->t('Language for this field.'),
|
||||
'theme' => $this->t('Which theme the block is placed in.'),
|
||||
'default_theme' => $this->t('The default theme.'),
|
||||
'title' => $this->t('Block title.'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$row->setSourceProperty('default_theme', $this->defaultTheme);
|
||||
return SourcePluginBase::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids = parent::getIds();
|
||||
$ids['module']['alias'] = 'b';
|
||||
$ids['delta']['alias'] = 'b';
|
||||
$ids['theme']['alias'] = 'b';
|
||||
$ids['language']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user