You are here

protected function PanelizerDefaultPanelsStorage::getEntityContext in Panelizer 8.3

Same name and namespace in other branches
  1. 8.5 src/Plugin/PanelsStorage/PanelizerDefaultPanelsStorage.php \Drupal\panelizer\Plugin\PanelsStorage\PanelizerDefaultPanelsStorage::getEntityContext()
  2. 8.4 src/Plugin/PanelsStorage/PanelizerDefaultPanelsStorage.php \Drupal\panelizer\Plugin\PanelsStorage\PanelizerDefaultPanelsStorage::getEntityContext()

Returns the entity context.

Wraps creating new Context objects to avoid typed data in tests.

Parameters

string $entity_type_id: The entity type id.

\Drupal\Core\Entity\EntityInterface|NULL $entity: The entity.

Return value

\Drupal\Core\Plugin\Context\Context[] The available contexts.

1 call to PanelizerDefaultPanelsStorage::getEntityContext()
PanelizerDefaultPanelsStorage::load in src/Plugin/PanelsStorage/PanelizerDefaultPanelsStorage.php

File

src/Plugin/PanelsStorage/PanelizerDefaultPanelsStorage.php, line 123

Class

PanelizerDefaultPanelsStorage
Panels storage service that stores Panels displays in Panelizer defaults.

Namespace

Drupal\panelizer\Plugin\PanelsStorage

Code

protected function getEntityContext($entity_type_id, EntityInterface $entity = NULL) {
  $contexts = [];

  // Set a placeholder context so that the calling code knows that we need
  // an entity context. If we have the value available, then we actually set
  // the context value.
  $contexts['@panelizer.entity_context:entity'] = new Context(new ContextDefinition('entity:' . $entity_type_id, NULL, TRUE), $entity);
  return $contexts;
}