public static function ViewsBulkOperationsFormTrait::calculateEntityBulkFormKey in Views Bulk Operations (VBO) 8.2
Same name and namespace in other branches
- 8.3 src/Form/ViewsBulkOperationsFormTrait.php \Drupal\views_bulk_operations\Form\ViewsBulkOperationsFormTrait::calculateEntityBulkFormKey()
- 4.0.x src/Form/ViewsBulkOperationsFormTrait.php \Drupal\views_bulk_operations\Form\ViewsBulkOperationsFormTrait::calculateEntityBulkFormKey()
Calculates the bulk form key for an entity.
This generates a key that is used as the checkbox return value when submitting the bulk form.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity to calculate a bulk form key for.
mixed $base_field_value: The value of the base field for this view result.
Return value
string The bulk form key representing the entity id, language and revision (if applicable) as one string.
See also
self::loadEntityFromBulkFormKey()
1 call to ViewsBulkOperationsFormTrait::calculateEntityBulkFormKey()
- ViewsBulkOperationsBulkForm::viewsForm in src/
Plugin/ views/ field/ ViewsBulkOperationsBulkForm.php - Form constructor for the bulk form.
File
- src/
Form/ ViewsBulkOperationsFormTrait.php, line 79
Class
- ViewsBulkOperationsFormTrait
- Defines common methods for Views Bulk Operations forms.
Namespace
Drupal\views_bulk_operations\FormCode
public static function calculateEntityBulkFormKey(EntityInterface $entity, $base_field_value) {
// We don't really need the entity ID or type ID, since only the
// base field value and language are used to select rows, but
// other modules may need those values.
$key_parts = [
$base_field_value,
$entity
->language()
->getId(),
$entity
->getEntityTypeId(),
$entity
->id(),
];
// An entity ID could be an arbitrary string (although they are typically
// numeric). JSON then Base64 encoding ensures 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);
}