Skip to content

Commit

Permalink
Generated a Symfony2 default bundle.
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Hillerström committed Jun 7, 2012
1 parent d7dcd3d commit 81e5b71
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Controller/DefaultController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Xi\Bundle\BreadcrumbsBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;


class DefaultController extends Controller
{

public function indexAction($name)
{
return $this->render('XiBreadcrumbsBundle:Default:index.html.twig', array('name' => $name));
}
}
29 changes: 29 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Xi\Bundle\BreadcrumbsBundle\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('xi_breadcrumbs');

// 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 changes: 28 additions & 0 deletions DependencyInjection/XiBreadcrumbsExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Xi\Bundle\BreadcrumbsBundle\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 XiBreadcrumbsExtension 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');
}
}
3 changes: 3 additions & 0 deletions Resources/config/routing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
XiBreadcrumbsBundle_homepage:
pattern: /hello/{name}
defaults: { _controller: XiBreadcrumbsBundle:Default:index }
7 changes: 7 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
# xi_breadcrumbs.example.class: Xi\Bundle\BreadcrumbsBundle\Example

services:
# xi_breadcrumbs.example:
# class: %xi_breadcrumbs.example.class%
# arguments: [@service_id, "plain_value", %parameter%]
1 change: 1 addition & 0 deletions Resources/views/Default/index.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello {{ name }}!
17 changes: 17 additions & 0 deletions Tests/Controller/DefaultControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Xi\Bundle\BreadcrumbsBundle\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);
}
}
9 changes: 9 additions & 0 deletions XiBreadcrumbsBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Xi\Bundle\BreadcrumbsBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class XiBreadcrumbsBundle extends Bundle
{
}

0 comments on commit 81e5b71

Please sign in to comment.