Skip to content
Snippets Groups Projects

Resolve #3519543 "Bug sample entity"

5 files
+ 22
4
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -6,6 +6,7 @@ use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Context\EntityContext;
use Drupal\Core\Render\RenderContext;
/**
@@ -161,6 +162,17 @@ class ComponentForm extends ComponentFormBase {
$contextComponentDefinition = ContextDefinition::create('string');
$element['#source_contexts']['component_id'] = new Context($contextComponentDefinition, $component_id);
}
// Check the root entity if it is a sample entity
// and pass this sample entity down the render tree.
// Plugins can use this determine if they running in sample mode.
if (isset($element['#source_contexts']['entity']) &&
// Pass the root entity down.
!isset($element['#source_contexts']['sample:entity'])) {
$entity = $element['#source_contexts']['entity']->getContextValue();
if ($entity->isSampleEntity) {
$element['#source_contexts']['sample:entity'] = $element['#source_contexts']['entity'];
}
}
if (empty($initial_component_id)) {
$component_selector_form = array_merge(self::buildComponentSelectorForm(
$wrapper_id,
Loading