public static function FillPdfLinkManipulator::parseEntityIds in FillPDF 5.0.x
Same name and namespace in other branches
- 8.4 src/Service/FillPdfLinkManipulator.php \Drupal\fillpdf\Service\FillPdfLinkManipulator::parseEntityIds()
Helper method parsing entities.
@internal
Parameters
array $query: Array of query parameters.
Return value
array An associative array representing the request context.
2 calls to FillPdfLinkManipulator::parseEntityIds()
- FillPdfLinkManipulator::parseLink in src/
Service/ FillPdfLinkManipulator.php - Parses a Url object.
- ParseEntityIdsTest::testEntityIds in tests/
src/ Unit/ LinkManipulator/ ParseEntityIdsTest.php - Tests parsing entity IDs from query parameters and back.
File
- src/
Service/ FillPdfLinkManipulator.php, line 143
Class
Namespace
Drupal\fillpdf\ServiceCode
public static function parseEntityIds(array $query) {
$context = [
'entity_ids' => [],
];
// Convert single entity ID into array notation.
if (!empty($query['entity_id'])) {
$query['entity_ids'] = (array) $query['entity_id'];
}
elseif (empty($query['entity_ids'])) {
return $context;
}
// Re-key entity IDs so they can be loaded easily with loadMultiple().
foreach ($query['entity_ids'] as $entity_id) {
list($entity_type, $entity_id) = array_pad(explode(':', $entity_id), -2, '');
if (empty($entity_type)) {
$entity_type = !empty($query['entity_type']) ? $query['entity_type'] : 'node';
}
$context['entity_ids'][$entity_type][$entity_id] = $entity_id;
}
return $context;
}