Comments (15)
No, you still can define a good old DependencyInjection/AppExtension
class that would be loaded instead of the default one.
Then, in this custom extension class, instanciate your Configuration class where you configure your TreeBuilder.
The process I described is just good old symfony stuff.
But there would indeed be a possiblity to make stuff easier by defining a getConfigTreeBuilder
method in the App bundle, and then call:
$config = (new Processor)->process($this->getConfigTreeBuilder()->buildTree(), $configs);
in the default knpRad extension.
from knpradbundle.
Then, your bundle class may do too much stuff, for what it should not be aware of.
from knpradbundle.
let me do a POC / EDIT: I don't see the use case
from knpradbundle.
BTW, what's the purpose to create a semantic config (using TreeBuilder) if you do not override the Extension class?
You have no other access to it but in the extension class.
from knpradbundle.
if you want to add DI parameters, just use parameters in app/config:
parameters:
app.config:
enabled: true
test: false
relates to #77
from knpradbundle.
Yeah sorry. We can defined a good old DependencyInjection\AppExtension
this is corect but i think it's interesting to simplify the different steps. Anyway, i agree with the "Too much stuff".
My first intention has been to create an AbstractConfigurationExtension
object that would contains the buildTree
and buildContainer
shortcuts. The user have to respect this abstract class into the DependencyInjection/ConfigurationExtension
(maybe ...) and us, we load this stuff in the current KnpRadExtension.
Concretly my intention is to provide a simple way to add TreeBuilding configuration stuff for application that need maybe a lot of configuration. the config:dump-reference
command is very interesting and powerfull ! And configuration still always well formated (and documented). I think it's a realy good practice that need to be simplify in the RadBundle ? Don't you ?
from knpradbundle.
ok to have a simple approach for defining semantig config and be able to dump it from console! :)
But the problem is, what to do then with this config ? put it rawly in the DI parameters?
from knpradbundle.
By default the method implemented in the base rad bundle should work this way.
from knpradbundle.
And anyway, the bundle class is empty, so using it to define "configuration of the bundle" seems interesting i guess ?
from knpradbundle.
yes indeed!
from knpradbundle.
Another point @davidjegat: by making the RadExtension
inherit from ConfigurableExtension
, we should be able to just add a class named DependencyInjection/Configuration
and it would be automatically loaded. I'm testing right now.
from knpradbundle.
hey, here is an example of how to do it without modifying anything:
<?php
namespace App;
use Knp\RadBundle\AppBundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
class App extends Bundle implements ExtensionInterface, ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$tree = new TreeBuilder;
$rootNode = $tree
->root('app')
->children()
->scalarNode('test')
->end()
->end();
return $tree;
}
public function load(array $config, ContainerBuilder $container)
{
$extension = new ContainerExtension($this->getPath());
$extension->load($config, $container);
// do more stuff
}
public function getAlias()
{
return 'app';
}
public function getContainerExtension()
{
return $this->extension = $this;
}
public function getConfiguration(array $configs, ContainerBuilder $container)
{
return $this;
}
public function getXsdValidationBasePath()
{
return false;
}
public function getNamespace()
{
return 'http://example.org/schema/dic/'.$this->getAlias();
}
}
from knpradbundle.
another possiblity would be to make the App bundle only implements ConfigurationInterface
.
Then modify the getConfiguration
method to:
public function getConfiguration()
{
if (null !== $config = parent::getConfiguration()) {
return $config;
}
if ($this->bundle instanceof ConfigurationInterface) {
return $this->bundle;
}
}
Then, you just have to implements getConfigTreeBuilder method, but again, then what to do with semantic $config.
from knpradbundle.
did you mean to close the ticket?
from knpradbundle.
yes. It has been implemented by #89.
from knpradbundle.
Related Issues (20)
- ServiceCircularReferenceException HOT 8
- Docs fix: addParameter should be setParameter HOT 1
- Auto registration Twig extensions with arguments HOT 2
- Two Symfony version dependency
- Rewriting Behat tests HOT 16
- We need a new stable release HOT 8
- Impossible to use as "dev-master" dependency HOT 3
- Support for Auto-Registering Event Subscribers HOT 3
- array syntax used on rad.knplabs.com cannot be used with minimum rad-edition requirements HOT 1
- [RFC] it could load every yml file present in config/services folder HOT 6
- rename jquery-ujs. HOT 6
- add copyright headers on all files HOT 4
- twitter bootstrap 3? HOT 3
- createAccessDeniedException() must be public HOT 6
- The "flashes" twig tag should have access to parent scope variables HOT 2
- split KnpRadBundle into smaller components HOT 11
- port Metawidget to Symfony
- Symfony 2.7 support HOT 8
- Caching option for better performance
- Bundle is outdated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from knpradbundle.