Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Config] Add ConfigurableArrayLoader #21070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

[Config] Add ConfigurableArrayLoader #21070

wants to merge 1 commit into from

Conversation

ro0NL
Copy link
Contributor

@ro0NL ro0NL commented Dec 27, 2016

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes/no
Fixed tickets #...
License MIT
Doc PR symfony/symfony-docs#...

Tiny snippet, that bridges Config\Definition with Config\Loader, by providing a convenient base class ConfigurableArrayLoader to users (comparable to the current ConfigurableExtension).

Would be nice if we considered renaming FileLoaderLoadException to LoaderLoadException (or given the package context just LoadException perhaps), to be semantically correct here.

@nicolas-grekas
Copy link
Member

What's the use case?

@ro0NL
Copy link
Contributor Author

ro0NL commented Dec 28, 2016

Bridging :) without bothering users about implementation details, allowing to write loaders simpply and focus on business value;

class MyBaseLoader extends ConfigurableArrayLoader {
    protected $target;
    public function __construct(Domain $target) {
        parent::__construct(new BusinessConfiguration());
        $this->target = $target;
    }
}

class MySpecialJsonLoader extends MyBaseLoader {
    public function load($file) {
       return parent::load(json_decode(file_get_contents($file));
    }

    protected function loadConfiguration(array $config) {
       $this->target->setBusiness($config['business']);
    }
}

@nicolas-grekas
Copy link
Member

But users don't write loaders, that's not a business responsibility...

@ro0NL
Copy link
Contributor Author

ro0NL commented Dec 28, 2016

True, but it depends how the user relies on SF\Config, it may not be using DI loaders etc.

@ro0NL
Copy link
Contributor Author

ro0NL commented Dec 28, 2016

Anyway, ill have no strong use case myself now. Just trying to make lib code more robust and easier to understand/implement.

@nicolas-grekas
Copy link
Member

Adding more code is not going to make it easier to understand IMHO...

@ro0NL
Copy link
Contributor Author

ro0NL commented Dec 28, 2016

Agree, not per see. Just saying (from a component pov) i could appreciate having this kind of self-bridging classes, doing things once; exposing patterns; exposing business value.

@fabpot
Copy link
Member

fabpot commented Dec 28, 2016

I agree with @nicolas-grekas. We never add a feature without a real-world use case. So, I'm closing this PR for now.

@fabpot fabpot closed this Dec 28, 2016
@ro0NL ro0NL deleted the config/array-loader branch December 31, 2016 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants