Coder Social home page Coder Social logo

2.3 bc breaks about di HOT 6 CLOSED

nette avatar nette commented on May 19, 2024
2.3 bc breaks

from di.

Comments (6)

lookyman avatar lookyman commented on May 19, 2024

You should never add any services after loadConfiguration, even if you have to partially configure them later!

http://doc.nette.org/en/2.2/di-extensions#toc-beforecompile

#46 (comment)

from di.

hrach avatar hrach commented on May 19, 2024

@lookyman well, I understand that this is the only way how to get this working now, but it's massive BC break, nowhere mentioned; also the API & the method name is bad, it makes me really unhappy to create service definitions in method named loadConfiguration.

There are two possibilities:

  1. Make it (somehow) backward compatible.
  2. Let this be, and disallow adding new services in beforeCompile time, to fail asap.

But, to be honest, the motivation to call prepareClassList() (added after my feature request), is exactly the possibility to add services dynamicly in beforeCompile time. Otherwise, I don't see much added value.

from di.

xificurk avatar xificurk commented on May 19, 2024

it's massive BC break, nowhere mentioned

http://doc.nette.org/en/2.2/di-extensions#toc-beforecompile

In beforeCompile phase we should not add any more services, however you can modify already existing ones or add relations between services (for example using tags).

You're doin' it wrong ;-)

from di.

dg avatar dg commented on May 19, 2024

it makes me really unhappy to create service definitions in method named loadConfiguration.

Service definitions are configuration of DIC. So it was meant as "load your configuration into container builder", not "load configuration from some file or whatever".

from di.

enumag avatar enumag commented on May 19, 2024

@hrach There is actually much more added value by the early preparedClassList. Mainly Kdyby/Events don't work well without it and now we can use $builder->getByType() in beforeCompile which allows you to not relly on service names of other extensions. There were some other cases where it helped me which I no longer remember.

from di.

hrach avatar hrach commented on May 19, 2024

@dg Thanks! What about deprecating adding new service in beforeCompile()?

from di.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.