Giter Site home page Giter Site logo

Comments (4)

simensen avatar simensen commented on July 19, 2024

Silex allows this but it looks like it does not pass the values to the constructor. Instead it processes them manually. I imagine this is because Silex sets up some default services and if parent::__construct($values) was used the Silex added services would always override the user contributed services and properties.

https://github.com/fabpot/Silex/blob/master/src/Silex/Application.php#L147-L149

I would recommend we do something similar. Allow for passing the $values array but process them ourselves at the bottom of the constructor instead of passing them to parent::__construct.

/cc @pulse00

from cilex.

pulse00 avatar pulse00 commented on July 19, 2024

I like the way Silex handles the initialization of services,

  1. They initialize the DIC with defaults
  2. They allow user to pass in initial services to Pimple
  3. The passed services will override any default services.

I think Cilex should follow this pattern, by simply adding the defaults values array to the constructor and initializing the DIC using the constructor argument after all the defaults have been set.

This would not introduce any BC breaks.

from cilex.

simensen avatar simensen commented on July 19, 2024

Yep. To clarify, I think this is what we are talking about:

public function __construct($name, $version = null, array $values = array())
{
    parent::__construct();
    $consoleConfig = array('console.name' => $name);
    if (null !== $version) {
        $consoleConfig['console.version'] = $version;
    }
    $this->register(new ConsoleServiceProvider(), $consoleConfig);
    foreach ($values as $key => $value) {
        $this[$key] = $value;
    }
}

from cilex.

mvriel avatar mvriel commented on July 19, 2024

Fixed in master at commit c6ebee2

from cilex.

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.