sonata-project / dev-kit

Development kit of the Sonata-Project
https://master-7rqtwti-ptm4dx6rjpjko.eu-5.platformsh.site/
42 stars 42 forks source link

[RFC] Create SonataContract repository with all interface, exception and some abstract class #658

Closed VincentLanglet closed 3 years ago

VincentLanglet commented 4 years ago

Symfony create https://github.com/symfony/contracts

I think we should do something similar.

IMHO, the SonataDoctrineORMBundle shouldn't require the SonataAdminBundle or SonataExporterBundle but only a SonataContract because it only use the Interface and some BaseThings abstract classes.

This would maybe also help to avoid having the same classes in SonataDatagridBundle and SonataAdminBundle.

WDYT @sonata-project/contributors ?

greg0ire commented 4 years ago

What good will it do exactly, not to have to require the admin bundle or the exporter?

VincentLanglet commented 4 years ago

What good will it do exactly, not to have to require the admin bundle or the exporter?

For example, if the sonata-project/exporter is not a requirement, someone could develop his own exporter. Actually it makes less sens to do it, since you still need to download the sonata-project/exporter.

And I mainly had this idea when I discovered the SonataDatagridBundle. Actually, the adminBundle requires the coreBundle which requires the datagridBundle. Almost all this classes have been duplicated in both adminBundle and datagridBundle. Do you know the reason ?

The same way we could have both the adminBundle and the datagridBundle to require SonataContract in order to avoid the duplicates. Then you could either install the adminBundle and datagridBundle or just install the adminBundle and implements your own datagridBundle.

greg0ire commented 4 years ago

Do you know the reason ?

Maybe someone planned to deprecate one in favor of the other? I'd have a look at the git history if I were you, but I think the datagrid bundle is probably more recent than the admin bundle.

I think this might be a good idea, not sure if we can really have base classes in something called contracts though.

VincentLanglet commented 4 years ago

I think this might be a good idea, not sure if we can really have base classes in something called contracts though.

Yeah, I'm not sure either for the base classes.

I was thinking that if someone wanted to use the BaseFieldDescription, BaseManager, BasePager, etc... to help the implementation of the Interface, he would prefer avoid to install the whole bundle with the sonata implementation. Maybe others repository would be needed, but we can just start with one repository with Interfaces and Exceptions.

A question would be, should we try doing this for the 4.0 (does it help ?), or wait for the 5.0 release.

VincentLanglet commented 4 years ago

Maybe someone planned to deprecate one in favor of the other? I'd have a look at the git history if I were you, but I think the datagrid bundle is probably more recent than the admin bundle.

I found my answer here: https://github.com/sonata-project/SonataDatagridBundle/issues/19#issuecomment-219032393

@greg0ire I'd like to try a POC for Sonata contracts. How does it work to create a new repository ? Should the team vote about this idea ?

phansys commented 4 years ago

In order to create a PoC, I guess you could use your own VCS repository: https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository Then, if the proposal is accepted, the new repository could be created under sonata-project organization.