Unverified Commit d1c7fa1b authored by larowlan's avatar larowlan

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

parent 9e18995a
......@@ -11,7 +11,7 @@
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Plugin\PluginWithFormsInterface;
use Drupal\Core\Plugin\PluginWithFormsTrait;
use Drupal\Core\Render\PlaceholderInterface;
use Drupal\Core\Render\PreviewFallbackInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Component\Transliteration\TransliterationInterface;
......@@ -24,7 +24,7 @@
*
* @ingroup block_api
*/
abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginInterface, PluginWithFormsInterface, PlaceholderInterface {
abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginInterface, PluginWithFormsInterface, PreviewFallbackInterface {
use ContextAwarePluginAssignmentTrait;
use MessengerTrait;
......@@ -256,7 +256,7 @@ public function getMachineNameSuggestion() {
/**
* {@inheritdoc}
*/
public function getPlaceholderString() {
public function getPreviewFallbackString() {
return $this->t('Placeholder for the "@block" block', ['@block' => $this->label()]);
}
......
......@@ -3,19 +3,19 @@
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,
* for example during configuration.
*
* @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 @@
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\PlaceholderInterface;
use Drupal\Core\Render\PreviewFallbackInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\layout_builder\Access\LayoutPreviewAccessAllowed;
use Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent;
......@@ -100,8 +100,8 @@ public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) {
'#weight' => $event->getComponent()->getWeight(),
'content' => $block->build(),
];
if ($event->inPreview() && Element::isEmpty($build['content']) && $block instanceof PlaceholderInterface) {
$build['content']['#markup'] = $block->getPlaceholderString();
if ($event->inPreview() && Element::isEmpty($build['content']) && $block instanceof PreviewFallbackInterface) {
$build['content']['#markup'] = $block->getPreviewFallbackString();
}
$event->setBuild($build);
}
......
......@@ -130,7 +130,7 @@ public function build() {
// render array. If the hook is invoked the placeholder will be
// replaced.
// @see ::replaceFieldPlaceholder()
'#markup' => $this->getPlaceholderString(),
'#markup' => $this->getPreviewFallbackString(),
];
}
CacheableMetadata::createFromObject($this)->applyTo($build);
......@@ -140,7 +140,7 @@ public function build() {
/**
* {@inheritdoc}
*/
public function getPlaceholderString() {
public function getPreviewFallbackString() {
$entity = $this->getEntity();
$extra_fields = $this->entityFieldManager->getExtraFields($entity->getEntityTypeId(), $entity->bundle());
return new TranslatableMarkup('Placeholder for the "@field" field', ['@field' => $extra_fields['display'][$this->fieldName]['label']]);
......
......@@ -166,7 +166,7 @@ public function build() {
/**
* {@inheritdoc}
*/
public function getPlaceholderString() {
public function getPreviewFallbackString() {
return new TranslatableMarkup('Placeholder for the "@field" field', ['@field' => $this->getFieldDefinition()->getLabel()]);
}
......
......@@ -108,7 +108,7 @@ public function defaultConfiguration() {
/**
* {@inheritdoc}
*/
public function getPlaceholderString() {
public function getPreviewFallbackString() {
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