GithubHelp home page GithubHelp logo

Comments (3)

mnapoli avatar mnapoli commented on June 6, 2024

I see what you mean, but just to be clear this is the small BC-break introduced in 3.2 right? (https://github.com/mnapoli/PHP-DI/releases/tag/3.2.0)

It's a shame the constructor calls init, and not the dispatcher.

+1

Another option is to override the init and include an InjectOn call against itself so that the dependencies are there. This would get you away from a custom dispatcher being required. The drawback is you have to get a handle to the DI container in your init call. If you instantiate the DIcontainer in a bootstrap file it's ugly to pass it down, so it may be better to instantiate it in the init itself.

Seems like the best option to me, given also that it's probably how it will end up for ZF2 integration.

What could be possible is offering 2 options:

  • keep using the provided Dispatcher (best solution), but dependencies are not injected in init()
  • use a base controller class (to be provided by this library) that fetches the dependencies in the constructor if dependencies are needed in init()

from zf1-bridge.

drdamour avatar drdamour commented on June 6, 2024

yes, sorry it was 3.2, guess we were on 3.1 before.

from zf1-bridge.

drdamour avatar drdamour commented on June 6, 2024

FYI: i found that moving the logic to preDispatch was the way to go. Especially once i learned that you can use _forward in preDispatch. We had so much ugly code to catch and respond with errors in Init that is now being forwarded to the appropriate error controller instead!

from zf1-bridge.

Related Issues (10)

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.