protected function BulkForm::calculateEntityBulkFormKey in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Plugin/views/field/BulkForm.php \Drupal\system\Plugin\views\field\BulkForm::calculateEntityBulkFormKey()
Calculates a bulk form key.
This generates a key that is used as the checkbox return value when submitting a bulk form. This key allows the entity for the row to be loaded totally independently of the executed view row.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity to calculate a bulk form key for.
bool $use_revision: Whether the revision id should be added to the bulk form key. This should be set to TRUE only if the view is listing entity revisions.
Return value
string The bulk form key representing the entity's id, language and revision (if applicable) as one string.
See also
self::loadEntityFromBulkFormKey()
1 call to BulkForm::calculateEntityBulkFormKey()
- BulkForm::viewsForm in core/
modules/ system/ src/ Plugin/ views/ field/ BulkForm.php - Form constructor for the bulk form.
File
- core/
modules/ system/ src/ Plugin/ views/ field/ BulkForm.php, line 460 - Contains \Drupal\system\Plugin\views\field\BulkForm.
Class
- BulkForm
- Defines a actions-based bulk operation form element.
Namespace
Drupal\system\Plugin\views\fieldCode
protected function calculateEntityBulkFormKey(EntityInterface $entity, $use_revision) {
$key_parts = [
$entity
->language()
->getId(),
$entity
->id(),
];
if ($entity instanceof RevisionableInterface && $use_revision) {
$key_parts[] = $entity
->getRevisionId();
}
// An entity ID could be an arbitrary string (although they are typically
// numeric). JSON then Base64 encoding ensures the the bulk_form_key is
// safe to use in HTML, and that the key parts can be retrieved.
$key = json_encode($key_parts);
return base64_encode($key);
}