Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HelenaEksler/d9d7dad3dd9010e5b9c5 to your computer and use it in GitHub Desktop.
Save HelenaEksler/d9d7dad3dd9010e5b9c5 to your computer and use it in GitHub Desktop.
checkPropertyAccess()
/**
* Overrides \RestfulEntityBaseTaxonomyTerm::checkPropertyAccess().
*
* Allow user to set the parent term for the unsaved term, even if the user
* doesn't have access to update existing terms, as required by the entity
* metadata wrapper's access check.
*/
protected function checkPropertyAccess($op, $public_field_name, EntityMetadataWrapper $property, EntityMetadataWrapper $wrapper) {
$info = $property->info();
$term = $wrapper->value();
if (!empty($info['name']) && $info['name'] == 'parent' && empty($term->tid) && $op == 'edit') {
return TRUE;
}
return parent::checkPropertyAccess($op, $public_field_name, $property, $wrapper);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment