EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Better default labels

Open tacman opened this issue 4 months ago • 1 comments

Most of my dashboard menu items pointing to a class don't need me to specify the label

    yield MenuItem::linkToCrud('Thumbs', 'gg:image', Thumb::class);

An easy default would be the short class name of the entity class, e.g. "Thumb".

Alternatively, it could be something that points to a translation message.

In version 5, perhaps the fields could be re-ordered, since the entity class is required but the label could have a better default and the icon could be optional.

tacman avatar Aug 05 '25 11:08 tacman

IMHO a good a idea to provide a default.

But I think reordering the arguments is not possible without rather big effort. I think the method EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem::linkToCrud() would have to be deprecated in v4 and replaced by a new method in v5. Otherwise it will just break everybodys code on an upgrade to v5. I see no way of triggering a deprecation inside the current method so I guess the whole method would have to be deprecated.

A simpler solution would be just allow passing NULL for the $label:

    public static function linkToCrud(TranslatableInterface|string|null $label, ?string $icon, string $entityFqcn): CrudMenuItem
    {
        // ...calculate default label...

        return new CrudMenuItem($label, $icon, $entityFqcn);
    }

michaelKaefer avatar Oct 06 '25 09:10 michaelKaefer