Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Asibona is working on porting field permissions to Drupal 8. He has this to say about field collection integration:
I'm trying to porting field_permission module to drupal 8.
(Road Map -> https://www.drupal.org/node/2196303)
I realized this feature is lacking [getOwnerId()], do I have to do a special check to field_collection or can you implement this
/**
* Get entity Author id.
*/
public function getOwnerId() {
return $this->getHost()->getOwnerId();
}
in FieldCollectionItem.php
Comment | File | Size | Author |
---|---|---|---|
#10 | interdiff-2734551-4-10.txt | 2.9 KB | manuel.adan |
#10 | field_collection-entity-owner-interface-2734551-10.patch | 2.64 KB | manuel.adan |
| |||
#4 | field_collection-getOwnerId.2734551.patch | 1.08 KB | asibona |
|
Comments
Comment #2
jmuzz CreditAttribution: jmuzz commentedThe problem with field permissions and field collections in Drupal 7 was that field collections do not intrinsically have an owner. They won't necessarily be in an entity that has an owner either, as they could be nested in another field collection item or a taxonomy term or another ownerless entity.
There was no unified way to deal with entity ownership in Drupal 7, but it looks like this has been improved by a getOwnerId() function in Drupal 8 and it may be worth implementing as suggested.
Comment #3
asibona CreditAttribution: asibona commentedThank you, for the moment I implemented the control directly in field_permission form.
good day.
Ale
Comment #4
asibona CreditAttribution: asibona commentedHI @jmuzz :)
This solves all the problems and it works for nodes users and the internal fields of the field collection.
:D
Comment #5
asibona CreditAttribution: asibona commentedComment #6
asibona CreditAttribution: asibona commentedComment #7
asibona CreditAttribution: asibona commentedComment #8
jmuzz CreditAttribution: jmuzz commentedI like this idea. If we're going to implement this method though the field collection item entities should be declared to implement the EntityOwnerInterface like the other objects that have the method. The "set" functions can throw an exception.
Instead of checking the host for the existence of the function it should check whether the host implements the interface. I'd recommend the same for the changes being made in field_permission.
Comment #9
jmuzz CreditAttribution: jmuzz commentedDevelopment is moving to 8.x-3.x.
Comment #10
manuel.adanAs @jmuzz suggested, FieldCollectionItem now implements the EntityOwnerInterface. Exception thrown on setters. It makes field permission module work well with fields on field collections items.
Comment #11
ram4nd CreditAttribution: ram4nd as a volunteer commented