Skip to content

Commit

Permalink
Prevent errors when importing page configuration for new homepage and…
Browse files Browse the repository at this point in the history
… errors when running bulk section creation
  • Loading branch information
berliner committed Nov 21, 2023
1 parent bb408db commit f7fc037
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion html/modules/custom/ghi_sections/src/SectionCreateBatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public static function process(SectionManager $section_manager, array $bundle, $

// The basic query to retrieve base object ids.
$query = \Drupal::entityQuery('base_object')
->condition('type', $bundle, 'IN');
->condition('type', $bundle, 'IN')
->accessCheck(FALSE);

$result = $query->execute();

Expand Down
8 changes: 7 additions & 1 deletion html/modules/custom/hpc_common/src/Plugin/HPCBlockBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\hpc_common\Helpers\ContextHelper;
use Drupal\hpc_common\Helpers\RequestHelper;
use Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage;
use Drupal\layout_builder\SectionStorageInterface;
use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface;
Expand Down Expand Up @@ -385,7 +386,7 @@ public function setPage($page_parameters = NULL) {
$node = is_object($page_parameters['node']) ? $page_parameters['node'] : $entity_storage->load($page_parameters['node']);
$this->page = $node->bundle() . '_node';
}
elseif (!empty($page_parameters['section_storage'])) {
elseif (!empty($page_parameters['section_storage']) && $page_parameters['section_storage'] instanceof OverridesSectionStorage) {
// Layout builder editing context.
$entity = $page_parameters['section_storage']->getContextValue('entity');
if ($entity->bundle() == 'page_variant') {
Expand All @@ -398,6 +399,11 @@ public function setPage($page_parameters = NULL) {
$this->page = $entity->bundle() . '_' . $entity->getEntityTypeId();
}
}
elseif (!empty($page_parameters['entity'])) {
// Content entity, e.g. node.
$entity = $page_parameters['entity'];
$this->page = $entity->bundle() . '_' . $entity->getEntityTypeId();
}
else {
// No page identified.
$this->page = FALSE;
Expand Down

0 comments on commit f7fc037

Please sign in to comment.