function EntityCollectorController::load in Relation 8.2
Same name and namespace in other branches
- 8 relation_entity_collector/src/Controller/EntityCollectorController.php \Drupal\relation_entity_collector\Controller\EntityCollectorController::load()
Page callback copying a relation into SESSION.
Parameters
RelationInterface $relation: A relation entity.
1 string reference to 'EntityCollectorController::load'
- relation_entity_collector.routing.yml in relation_entity_collector/
relation_entity_collector.routing.yml - relation_entity_collector/relation_entity_collector.routing.yml
File
- relation_entity_collector/
src/ Controller/ EntityCollectorController.php, line 24 - Contains \Drupal\relation_entity_collector\Controller\EntityCollectorController.
Class
- EntityCollectorController
- Returns responses for Relation routes.
Namespace
Drupal\relation_entity_collector\ControllerCode
function load(RelationInterface $relation) {
$_SESSION['relation_edit'] = $relation;
$_SESSION['relation_type'] = $relation->relation_type;
$_SESSION['relation_entity_keys'] = array();
foreach ($relation->endpoints[Language::LANGCODE_NOT_SPECIFIED] as $delta => $endpoint) {
$storage_handler = \Drupal::entityTypeManager()
->getStorage($endpoint['entity_type']);
$entities = $storage_handler
->loadMultiple(array(
$endpoint['entity_id'],
));
$entity = $entities[$endpoint['entity_id']];
list(, , $entity_bundle) = entity_extract_ids($endpoint['entity_type'], $entity);
$_SESSION['relation_entity_keys'][] = array(
'entity_type' => $endpoint['entity_type'],
'entity_id' => $endpoint['entity_id'],
'entity_bundle' => $entity_bundle,
'delta' => $delta,
'entity_label' => "{$entity_bundle}: " . entity_label($endpoint['entity_type'], $entity),
'entity_key' => $endpoint['entity_type'] . ':' . $endpoint['entity_id'],
);
}
drupal_set_message(t('The relation is ready for edit'));
drupal_goto();
}