protected function PanelizerDefaultPanelsStorage::parseId in Panelizer 8.4
Same name and namespace in other branches
- 8.5 src/Plugin/PanelsStorage/PanelizerDefaultPanelsStorage.php \Drupal\panelizer\Plugin\PanelsStorage\PanelizerDefaultPanelsStorage::parseId()
- 8.3 src/Plugin/PanelsStorage/PanelizerDefaultPanelsStorage.php \Drupal\panelizer\Plugin\PanelsStorage\PanelizerDefaultPanelsStorage::parseId()
Converts the storage id into its component parts.
Parameters
string $id: The storage id. There are two formats that can potentially be used:
- The first is the normal format that we actually store: "entity_type_id:bundle:view_mode:name"
- The second is a special internal format we use in the IPE so we can
correctly set context: "*entity_type_id:entity_id:view_mode:name"
Return value
array An array with 4 or 5 items:
- Entity type id: string
- Bundle name: string
- View mode: string
- Default name: string
- Entity: \Drupal\Core\Entity\EntityInterface|NULL
Throws
\Drupal\panelizer\Exception\PanelizerException
3 calls to PanelizerDefaultPanelsStorage::parseId()
- PanelizerDefaultPanelsStorage::access in src/
Plugin/ PanelsStorage/ PanelizerDefaultPanelsStorage.php - PanelizerDefaultPanelsStorage::load in src/
Plugin/ PanelsStorage/ PanelizerDefaultPanelsStorage.php - PanelizerDefaultPanelsStorage::save in src/
Plugin/ PanelsStorage/ PanelizerDefaultPanelsStorage.php
File
- src/
Plugin/ PanelsStorage/ PanelizerDefaultPanelsStorage.php, line 89
Class
- PanelizerDefaultPanelsStorage
- Panels storage service that stores Panels displays in Panelizer defaults.
Namespace
Drupal\panelizer\Plugin\PanelsStorageCode
protected function parseId($id) {
list($entity_type_id, $part_two, $view_mode, $name) = explode(':', $id);
if (strpos($entity_type_id, '*') === 0) {
$entity_type_id = substr($entity_type_id, 1);
$storage = $this->entityTypeManager
->getStorage($entity_type_id);
if ($entity = $storage
->load($part_two)) {
$bundle = $entity
->bundle();
}
else {
throw new PanelizerException("Unable to load {$entity_type_id} with id {$part_two}");
}
}
else {
$entity = NULL;
$bundle = $part_two;
}
return [
$entity_type_id,
$bundle,
$view_mode,
$name,
$entity,
];
}