function entity_access_by_field_post_presave in Open Social 8.3
Same name and namespace in other branches
- 8.9 modules/custom/entity_access_by_field/entity_access_by_field.module \entity_access_by_field_post_presave()
- 8 modules/custom/entity_access_by_field/entity_access_by_field.module \entity_access_by_field_post_presave()
- 8.2 modules/custom/entity_access_by_field/entity_access_by_field.module \entity_access_by_field_post_presave()
- 8.4 modules/custom/entity_access_by_field/entity_access_by_field.module \entity_access_by_field_post_presave()
- 8.5 modules/custom/entity_access_by_field/entity_access_by_field.module \entity_access_by_field_post_presave()
- 8.6 modules/custom/entity_access_by_field/entity_access_by_field.module \entity_access_by_field_post_presave()
- 8.7 modules/custom/entity_access_by_field/entity_access_by_field.module \entity_access_by_field_post_presave()
- 8.8 modules/custom/entity_access_by_field/entity_access_by_field.module \entity_access_by_field_post_presave()
- 10.3.x modules/custom/entity_access_by_field/entity_access_by_field.module \entity_access_by_field_post_presave()
- 10.0.x modules/custom/entity_access_by_field/entity_access_by_field.module \entity_access_by_field_post_presave()
- 10.1.x modules/custom/entity_access_by_field/entity_access_by_field.module \entity_access_by_field_post_presave()
- 10.2.x modules/custom/entity_access_by_field/entity_access_by_field.module \entity_access_by_field_post_presave()
Implements hook_ENTITY_TYPE_presave().
File
- modules/
custom/ entity_access_by_field/ entity_access_by_field.module, line 166 - Entity Access By Field module file.
Code
function entity_access_by_field_post_presave(PostInterface $post) {
$field_definitions = $post
->getFieldDefinitions();
foreach ($field_definitions as $field_name => $field_definition) {
if ($field_definition
->getType() == 'entity_access_field' && $post
->get($field_name)
->isEmpty()) {
$default_visibility = _entity_access_by_field_get_default_visibility($post);
$post
->get($field_name)
->setValue($default_visibility);
}
}
}