diff --git a/src/Plugin/DisplayBuilder/StandardDisplayBuilder.php b/src/Plugin/DisplayBuilder/StandardDisplayBuilder.php
index 1cd592f..1728a8e 100644
--- a/src/Plugin/DisplayBuilder/StandardDisplayBuilder.php
+++ b/src/Plugin/DisplayBuilder/StandardDisplayBuilder.php
@@ -121,7 +121,7 @@ class StandardDisplayBuilder extends DisplayBuilderBase implements PluginWizardI
// pane information.
$build[$region] = $panels_display->getRegionStyle($region)->buildRegion($panels_display, $build[$region], $region, $blocks);
}
- $build['#title'] = $panels_display->renderPageTitle($panels_display->configuration['page_title']);
+
return $build;
}
diff --git a/src/Plugin/DisplayVariant/PanelsDisplayVariant.php b/src/Plugin/DisplayVariant/PanelsDisplayVariant.php
index 0c67a02..42fd56d 100644
--- a/src/Plugin/DisplayVariant/PanelsDisplayVariant.php
+++ b/src/Plugin/DisplayVariant/PanelsDisplayVariant.php
@@ -8,6 +8,7 @@ use Drupal\Core\Block\BlockManager;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Condition\ConditionManager;
use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Layout\LayoutInterface;
@@ -89,6 +90,13 @@ class PanelsDisplayVariant extends BlockDisplayVariant implements PluginWizardIn
protected $configFactory;
/**
+ * The configuration manager.
+ *
+ * @var \Drupal\panels\Storage\PanelsStorageManagerInterface
+ */
+ protected $entityTypeManager;
+
+ /**
* Constructs a new PanelsDisplayVariant.
*
* @param array $configuration
@@ -116,12 +124,13 @@ class PanelsDisplayVariant extends BlockDisplayVariant implements PluginWizardIn
* @param \Drupal\Core\Layout\LayoutPluginManagerInterface $layout_manager
* The layout plugin manager.
*/
- public function __construct(array $configuration, $plugin_id, $plugin_definition, ContextHandlerInterface $context_handler, AccountInterface $account, UuidInterface $uuid_generator, Token $token, ConfigFactoryInterface $config_factory, BlockManager $block_manager, ConditionManager $condition_manager, ModuleHandlerInterface $module_handler, DisplayBuilderManagerInterface $builder_manager, LayoutPluginManagerInterface $layout_manager, PanelsStylePluginManagerInterface $style_manager) {
+ public function __construct(array $configuration, $plugin_id, $plugin_definition, ContextHandlerInterface $context_handler, AccountInterface $account, UuidInterface $uuid_generator, Token $token, ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, BlockManager $block_manager, ConditionManager $condition_manager, ModuleHandlerInterface $module_handler, DisplayBuilderManagerInterface $builder_manager, LayoutPluginManagerInterface $layout_manager, PanelsStylePluginManagerInterface $style_manager) {
$this->moduleHandler = $module_handler;
$this->builderManager = $builder_manager;
$this->layoutManager = $layout_manager;
$this->styleManager = $style_manager;
$this->configFactory = $config_factory;
+ $this->entityTypeManager = $entity_type_manager;
parent::__construct($configuration, $plugin_id, $plugin_definition, $context_handler, $account, $uuid_generator, $token, $block_manager, $condition_manager);
}
@@ -139,6 +148,7 @@ class PanelsDisplayVariant extends BlockDisplayVariant implements PluginWizardIn
$container->get('uuid'),
$container->get('token'),
$container->get('config.factory'),
+ $container->get('entity_type.manager'),
$container->get('plugin.manager.block'),
$container->get('plugin.manager.condition'),
$container->get('module_handler'),
@@ -150,6 +160,17 @@ class PanelsDisplayVariant extends BlockDisplayVariant implements PluginWizardIn
}
/**
+ * {inheritdoc}
+ */
+ public function label() {
+ // Page manager stores the label on the page_variant
+ if ($this->getStorageType() == 'page_manager') {
+ return $this->entityTypeManager->getStorage('page_variant')->load($this->getStorageId())->label();
+ }
+ return parent::label();
+ }
+
+ /**
* Returns the builder assigned to this display variant.
*
* @return \Drupal\panels\Plugin\DisplayBuilder\DisplayBuilderInterface
@@ -625,7 +646,7 @@ class PanelsDisplayVariant extends BlockDisplayVariant implements PluginWizardIn
* @return string
* The page title after replacing any tokens.
*/
- public function renderPageTitle($page_title) {
+ protected function renderPageTitle($page_title) {
$data = $this->getContextAsTokenData();
// Token replace only escapes replacement values, ensure a consistent
// behavior by also escaping the input and then returning it as a Markup
diff --git a/src/Plugin/PanelsStyle/PanelsStyleBase.php b/src/Plugin/PanelsStyle/PanelsStyleBase.php
index 7edcd04..ec3d1d7 100644
--- a/src/Plugin/PanelsStyle/PanelsStyleBase.php
+++ b/src/Plugin/PanelsStyle/PanelsStyleBase.php
@@ -10,8 +10,10 @@ namespace Drupal\panels\Plugin\PanelsStyle;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant;
use Drupal\panels\Plugin\PanelsStyle\PanelsStyleInterface;
@@ -20,6 +22,8 @@ use Drupal\panels\Plugin\PanelsStyle\PanelsStyleInterface;
*/
abstract class PanelsStyleBase extends PluginBase implements PanelsStyleInterface {
+ use StringTranslationTrait;
+
/**
* The style configuration.
*
@@ -30,6 +34,14 @@ abstract class PanelsStyleBase extends PluginBase implements PanelsStyleInterfac
/**
* {@inheritdoc}
*/
+ public function __construct(array $configuration, $plugin_id, $plugin_definition) {
+ parent::__construct($configuration, $plugin_id, $plugin_definition);
+ $this->setConfiguration($configuration);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
public function buildRegion(PanelsDisplayVariant $display, array $build, $region, array $blocks) {
$region_name = Html::getClass("block-region-$region");
$build['#prefix'] = '
';
@@ -83,14 +95,14 @@ abstract class PanelsStyleBase extends PluginBase implements PanelsStyleInterfac
* {@inheritdoc}
*/
public function getConfiguration() {
- return array_merge($this->defaultConfiguration(), $this->configuration);
+ return $this->configuration;
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) {
- $this->configuration = $configuration;
+ $this->configuration = NestedArray::mergeDeep($this->defaultConfiguration(), $configuration);
}
/**
diff --git a/src/Plugin/PanelsStyle/PanelsStyleBroken.php b/src/Plugin/PanelsStyle/PanelsStyleBroken.php
index 5f312af..a6584d9 100644
--- a/src/Plugin/PanelsStyle/PanelsStyleBroken.php
+++ b/src/Plugin/PanelsStyle/PanelsStyleBroken.php
@@ -21,9 +21,11 @@ class PanelsStyleBroken extends PanelsStyleBase {
* {@inheritdoc}
*/
public function buildRegion(PanelsDisplayVariant $display, array $build, $region, array $blocks) {
- \Drupal::logger('panels')->alert('THe panels style plugin named "@style" is missing for region "@region"', [
- '@region' => $region,
+ \Drupal::logger('panels')->alert('The panels style plugin named "@style" is missing for region "@region" on the variant named "@variant" (id: "@id")', [
'@style' => $display->getConfiguration()['regions'][$region]['style']['plugin'],
+ '@region' => $region,
+ '@variant' => $display->label(),
+ '@id' => $display->getStorageId(),
]);
return parent::buildRegion($display, $build, $region, $blocks);
}
@@ -32,9 +34,11 @@ class PanelsStyleBroken extends PanelsStyleBase {
* {@inheritdoc}
*/
public function buildBlock(PanelsDisplayVariant $display, BlockPluginInterface $block) {
- \Drupal::logger('panels')->alert('The panels style plugin named "@style" is missing for block "@block"', [
+ \Drupal::logger('panels')->alert('The panels style plugin named "@style" is missing for block "@block" on the variant named "@variant" (id: "@id")', [
'@block' => $block->label(),
'@style' => $block->getConfiguration()['style']['plugin'],
+ '@variant' => $display->label(),
+ '@id' => $display->getStorageId(),
]);
return parent::buildBlock($display, $block);
}
@@ -44,7 +48,7 @@ class PanelsStyleBroken extends PanelsStyleBase {
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['broken_message'] = [
- '#markup' => t('The panels style plugin is missing for this block or region.'),
+ '#markup' => $this->t('The panels style plugin is missing for this block or region.'),
];
return $form;
}
diff --git a/src/Plugin/PanelsStyle/PanelsStyleList.php b/src/Plugin/PanelsStyle/PanelsStyleList.php
index eacde33..efbfd8a 100644
--- a/src/Plugin/PanelsStyle/PanelsStyleList.php
+++ b/src/Plugin/PanelsStyle/PanelsStyleList.php
@@ -50,10 +50,10 @@ class PanelsStyleList extends PanelsStyleBase {
$form['type'] = [
'#type' => 'select',
- '#title' => t('Type'),
+ '#title' => $this->t('Type'),
'#options' => [
- 'ul' => 'Unordered',
- 'ol' => 'Ordered',
+ 'ul' => $this->t('Unordered'),
+ 'ol' => $this->t('Ordered'),
],
'#default_value' => $config['type'],
];
diff --git a/src/Plugin/PanelsStyle/PanelsStylePluginManager.php b/src/Plugin/PanelsStyle/PanelsStylePluginManager.php
index e7ad7a1..17d6662 100644
--- a/src/Plugin/PanelsStyle/PanelsStylePluginManager.php
+++ b/src/Plugin/PanelsStyle/PanelsStylePluginManager.php
@@ -50,9 +50,7 @@ class PanelsStylePluginManager extends DefaultPluginManager implements PanelsSty
public function getDefinitions() {
$definitions = parent::getDefinitions();
// Don't return the fallback plugin definition
- if (isset($definitions['panels_broken'])) {
- unset($definitions['panels_broken']);
- }
+ unset($definitions['panels_broken']);
return $definitions;
}
diff --git a/tests/src/Unit/PanelsDisplayVariantTest.php b/tests/src/Unit/PanelsDisplayVariantTest.php
index 24125db..c72bf70 100644
--- a/tests/src/Unit/PanelsDisplayVariantTest.php
+++ b/tests/src/Unit/PanelsDisplayVariantTest.php
@@ -5,6 +5,7 @@ namespace Drupal\Tests\panels\Unit;
use Drupal\Component\Uuid\UuidInterface;
use Drupal\Core\Block\BlockManager;
use Drupal\Core\Condition\ConditionManager;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormState;
use Drupal\Core\Layout\LayoutDefinition;
@@ -102,6 +103,7 @@ class PanelsDisplayVariantTest extends UnitTestCase {
$this->layout = $this->prophesize(LayoutInterface::class);
$this->styleManager = $this->prophesize(PanelsStylePluginManagerInterface::class);
$this->style = $this->prophesize(PanelsStyleInterface::class);
+ $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class);
$this->layoutManager
->createInstance(Argument::type('string'), Argument::type('array'))
@@ -111,7 +113,7 @@ class PanelsDisplayVariantTest extends UnitTestCase {
->createInstance(Argument::type('string'), Argument::type('array'))
->willReturn($this->style->reveal());
- $this->variant = new PanelsDisplayVariant([], '', [], $this->contextHandler->reveal(), $this->account->reveal(), $this->uuidGenerator->reveal(), $this->token->reveal(), $this->configFactory, $this->blockManager->reveal(), $this->conditionManager->reveal(), $this->moduleHandler->reveal(), $this->builderManager->reveal(), $this->layoutManager->reveal(), $this->styleManager->reveal());
+ $this->variant = new PanelsDisplayVariant([], '', [], $this->contextHandler->reveal(), $this->account->reveal(), $this->uuidGenerator->reveal(), $this->token->reveal(), $this->configFactory, $this->entityTypeManager->reveal(), $this->blockManager->reveal(), $this->conditionManager->reveal(), $this->moduleHandler->reveal(), $this->builderManager->reveal(), $this->layoutManager->reveal(), $this->styleManager->reveal());
}
/**
diff --git a/tests/src/Unit/StandardDisplayBuilderTest.php b/tests/src/Unit/StandardDisplayBuilderTest.php
index b953ce8..a7c95f2 100644
--- a/tests/src/Unit/StandardDisplayBuilderTest.php
+++ b/tests/src/Unit/StandardDisplayBuilderTest.php
@@ -6,6 +6,7 @@ use Drupal\Component\Uuid\UuidInterface;
use Drupal\Core\Block\BlockManager;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Condition\ConditionManager;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\Context\ContextHandlerInterface;
use Drupal\Core\Session\AccountInterface;
@@ -142,6 +143,7 @@ class StandardDisplayBuilderTest extends UnitTestCase {
'default_style_region' => 'panels_default',
],
]);
+ $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class);
$this->blockManager = $this->prophesize(BlockManager::class);
$this->conditionManager = $this->prophesize(ConditionManager::class);
$this->builderManager = $this->prophesize(DisplayBuilderManagerInterface::class);
@@ -182,6 +184,7 @@ class StandardDisplayBuilderTest extends UnitTestCase {
$this->uuidGenerator->reveal(),
$this->token->reveal(),
$this->configFactory,
+ $this->entityTypeManager->reveal(),
$this->blockManager->reveal(),
$this->conditionManager->reveal(),
$this->moduleHandler->reveal(),