EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

FieldDto should be aware about EntityDto to which it is applied.

Open oleg-andreyev opened this issue 1 year ago • 0 comments

Short description of what this feature will allow to do: It would be great if FieldDto would be aware about EntityDto

    public function processFieldsForAll(EntityCollection $entities, FieldCollection $fields): void
    {
        foreach ($entities as $entity) {
            $this->processFields($entity, clone $fields);
            $entities->set($entity);
        }
    }

EA already doing clone of FieldCollection, so it's a unique set per entity

Example of how to use this feature I'm working on integrating https://github.com/symfony/acl-bundle into my project and want to deny/allow accesses based on ACL object.

In order to do I need to implement custom ObjectIdentityRetrievalStrategy (acl class) to retrieve "real entity" and not DTO.

class EasyAdminObjectIdentityRetrievalStrategy extends ObjectIdentityRetrievalStrategy
{
    public function getObjectIdentity($domainObject)
    {
        if ($domainObject instanceof EntityDto && $domainObject->getInstance() !== null) {
            return parent::getObjectIdentity($domainObject->getInstance());
        } elseif ($domainObject instanceof FieldDto && $domainObject->get) {

        }

        return parent::getObjectIdentity($domainObject);
    }
}

but FieldDto does not have such any association with EntityDto or entity itself.

oleg-andreyev avatar Nov 06 '23 16:11 oleg-andreyev