Skip to content

Commit 318f2b1

Browse files
committed
Initial commit
0 parents  commit 318f2b1

File tree

10 files changed

+118
-0
lines changed

10 files changed

+118
-0
lines changed

Controller/DefaultController.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Ymc\HowToServiceContainerBundle\Controller;
4+
5+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6+
7+
class DefaultController extends Controller
8+
{
9+
public function indexAction($name)
10+
{
11+
return $this->render('YmcHowToServiceContainerBundle:Default:index.html.twig', array('name' => $name));
12+
}
13+
}

DependencyInjection/Configuration.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Ymc\HowToServiceContainerBundle\DependencyInjection;
4+
5+
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6+
use Symfony\Component\Config\Definition\ConfigurationInterface;
7+
8+
/**
9+
* This is the class that validates and merges configuration from your app/config files
10+
*
11+
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
12+
*/
13+
class Configuration implements ConfigurationInterface
14+
{
15+
/**
16+
* {@inheritDoc}
17+
*/
18+
public function getConfigTreeBuilder()
19+
{
20+
$treeBuilder = new TreeBuilder();
21+
$rootNode = $treeBuilder->root('ymc_how_to_service_container');
22+
23+
// Here you should define the parameters that are allowed to
24+
// configure your bundle. See the documentation linked above for
25+
// more information on that topic.
26+
27+
return $treeBuilder;
28+
}
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Ymc\HowToServiceContainerBundle\DependencyInjection;
4+
5+
use Symfony\Component\DependencyInjection\ContainerBuilder;
6+
use Symfony\Component\Config\FileLocator;
7+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
8+
use Symfony\Component\DependencyInjection\Loader;
9+
10+
/**
11+
* This is the class that loads and manages your bundle configuration
12+
*
13+
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
14+
*/
15+
class YmcHowToServiceContainerExtension extends Extension
16+
{
17+
/**
18+
* {@inheritDoc}
19+
*/
20+
public function load(array $configs, ContainerBuilder $container)
21+
{
22+
$configuration = new Configuration();
23+
$config = $this->processConfiguration($configuration, $configs);
24+
25+
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
26+
$loader->load('services.yml');
27+
}
28+
}

Resources/config/routing.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ymc_how_to_service_container_homepage:
2+
pattern: /hello/{name}
3+
defaults: { _controller: YmcHowToServiceContainerBundle:Default:index }

Resources/config/services.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
# ymc_how_to_service_container.example.class: Ymc\HowToServiceContainerBundle\Example
3+
4+
services:
5+
# ymc_how_to_service_container.example:
6+
# class: %ymc_how_to_service_container.example.class%
7+
# arguments: [@service_id, "plain_value", %parameter%]

Resources/doc/index.rst

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0"?>
2+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3+
<file source-language="en" datatype="plaintext" original="file.ext">
4+
<body>
5+
<trans-unit id="1">
6+
<source>Symfony2 is great</source>
7+
<target>J'aime Symfony2</target>
8+
</trans-unit>
9+
</body>
10+
</file>
11+
</xliff>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello {{ name }}!
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Ymc\HowToServiceContainerBundle\Tests\Controller;
4+
5+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6+
7+
class DefaultControllerTest extends WebTestCase
8+
{
9+
public function testIndex()
10+
{
11+
$client = static::createClient();
12+
13+
$crawler = $client->request('GET', '/hello/Fabien');
14+
15+
$this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0);
16+
}
17+
}

YmcHowToServiceContainerBundle.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Ymc\HowToServiceContainerBundle;
4+
5+
use Symfony\Component\HttpKernel\Bundle\Bundle;
6+
7+
class YmcHowToServiceContainerBundle extends Bundle
8+
{
9+
}

0 commit comments

Comments
 (0)