Skip to content
Browse files

Hide App bundle and extension classes

  • Loading branch information...
0 parents commit abbafe113c65bad4852e5939c71a05e2bc1c0a1b @everzet everzet committed Oct 29, 2012
35 AppBundle/Bundle.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Knp\RadBundle\AppBundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle as BaseBundle;
+
+class Bundle extends BaseBundle
+{
+ private $path;
+
+ public function __construct($path, $name = 'App')
+ {
+ $this->path = $path;
+ $this->name = $name;
+ }
+
+ public function getPath()
+ {
+ return $this->path;
+ }
+
+ public function getNamespace()
+ {
+ return $this->name;
+ }
+
+ public function getContainerExtension()
+ {
+ if ($extension = parent::getContainerExtension()) {
+ return $extension;
+ }
+
+ return $this->extension = new ContainerExtension($this->path);
+ }
+}
43 AppBundle/ContainerExtension.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Knp\RadBundle\AppBundle;
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+use Symfony\Component\DependencyInjection\Loader;
+
+class ContainerExtension extends Extension
+{
+ private $path;
+
+ public function __construct($path)
+ {
+ $this->path = $path;
+ }
+
+ public function getAlias()
+ {
+ return 'app';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function load(array $configs, ContainerBuilder $container)
+ {
+ if (file_exists($this->path.'/Resources/config/services.yml')) {
+ $loader = new Loader\YamlFileLoader(
+ $container, new FileLocator($this->path.'/Resources/config')
+ );
+ $loader->load('services.yml');
+ }
+
+ if (file_exists($this->path.'/Resources/config/services.xml')) {
+ $loader = new Loader\XmlFileLoader(
+ $container, new FileLocator($this->path.'/Resources/config')
+ );
+ $loader->load('services.xml');
+ }
+ }
+}
13 Controller/DefaultController.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace Knp\RadBundle\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+
+class DefaultController extends Controller
+{
+ public function indexAction($name)
+ {
+ return $this->render('KnpRadBundle:Default:index.html.twig', array('name' => $name));
+ }
+}
29 DependencyInjection/Configuration.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Knp\RadBundle\DependencyInjection;
+
+use Symfony\Component\Config\Definition\Builder\TreeBuilder;
+use Symfony\Component\Config\Definition\ConfigurationInterface;
+
+/**
+ * This is the class that validates and merges configuration from your app/config files
+ *
+ * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
+ */
+class Configuration implements ConfigurationInterface
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function getConfigTreeBuilder()
+ {
+ $treeBuilder = new TreeBuilder();
+ $rootNode = $treeBuilder->root('knp_rad');
+
+ // Here you should define the parameters that are allowed to
+ // configure your bundle. See the documentation linked above for
+ // more information on that topic.
+
+ return $treeBuilder;
+ }
+}
28 DependencyInjection/KnpRadExtension.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Knp\RadBundle\DependencyInjection;
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+use Symfony\Component\DependencyInjection\Loader;
+
+/**
+ * This is the class that loads and manages your bundle configuration
+ *
+ * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
+ */
+class KnpRadExtension extends Extension
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function load(array $configs, ContainerBuilder $container)
+ {
+ $configuration = new Configuration();
+ $config = $this->processConfiguration($configuration, $configs);
+
+ $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+ $loader->load('services.yml');
+ }
+}
9 KnpRadBundle.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Knp\RadBundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+class KnpRadBundle extends Bundle
+{
+}
7 Resources/config/services.yml
@@ -0,0 +1,7 @@
+parameters:
+# knp_rad.example.class: Knp\RadBundle\Example
+
+services:
+# knp_rad.example:
+# class: %knp_rad.example.class%
+# arguments: [@service_id, "plain_value", %parameter%]
1 Resources/views/Default/index.html.twig
@@ -0,0 +1 @@
+Hello {{ name }}!

0 comments on commit abbafe1

Please sign in to comment.
Something went wrong with that request. Please try again.