Skip to content
Browse files

add model bundle

  • Loading branch information...
1 parent cd61749 commit 6737863e5ae108f702ca523d7e85ceba6ee17b6c Florian Pondepeyre committed Mar 7, 2013
View
1 app/AppKernel.php
@@ -21,6 +21,7 @@ public function registerBundles()
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new Propel\PropelBundle\PropelBundle(),
new Gr\BackendBundle\GrBackendBundle(),
+ new Gr\ModelBundle\GrModelBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
View
4 app/config/routing.yml
@@ -1,3 +1,7 @@
+gr_model:
+ resource: "@GrModelBundle/Resources/config/routing.yml"
+ prefix: /
+
gr_backend:
resource: "@GrBackendBundle/Resources/config/routing.yml"
prefix: /
View
2 app/propel/sql/sqldb.map
@@ -0,0 +1,2 @@
+# Sqlfile -> Database map
+default.sql=default
View
13 src/Gr/ModelBundle/Controller/DefaultController.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace Gr\ModelBundle\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+
+class DefaultController extends Controller
+{
+ public function indexAction($name)
+ {
+ return $this->render('GrModelBundle:Default:index.html.twig', array('name' => $name));
+ }
+}
View
28 src/Gr/ModelBundle/DependencyInjection/Configuration.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Gr\ModelBundle\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('gr_model');
+
+ // 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;
+ }
+}
View
28 src/Gr/ModelBundle/DependencyInjection/GrModelExtension.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Gr\ModelBundle\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 GrModelExtension 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');
+ }
+}
View
9 src/Gr/ModelBundle/GrModelBundle.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Gr\ModelBundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+class GrModelBundle extends Bundle
+{
+}
View
0 src/Gr/ModelBundle/Model/.gitkeep
No changes.
View
3 src/Gr/ModelBundle/Resources/config/routing.yml
@@ -0,0 +1,3 @@
+gr_model_homepage:
+ pattern: /hello/{name}
+ defaults: { _controller: GrModelBundle:Default:index }
View
4 src/Gr/ModelBundle/Resources/config/schema.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<database name="default" namespace="Gr\ModelBundle\Model" defaultIdMethod="native">
+
+</database>
View
7 src/Gr/ModelBundle/Resources/config/services.yml
@@ -0,0 +1,7 @@
+parameters:
+# gr_model.example.class: Gr\ModelBundle\Example
+
+services:
+# gr_model.example:
+# class: %gr_model.example.class%
+# arguments: [@service_id, "plain_value", %parameter%]
View
0 src/Gr/ModelBundle/Resources/doc/index.rst
No changes.
View
11 src/Gr/ModelBundle/Resources/translations/messages.fr.xlf
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file source-language="en" datatype="plaintext" original="file.ext">
+ <body>
+ <trans-unit id="1">
+ <source>Symfony2 is great</source>
+ <target>J'aime Symfony2</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
View
1 src/Gr/ModelBundle/Resources/views/Default/index.html.twig
@@ -0,0 +1 @@
+Hello {{ name }}!
View
17 src/Gr/ModelBundle/Tests/Controller/DefaultControllerTest.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace Gr\ModelBundle\Tests\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
+
+class DefaultControllerTest extends WebTestCase
+{
+ public function testIndex()
+ {
+ $client = static::createClient();
+
+ $crawler = $client->request('GET', '/hello/Fabien');
+
+ $this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0);
+ }
+}

0 comments on commit 6737863

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