Git Product home page Git Product logo

Comments (13)

f3l1x avatar f3l1x commented on May 14, 2024

Hi @MartinMystikJonas. Why do you need that functionality? I mean, command can be autowired via constructor and it's lazily created.

from console.

MartinMystikJonas avatar MartinMystikJonas commented on May 14, 2024

Parent class Command constructor already uses some parameters so I preffer not to mess up with that in my code to avoid incompatibilities. Imho injects are better solution here and I would prefer them over overiding constructor. So I think this could be an useful option.

from console.

MartinMystikJonas avatar MartinMystikJonas commented on May 14, 2024

Or maybe just give us option to choose CommandLoader class via config. Currently it is not easy to use different loader by just redefining service because of command map parameter.

from console.

JanTvrdik avatar JanTvrdik commented on May 14, 2024

Parent class Command constructor already uses some parameters so I preffer not to mess up with that in my code to avoid incompatibilities

That's nonsence. Just call the parent constructor with no arguments and specify command in $defaultName property.
https://symfony.com/doc/current/console/commands_as_services.html#lazy-loading

from console.

MartinMystikJonas avatar MartinMystikJonas commented on May 14, 2024

Ok. So I can be sure that redefining constructor signature will be ok. Fine.

Yet maybe support for custom command loader could be useful sometimes.

from console.

f3l1x avatar f3l1x commented on May 14, 2024

I am ok to support other command loader, but I can't imagine any other, can you prepare PR with your idea?

from console.

MartinMystikJonas avatar MartinMystikJonas commented on May 14, 2024

I will

from console.

MartinMystikJonas avatar MartinMystikJonas commented on May 14, 2024

I started working on it and I have few questions about what approach select:

  1. Would you preffer separate config value
lazy: true
commandLoader: \Custom\MyCommandLoader

or allow lazy option to pass class (false = not lazy, true = default loader, class = use specific loader)

lazy: \Custom\MyCommandLoader
  1. I am thinking of making commandMap as a service so it can be easily autowired to any command loader instead of fixed loader constructor signature. Either service with getCommandMap() : array or service directly implementing \ArrayAccess. Do you agree? Which version do you preffer?

from console.

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.