Skip to content

Commit

Permalink
HPC-9966: Fix issues with element contexts on cluster pages
Browse files Browse the repository at this point in the history
  • Loading branch information
berliner committed Dec 9, 2024
1 parent 8e72f43 commit 58060c6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Drupal\Core\Cache\Cache;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Markup;
use Drupal\ghi_base_objects\Entity\BaseObjectAwareEntityInterface;
use Drupal\ghi_blocks\Interfaces\ConfigValidationInterface;
use Drupal\ghi_blocks\Interfaces\MultiStepFormBlockInterface;
use Drupal\ghi_blocks\Interfaces\OverrideDefaultTitleBlockInterface;
Expand Down Expand Up @@ -1201,11 +1202,12 @@ private function getAttachmentSwitcher() {
* An array with context data or query handlers.
*/
public function getBlockContext() {
$page_node = $this->getPageNode();
return [
'page_node' => $this->getPageNode(),
'page_node' => $page_node,
'plan_object' => $this->getCurrentPlanObject(),
'base_object' => $this->getCurrentBaseObject(),
'context_node' => $this->getPageNode(),
'base_object' => $this->getCurrentBaseObject($page_node instanceof BaseObjectAwareEntityInterface ? $page_node : NULL),
'context_node' => $page_node,
'attachment_prototype' => $this->getAttachmentPrototype(),
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Markup;
use Drupal\Core\Security\TrustedCallbackInterface;
use Drupal\ghi_base_objects\Entity\BaseObjectAwareEntityInterface;
use Drupal\ghi_blocks\Interfaces\ConfigValidationInterface;
use Drupal\ghi_blocks\Interfaces\ConfigurableTableBlockInterface;
use Drupal\ghi_blocks\Interfaces\CustomLinkBlockInterface;
Expand Down Expand Up @@ -612,7 +613,8 @@ private function getEntityRefCodeOptions() {
* An array of plan entity objects for the current context.
*/
private function getPlanEntities($entity_ref_code = NULL) {
$context_object = $this->getCurrentBaseObject();
$page_node = $this->getPageNode();
$context_object = $this->getCurrentBaseObject($page_node instanceof BaseObjectAwareEntityInterface ? $page_node : NULL);

if ($entity_ref_code == 'PL' && $context_object instanceof Plan) {
/** @var \Drupal\ghi_plans\Plugin\EndpointQuery\EntityQuery $query */
Expand Down Expand Up @@ -730,12 +732,13 @@ public function getBlockContext() {
// This can be any parent node, e.g. SectionNode or PlanClusterNode.
$base_entity = $this->getCurrentBaseEntity();
$section_node = $this->sectionManager->getCurrentSection($base_entity);
$page_node = $this->getPageNode();
return [
'section_node' => $section_node,
'page_node' => $this->getPageNode(),
'page_node' => $page_node,
'plan_object' => $plan_object,
'base_object' => $this->getCurrentBaseObject(),
'context_node' => $this->getPageNode(),
'base_object' => $this->getCurrentBaseObject($page_node instanceof BaseObjectAwareEntityInterface ? $page_node : NULL),
'context_node' => $page_node,
'entities' => $plan_entities,
'entity_types' => $this->logframeManager->getEntityTypesFromPlanObject($plan_object),
'attachment_prototypes' => $this->getAttachmentPrototypes(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\ghi_base_objects\Entity\BaseObjectAwareEntityInterface;
use Drupal\ghi_blocks\Interfaces\ConfigValidationInterface;
use Drupal\ghi_blocks\Interfaces\ConfigurableTableBlockInterface;
use Drupal\ghi_blocks\Interfaces\MultiStepFormBlockInterface;
Expand Down Expand Up @@ -219,7 +220,7 @@ public function getBlockContext() {
'section_node' => $this->getCurrentBaseEntity(),
'page_node' => $page_node,
'plan_object' => $this->getCurrentPlanObject(),
'base_object' => $this->getCurrentBaseObject(),
'base_object' => $this->getCurrentBaseObject($page_node instanceof BaseObjectAwareEntityInterface ? $page_node : NULL),
'context_node' => $page_node,
];
}
Expand Down

0 comments on commit 58060c6

Please sign in to comment.