Unverified Commit d1c7fa1b authored by larowlan's avatar larowlan

Issue #3013187 by tim.plunkett: Rename PlaceholderInterface to PreviewFallbackInterface

parent 9e18995a
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Plugin\PluginWithFormsInterface; use Drupal\Core\Plugin\PluginWithFormsInterface;
use Drupal\Core\Plugin\PluginWithFormsTrait; use Drupal\Core\Plugin\PluginWithFormsTrait;
use Drupal\Core\Render\PlaceholderInterface; use Drupal\Core\Render\PreviewFallbackInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Component\Transliteration\TransliterationInterface; use Drupal\Component\Transliteration\TransliterationInterface;
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* *
* @ingroup block_api * @ingroup block_api
*/ */
abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginInterface, PluginWithFormsInterface, PlaceholderInterface { abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginInterface, PluginWithFormsInterface, PreviewFallbackInterface {
use ContextAwarePluginAssignmentTrait; use ContextAwarePluginAssignmentTrait;
use MessengerTrait; use MessengerTrait;
...@@ -256,7 +256,7 @@ public function getMachineNameSuggestion() { ...@@ -256,7 +256,7 @@ public function getMachineNameSuggestion() {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getPlaceholderString() { public function getPreviewFallbackString() {
return $this->t('Placeholder for the "@block" block', ['@block' => $this->label()]); return $this->t('Placeholder for the "@block" block', ['@block' => $this->label()]);
} }
......
...@@ -3,19 +3,19 @@ ...@@ -3,19 +3,19 @@
namespace Drupal\Core\Render; namespace Drupal\Core\Render;
/** /**
* Allows an element to provide a placeholder representation of itself. * Allows an element to provide a fallback representation of itself for preview.
*/ */
interface PlaceholderInterface { interface PreviewFallbackInterface {
/** /**
* Returns a string to be used as a placeholder. * Returns a string to be used as a fallback during preview.
* *
* This is typically used when an element has no output and must be displayed, * This is typically used when an element has no output and must be displayed,
* for example during configuration. * for example during configuration.
* *
* @return string|\Drupal\Core\StringTranslation\TranslatableMarkup * @return string|\Drupal\Core\StringTranslation\TranslatableMarkup
* A placeholder string for this element. * A string representing for this.
*/ */
public function getPlaceholderString(); public function getPreviewFallbackString();
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResult;
use Drupal\Core\Block\BlockPluginInterface; use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Render\Element; use Drupal\Core\Render\Element;
use Drupal\Core\Render\PlaceholderInterface; use Drupal\Core\Render\PreviewFallbackInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\layout_builder\Access\LayoutPreviewAccessAllowed; use Drupal\layout_builder\Access\LayoutPreviewAccessAllowed;
use Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent; use Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent;
...@@ -100,8 +100,8 @@ public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) { ...@@ -100,8 +100,8 @@ public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) {
'#weight' => $event->getComponent()->getWeight(), '#weight' => $event->getComponent()->getWeight(),
'content' => $block->build(), 'content' => $block->build(),
]; ];
if ($event->inPreview() && Element::isEmpty($build['content']) && $block instanceof PlaceholderInterface) { if ($event->inPreview() && Element::isEmpty($build['content']) && $block instanceof PreviewFallbackInterface) {
$build['content']['#markup'] = $block->getPlaceholderString(); $build['content']['#markup'] = $block->getPreviewFallbackString();
} }
$event->setBuild($build); $event->setBuild($build);
} }
......
...@@ -130,7 +130,7 @@ public function build() { ...@@ -130,7 +130,7 @@ public function build() {
// render array. If the hook is invoked the placeholder will be // render array. If the hook is invoked the placeholder will be
// replaced. // replaced.
// @see ::replaceFieldPlaceholder() // @see ::replaceFieldPlaceholder()
'#markup' => $this->getPlaceholderString(), '#markup' => $this->getPreviewFallbackString(),
]; ];
} }
CacheableMetadata::createFromObject($this)->applyTo($build); CacheableMetadata::createFromObject($this)->applyTo($build);
...@@ -140,7 +140,7 @@ public function build() { ...@@ -140,7 +140,7 @@ public function build() {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getPlaceholderString() { public function getPreviewFallbackString() {
$entity = $this->getEntity(); $entity = $this->getEntity();
$extra_fields = $this->entityFieldManager->getExtraFields($entity->getEntityTypeId(), $entity->bundle()); $extra_fields = $this->entityFieldManager->getExtraFields($entity->getEntityTypeId(), $entity->bundle());
return new TranslatableMarkup('Placeholder for the "@field" field', ['@field' => $extra_fields['display'][$this->fieldName]['label']]); return new TranslatableMarkup('Placeholder for the "@field" field', ['@field' => $extra_fields['display'][$this->fieldName]['label']]);
......
...@@ -166,7 +166,7 @@ public function build() { ...@@ -166,7 +166,7 @@ public function build() {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getPlaceholderString() { public function getPreviewFallbackString() {
return new TranslatableMarkup('Placeholder for the "@field" field', ['@field' => $this->getFieldDefinition()->getLabel()]); return new TranslatableMarkup('Placeholder for the "@field" field', ['@field' => $this->getFieldDefinition()->getLabel()]);
} }
......
...@@ -108,7 +108,7 @@ public function defaultConfiguration() { ...@@ -108,7 +108,7 @@ public function defaultConfiguration() {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getPlaceholderString() { public function getPreviewFallbackString() {
return $this->t('Placeholder for the "@view" views block', ['@view' => $this->view->storage->label()]); return $this->t('Placeholder for the "@view" views block', ['@view' => $this->view->storage->label()]);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment