public function EntityAccessByFieldPermissions::getRealmWithPermission in Open Social 8
Same name and namespace in other branches
- 8.9 modules/custom/entity_access_by_field/src/EntityAccessByFieldPermissions.php \Drupal\entity_access_by_field\EntityAccessByFieldPermissions::getRealmWithPermission()
- 8.2 modules/custom/entity_access_by_field/src/EntityAccessByFieldPermissions.php \Drupal\entity_access_by_field\EntityAccessByFieldPermissions::getRealmWithPermission()
- 8.3 modules/custom/entity_access_by_field/src/EntityAccessByFieldPermissions.php \Drupal\entity_access_by_field\EntityAccessByFieldPermissions::getRealmWithPermission()
- 8.4 modules/custom/entity_access_by_field/src/EntityAccessByFieldPermissions.php \Drupal\entity_access_by_field\EntityAccessByFieldPermissions::getRealmWithPermission()
- 8.5 modules/custom/entity_access_by_field/src/EntityAccessByFieldPermissions.php \Drupal\entity_access_by_field\EntityAccessByFieldPermissions::getRealmWithPermission()
- 8.6 modules/custom/entity_access_by_field/src/EntityAccessByFieldPermissions.php \Drupal\entity_access_by_field\EntityAccessByFieldPermissions::getRealmWithPermission()
- 8.7 modules/custom/entity_access_by_field/src/EntityAccessByFieldPermissions.php \Drupal\entity_access_by_field\EntityAccessByFieldPermissions::getRealmWithPermission()
- 8.8 modules/custom/entity_access_by_field/src/EntityAccessByFieldPermissions.php \Drupal\entity_access_by_field\EntityAccessByFieldPermissions::getRealmWithPermission()
- 10.3.x modules/custom/entity_access_by_field/src/EntityAccessByFieldPermissions.php \Drupal\entity_access_by_field\EntityAccessByFieldPermissions::getRealmWithPermission()
- 10.0.x modules/custom/entity_access_by_field/src/EntityAccessByFieldPermissions.php \Drupal\entity_access_by_field\EntityAccessByFieldPermissions::getRealmWithPermission()
- 10.1.x modules/custom/entity_access_by_field/src/EntityAccessByFieldPermissions.php \Drupal\entity_access_by_field\EntityAccessByFieldPermissions::getRealmWithPermission()
- 10.2.x modules/custom/entity_access_by_field/src/EntityAccessByFieldPermissions.php \Drupal\entity_access_by_field\EntityAccessByFieldPermissions::getRealmWithPermission()
Get the realms array with permissions as value.
File
- modules/
custom/ entity_access_by_field/ src/ EntityAccessByFieldPermissions.php, line 92
Class
- EntityAccessByFieldPermissions
- EntityAccessByFieldPermissions.
Namespace
Drupal\entity_access_by_fieldCode
public function getRealmWithPermission() {
$realms = [];
$contentTypes = $this
->getContentTypes();
foreach ($contentTypes as $bundle) {
$entity_type = 'node';
$fields = $this
->getEntityAccessFields($entity_type, $bundle);
/** @var \Drupal\field\Entity\FieldConfig $field */
foreach ($fields as $field) {
$field_storage = $field
->getFieldStorageDefinition();
// @TODO Add support for allowed_values_function.
$allowed_values = $field_storage
->getSetting('allowed_values');
if (!empty($allowed_values)) {
foreach ($allowed_values as $field_key => $field_label) {
// e.g. label = node.article.field_content_visibility:public.
$permission_label = $field
->id() . ':' . $field_key;
$op = 'view';
$permission = $op . ' ' . $permission_label . ' content';
$bundle_id = $bundle
->id();
$field_name = $field
->getName();
$realm = $this
->getRealmForFieldValue($op, $entity_type, $bundle_id, $field_name, $field_key);
$realms[$realm] = $permission;
}
}
}
}
return $realms;
}