Browse files

Remove AcmeDemoBundle and add GrBackendBundle

  • Loading branch information...
1 parent 519b027 commit d0e9bee0d659fa63a03f077a3aca8756fd036614 Florian Pondepeyre committed Mar 7, 2013
Showing with 121 additions and 671 deletions.
  1. +1 −1 app/AppKernel.php
  2. +3 −0 app/config/routing.yml
  3. +0 −13 app/config/routing_dev.yml
  4. +0 −9 src/Acme/DemoBundle/AcmeDemoBundle.php
  5. +0 −57 src/Acme/DemoBundle/Controller/DemoController.php
  6. +0 −69 src/Acme/DemoBundle/Controller/SecuredController.php
  7. +0 −19 src/Acme/DemoBundle/Controller/WelcomeController.php
  8. +0 −22 src/Acme/DemoBundle/DependencyInjection/AcmeDemoExtension.php
  9. +0 −25 src/Acme/DemoBundle/EventListener/ControllerListener.php
  10. +0 −20 src/Acme/DemoBundle/Form/ContactType.php
  11. +0 −18 src/Acme/DemoBundle/Resources/config/services.xml
  12. +0 −101 src/Acme/DemoBundle/Resources/public/css/demo.css
  13. BIN src/Acme/DemoBundle/Resources/public/images/blue-arrow.png
  14. BIN src/Acme/DemoBundle/Resources/public/images/field-background.gif
  15. BIN src/Acme/DemoBundle/Resources/public/images/logo.gif
  16. BIN src/Acme/DemoBundle/Resources/public/images/search.png
  17. BIN src/Acme/DemoBundle/Resources/public/images/welcome-configure.gif
  18. BIN src/Acme/DemoBundle/Resources/public/images/welcome-demo.gif
  19. BIN src/Acme/DemoBundle/Resources/public/images/welcome-quick-tour.gif
  20. +0 −15 src/Acme/DemoBundle/Resources/views/Demo/contact.html.twig
  21. +0 −9 src/Acme/DemoBundle/Resources/views/Demo/hello.html.twig
  22. +0 −14 src/Acme/DemoBundle/Resources/views/Demo/index.html.twig
  23. +0 −11 src/Acme/DemoBundle/Resources/views/Secured/hello.html.twig
  24. +0 −9 src/Acme/DemoBundle/Resources/views/Secured/helloadmin.html.twig
  25. +0 −6 src/Acme/DemoBundle/Resources/views/Secured/layout.html.twig
  26. +0 −35 src/Acme/DemoBundle/Resources/views/Secured/login.html.twig
  27. +0 −83 src/Acme/DemoBundle/Resources/views/Welcome/index.html.twig
  28. +0 −37 src/Acme/DemoBundle/Resources/views/layout.html.twig
  29. +0 −17 src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php
  30. +0 −81 src/Acme/DemoBundle/Twig/Extension/DemoExtension.php
  31. +13 −0 src/Gr/BackendBundle/Controller/DefaultController.php
  32. +28 −0 src/Gr/BackendBundle/DependencyInjection/Configuration.php
  33. +28 −0 src/Gr/BackendBundle/DependencyInjection/GrBackendExtension.php
  34. +9 −0 src/Gr/BackendBundle/GrBackendBundle.php
  35. +3 −0 src/Gr/BackendBundle/Resources/config/routing.yml
  36. +7 −0 src/Gr/BackendBundle/Resources/config/services.yml
  37. 0 src/Gr/BackendBundle/Resources/doc/index.rst
  38. +11 −0 src/Gr/BackendBundle/Resources/translations/messages.fr.xlf
  39. +1 −0 src/Gr/BackendBundle/Resources/views/Default/index.html.twig
  40. +17 −0 src/Gr/BackendBundle/Tests/Controller/DefaultControllerTest.php
View
2 app/AppKernel.php
@@ -19,10 +19,10 @@ public function registerBundles()
new JMS\AopBundle\JMSAopBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
+ new Gr\BackendBundle\GrBackendBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
- $bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
View
3 app/config/routing.yml
@@ -0,0 +1,3 @@
+gr_backend:
+ resource: "@GrBackendBundle/Resources/config/routing.yml"
+ prefix: /
View
13 app/config/routing_dev.yml
@@ -1,16 +1,3 @@
-_welcome:
- pattern: /
- defaults: { _controller: AcmeDemoBundle:Welcome:index }
-
-_demo_secured:
- resource: "@AcmeDemoBundle/Controller/SecuredController.php"
- type: annotation
-
-_demo:
- resource: "@AcmeDemoBundle/Controller/DemoController.php"
- type: annotation
- prefix: /demo
-
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
View
9 src/Acme/DemoBundle/AcmeDemoBundle.php
@@ -1,9 +0,0 @@
-<?php
-
-namespace Acme\DemoBundle;
-
-use Symfony\Component\HttpKernel\Bundle\Bundle;
-
-class AcmeDemoBundle extends Bundle
-{
-}
View
57 src/Acme/DemoBundle/Controller/DemoController.php
@@ -1,57 +0,0 @@
-<?php
-
-namespace Acme\DemoBundle\Controller;
-
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-use Symfony\Component\HttpFoundation\RedirectResponse;
-use Acme\DemoBundle\Form\ContactType;
-
-// these import the "@Route" and "@Template" annotations
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
-
-class DemoController extends Controller
-{
- /**
- * @Route("/", name="_demo")
- * @Template()
- */
- public function indexAction()
- {
- return array();
- }
-
- /**
- * @Route("/hello/{name}", name="_demo_hello")
- * @Template()
- */
- public function helloAction($name)
- {
- return array('name' => $name);
- }
-
- /**
- * @Route("/contact", name="_demo_contact")
- * @Template()
- */
- public function contactAction()
- {
- $form = $this->get('form.factory')->create(new ContactType());
-
- $request = $this->get('request');
- if ('POST' == $request->getMethod()) {
- $form->bindRequest($request);
- if ($form->isValid()) {
- $mailer = $this->get('mailer');
- // .. setup a message and send it
- // http://symfony.com/doc/current/cookbook/email.html
-
- $this->get('session')->setFlash('notice', 'Message sent!');
-
- return new RedirectResponse($this->generateUrl('_demo'));
- }
- }
-
- return array('form' => $form->createView());
- }
-}
View
69 src/Acme/DemoBundle/Controller/SecuredController.php
@@ -1,69 +0,0 @@
-<?php
-
-namespace Acme\DemoBundle\Controller;
-
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-use Symfony\Component\Security\Core\SecurityContext;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
-use JMS\SecurityExtraBundle\Annotation\Secure;
-
-/**
- * @Route("/demo/secured")
- */
-class SecuredController extends Controller
-{
- /**
- * @Route("/login", name="_demo_login")
- * @Template()
- */
- public function loginAction()
- {
- if ($this->get('request')->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
- $error = $this->get('request')->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
- } else {
- $error = $this->get('request')->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
- }
-
- return array(
- 'last_username' => $this->get('request')->getSession()->get(SecurityContext::LAST_USERNAME),
- 'error' => $error,
- );
- }
-
- /**
- * @Route("/login_check", name="_security_check")
- */
- public function securityCheckAction()
- {
- // The security layer will intercept this request
- }
-
- /**
- * @Route("/logout", name="_demo_logout")
- */
- public function logoutAction()
- {
- // The security layer will intercept this request
- }
-
- /**
- * @Route("/hello", defaults={"name"="World"}),
- * @Route("/hello/{name}", name="_demo_secured_hello")
- * @Template()
- */
- public function helloAction($name)
- {
- return array('name' => $name);
- }
-
- /**
- * @Route("/hello/admin/{name}", name="_demo_secured_hello_admin")
- * @Secure(roles="ROLE_ADMIN")
- * @Template()
- */
- public function helloadminAction($name)
- {
- return array('name' => $name);
- }
-}
View
19 src/Acme/DemoBundle/Controller/WelcomeController.php
@@ -1,19 +0,0 @@
-<?php
-
-namespace Acme\DemoBundle\Controller;
-
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-
-class WelcomeController extends Controller
-{
- public function indexAction()
- {
- /*
- * The action's view can be rendered using render() method
- * or @Template annotation as demonstrated in DemoController.
- *
- */
-
- return $this->render('AcmeDemoBundle:Welcome:index.html.twig');
- }
-}
View
22 src/Acme/DemoBundle/DependencyInjection/AcmeDemoExtension.php
@@ -1,22 +0,0 @@
-<?php
-
-namespace Acme\DemoBundle\DependencyInjection;
-
-use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
-use Symfony\Component\HttpKernel\DependencyInjection\Extension;
-use Symfony\Component\Config\FileLocator;
-
-class AcmeDemoExtension extends Extension
-{
- public function load(array $configs, ContainerBuilder $container)
- {
- $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
- $loader->load('services.xml');
- }
-
- public function getAlias()
- {
- return 'acme_demo';
- }
-}
View
25 src/Acme/DemoBundle/EventListener/ControllerListener.php
@@ -1,25 +0,0 @@
-<?php
-
-namespace Acme\DemoBundle\EventListener;
-
-use Symfony\Component\EventDispatcher\Event;
-use Symfony\Component\HttpKernel\HttpKernelInterface;
-use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
-use Acme\DemoBundle\Twig\Extension\DemoExtension;
-
-class ControllerListener
-{
- protected $extension;
-
- public function __construct(DemoExtension $extension)
- {
- $this->extension = $extension;
- }
-
- public function onKernelController(FilterControllerEvent $event)
- {
- if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
- $this->extension->setController($event->getController());
- }
- }
-}
View
20 src/Acme/DemoBundle/Form/ContactType.php
@@ -1,20 +0,0 @@
-<?php
-
-namespace Acme\DemoBundle\Form;
-
-use Symfony\Component\Form\AbstractType;
-use Symfony\Component\Form\FormBuilderInterface;
-
-class ContactType extends AbstractType
-{
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- $builder->add('email', 'email');
- $builder->add('message', 'textarea');
- }
-
- public function getName()
- {
- return 'contact';
- }
-}
View
18 src/Acme/DemoBundle/Resources/config/services.xml
@@ -1,18 +0,0 @@
-<?xml version="1.0" ?>
-
-<container xmlns="http://symfony.com/schema/dic/services"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
-
- <services>
- <service id="twig.extension.acme.demo" class="Acme\DemoBundle\Twig\Extension\DemoExtension" public="false">
- <tag name="twig.extension" />
- <argument type="service" id="twig.loader" />
- </service>
-
- <service id="acme.demo.listener" class="Acme\DemoBundle\EventListener\ControllerListener">
- <tag name="kernel.event_listener" event="kernel.controller" method="onKernelController" />
- <argument type="service" id="twig.extension.acme.demo" />
- </service>
- </services>
-</container>
View
101 src/Acme/DemoBundle/Resources/public/css/demo.css
@@ -1,101 +0,0 @@
-body {
- font-size: 14px;
- font-family: "Lucida Sans Unicode", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
-}
-h1.title {
- font-size: 45px;
- padding-bottom: 30px;
-}
-.sf-reset h2 {
- font-weight: bold;
- color: #FFFFFF;
- /* Font is duplicated of body (sans-serif) */
- font-family: "Lucida Sans Unicode", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
-
- margin-bottom: 10px;
- background-color: #aacd4e;
- padding: 2px 4px;
- display: inline-block;
- text-transform: uppercase;
-
-}
-p {
- line-height: 20px;
- padding-bottom: 20px;
-}
-ul#demo-list a {
- background: url(../images/blue-arrow.png) no-repeat right 6px;
- padding-right: 10px;
- margin-right: 30px;
-}
-#symfony-header {
- position: relative;
- padding: 30px 30px 20px 30px;
-}
-.sf-reset .symfony-blocks-welcome {
- overflow: hidden;
-}
-.sf-reset .symfony-blocks-welcome > div {
- background-color: whitesmoke;
- float: left;
- width: 240px;
- margin-right: 14px;
- text-align: center;
- padding: 26px 20px;
-}
-.sf-reset .symfony-blocks-welcome > div.block-demo {
- margin-right: 0;
-}
-.sf-reset .symfony-blocks-welcome .illustration {
- padding-bottom: 20px;
-}
-.sf-reset .symfony-blocks-help {
- overflow: hidden;
-}
-.sf-reset .symfony-blocks-help {
- margin-top: 30px;
- padding: 18px;
- border: 1px solid #E6E6E6;
-}
-.sf-reset .symfony-blocks-help > div {
- width: 254px;
- float: left;
-}
-.flash-message {
- padding: 10px;
- margin: 5px;
- margin-top: 15px;
- background-color: #ffe;
-}
-.sf-reset .error {
- color: red;
-}
-#login label, #contact_form label {
- display: block;
- float: left;
- width: 90px;
-}
-.sf-reset ul#menu {
- float: right;
- margin-bottom: 20px;
- padding-left: 0;
-}
-.sf-reset #menu li {
- padding-left: 0;
- margin-right: 10px;
- display: inline;
-}
-.sf-reset a,
-.sf-reset li a {
- color: #08C;
- text-decoration: none;
-}
-.sf-reset a:hover,
-.sf-reset li a:hover {
- color: #08C;
- text-decoration: underline;
-}
-.sf-reset .symfony-content pre {
- white-space: pre;
- font-family: monospace;
-}
View
BIN src/Acme/DemoBundle/Resources/public/images/blue-arrow.png
Deleted file not rendered
View
BIN src/Acme/DemoBundle/Resources/public/images/field-background.gif
Deleted file not rendered
View
BIN src/Acme/DemoBundle/Resources/public/images/logo.gif
Deleted file not rendered
View
BIN src/Acme/DemoBundle/Resources/public/images/search.png
Deleted file not rendered
View
BIN src/Acme/DemoBundle/Resources/public/images/welcome-configure.gif
Deleted file not rendered
View
BIN src/Acme/DemoBundle/Resources/public/images/welcome-demo.gif
Deleted file not rendered
View
BIN src/Acme/DemoBundle/Resources/public/images/welcome-quick-tour.gif
Deleted file not rendered
View
15 src/Acme/DemoBundle/Resources/views/Demo/contact.html.twig
@@ -1,15 +0,0 @@
-{% extends "AcmeDemoBundle::layout.html.twig" %}
-
-{% block title "Symfony - Contact form" %}
-
-{% block content %}
- <form action="{{ path('_demo_contact') }}" method="POST" id="contact_form">
- {{ form_errors(form) }}
-
- {{ form_row(form.email) }}
- {{ form_row(form.message) }}
-
- {{ form_rest(form) }}
- <input type="submit" value="Send" class="symfony-button-grey" />
- </form>
-{% endblock %}
View
9 src/Acme/DemoBundle/Resources/views/Demo/hello.html.twig
@@ -1,9 +0,0 @@
-{% extends "AcmeDemoBundle::layout.html.twig" %}
-
-{% block title "Hello " ~ name %}
-
-{% block content %}
- <h1>Hello {{ name }}!</h1>
-{% endblock %}
-
-{% set code = code(_self) %}
View
14 src/Acme/DemoBundle/Resources/views/Demo/index.html.twig
@@ -1,14 +0,0 @@
-{% extends "AcmeDemoBundle::layout.html.twig" %}
-
-{% block title "Symfony - Demos" %}
-
-{% block content_header '' %}
-
-{% block content %}
- <h1 class="title">Available demos</h1>
- <ul id="demo-list">
- <li><a href="{{ path('_demo_hello', {'name': 'World'}) }}">Hello World</a></li>
- <li><a href="{{ path('_demo_secured_hello', {'name': 'World'}) }}">Access the secured area</a> <a href="{{ path('_demo_login') }}">Go to the login page</a></li>
- {# <li><a href="{{ path('_demo_contact') }}">Send a Message</a></li> #}
- </ul>
-{% endblock %}
View
11 src/Acme/DemoBundle/Resources/views/Secured/hello.html.twig
@@ -1,11 +0,0 @@
-{% extends "AcmeDemoBundle:Secured:layout.html.twig" %}
-
-{% block title "Hello " ~ name %}
-
-{% block content %}
- <h1 class="title">Hello {{ name }}!</h1>
-
- <a href="{{ path('_demo_secured_hello_admin', { 'name': name }) }}">Hello resource secured for <strong>admin</strong> only.</a>
-{% endblock %}
-
-{% set code = code(_self) %}
View
9 src/Acme/DemoBundle/Resources/views/Secured/helloadmin.html.twig
@@ -1,9 +0,0 @@
-{% extends "AcmeDemoBundle:Secured:layout.html.twig" %}
-
-{% block title "Hello " ~ name %}
-
-{% block content %}
- <h1 class="title">Hello {{ name }} secured for Admins only!</h1>
-{% endblock %}
-
-{% set code = code(_self) %}
View
6 src/Acme/DemoBundle/Resources/views/Secured/layout.html.twig
@@ -1,6 +0,0 @@
-{% extends "AcmeDemoBundle::layout.html.twig" %}
-
-{% block content_header_more %}
- {{ parent() }}
- <li>logged in as <strong>{{ app.user ? app.user.username : 'Anonymous' }}</strong> - <a href="{{ path('_demo_logout') }}">Logout</a></li>
-{% endblock %}
View
35 src/Acme/DemoBundle/Resources/views/Secured/login.html.twig
@@ -1,35 +0,0 @@
-{% extends 'AcmeDemoBundle::layout.html.twig' %}
-
-{% block content %}
- <h1 class="title">Login</h1>
-
- <p>
- Choose between two default users: <em>user/userpass</em> <small>(ROLE_USER)</small> or <em>admin/adminpass</em> <small>(ROLE_ADMIN)</small>
- </p>
-
- {% if error %}
- <div class="error">{{ error.message }}</div>
- {% endif %}
-
- <form action="{{ path("_security_check") }}" method="post" id="login">
- <div>
- <label for="username">Username</label>
- <input type="text" id="username" name="_username" value="{{ last_username }}" />
- </div>
-
- <div>
- <label for="password">Password</label>
- <input type="password" id="password" name="_password" />
- </div>
-
- <button type="submit" class="sf-button">
- <span class="border-l">
- <span class="border-r">
- <span class="btn-bg">Login</span>
- </span>
- </span>
- </button>
- </form>
-{% endblock %}
-
-{% set code = code(_self) %}
View
83 src/Acme/DemoBundle/Resources/views/Welcome/index.html.twig
@@ -1,83 +0,0 @@
-{% extends 'AcmeDemoBundle::layout.html.twig' %}
-
-{% block title %}Symfony - Welcome{% endblock %}
-
-{% block content_header '' %}
-
-{% block content %}
- {% set version = constant('Symfony\\Component\\HttpKernel\\Kernel::MAJOR_VERSION') ~ '.' ~ constant('Symfony\\Component\\HttpKernel\\Kernel::MINOR_VERSION')%}
-
- <h1 class="title">Welcome!</h1>
-
- <p>Congratulations! You have successfully installed a new Symfony application.</p>
-
- <div class="symfony-blocks-welcome">
- <div class="block-quick-tour">
- <div class="illustration">
- <img src="{{ asset('bundles/acmedemo/images/welcome-quick-tour.gif') }}" alt="Quick tour" />
- </div>
- <a href="http://symfony.com/doc/{{ version }}/quick_tour/index.html" class="sf-button sf-button-selected">
- <span class="border-l">
- <span class="border-r">
- <span class="btn-bg">Read the Quick Tour</span>
- </span>
- </span>
- </a>
- </div>
- {% if app.environment == 'dev' %}
- <div class="block-configure">
- <div class="illustration">
- <img src="{{ asset('bundles/acmedemo/images/welcome-configure.gif') }}" alt="Configure your application" />
- </div>
- <a href="{{ path('_configurator_home') }}" class="sf-button sf-button-selected">
- <span class="border-l">
- <span class="border-r">
- <span class="btn-bg">Configure</span>
- </span>
- </span>
- </a>
- </div>
- {% endif %}
- <div class="block-demo">
- <div class="illustration">
- <img src="{{ asset('bundles/acmedemo/images/welcome-demo.gif') }}" alt="Demo" />
- </div>
- <a href="{{ path('_demo') }}" class="sf-button sf-button-selected">
- <span class="border-l">
- <span class="border-r">
- <span class="btn-bg">Run The Demo</span>
- </span>
- </span>
- </a>
- </div>
- </div>
-
- <div class="symfony-blocks-help">
- <div class="block-documentation">
- <ul>
- <li><strong>Documentation</strong></li>
- <li><a href="http://symfony.com/doc/{{ version }}/book/index.html">The Book</a></li>
- <li><a href="http://symfony.com/doc/{{ version }}/cookbook/index.html">The Cookbook</a></li>
- <li><a href="http://symfony.com/doc/{{ version }}/components/index.html">The Components</a></li>
- <li><a href="http://symfony.com/doc/{{ version }}/reference/index.html">Reference</a></li>
- <li><a href="http://symfony.com/doc/{{ version }}/glossary.html">Glossary</a></li>
- </ul>
- </div>
- <div class="block-documentation-more">
- <ul>
- <li><strong>Sensio</strong></li>
- <li><a href="http://trainings.sensiolabs.com">Trainings</a></li>
- <li><a href="http://books.sensiolabs.com">Books</a></li>
- </ul>
- </div>
- <div class="block-community">
- <ul>
- <li><strong>Community</strong></li>
- <li><a href="http://symfony.com/irc">IRC channel</a></li>
- <li><a href="http://symfony.com/mailing-lists">Mailing lists</a></li>
- <li><a href="http://forum.symfony-project.org">Forum</a></li>
- <li><a href="http://symfony.com/doc/{{ version }}/contributing/index.html">Contributing</a></li>
- </ul>
- </div>
- </div>
-{% endblock %}
View
37 src/Acme/DemoBundle/Resources/views/layout.html.twig
@@ -1,37 +0,0 @@
-{% extends "TwigBundle::layout.html.twig" %}
-
-{% block head %}
- <link rel="icon" sizes="16x16" href="{{ asset('favicon.ico') }}" />
- <link rel="stylesheet" href="{{ asset('bundles/acmedemo/css/demo.css') }}" />
-{% endblock %}
-
-{% block title 'Demo Bundle' %}
-
-{% block body %}
- {% for flashMessage in app.session.flashbag.get('notice') %}
- <div class="flash-message">
- <em>Notice</em>: {{ flashMessage }}
- </div>
- {% endfor %}
-
- {% block content_header %}
- <ul id="menu">
- {% block content_header_more %}
- <li><a href="{{ path('_demo') }}">Demo Home</a></li>
- {% endblock %}
- </ul>
-
- <div style="clear: both"></div>
- {% endblock %}
-
- <div class="block">
- {% block content %}{% endblock %}
- </div>
-
- {% if code is defined %}
- <h2>Code behind this page</h2>
- <div class="block">
- <div class="symfony-content">{{ code|raw }}</div>
- </div>
- {% endif %}
-{% endblock %}
View
17 src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php
@@ -1,17 +0,0 @@
-<?php
-
-namespace Acme\DemoBundle\Tests\Controller;
-
-use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
-
-class DemoControllerTest extends WebTestCase
-{
- public function testIndex()
- {
- $client = static::createClient();
-
- $crawler = $client->request('GET', '/demo/hello/Fabien');
-
- $this->assertGreaterThan(0, $crawler->filter('html:contains("Hello Fabien")')->count());
- }
-}
View
81 src/Acme/DemoBundle/Twig/Extension/DemoExtension.php
@@ -1,81 +0,0 @@
-<?php
-
-namespace Acme\DemoBundle\Twig\Extension;
-
-use CG\Core\ClassUtils;
-
-class DemoExtension extends \Twig_Extension
-{
- protected $loader;
- protected $controller;
-
- public function __construct(\Twig_LoaderInterface $loader)
- {
- $this->loader = $loader;
- }
-
- public function setController($controller)
- {
- $this->controller = $controller;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getFunctions()
- {
- return array(
- 'code' => new \Twig_Function_Method($this, 'getCode', array('is_safe' => array('html'))),
- );
- }
-
- public function getCode($template)
- {
- // highlight_string highlights php code only if '<?php' tag is present.
- $controller = highlight_string("<?php" . $this->getControllerCode(), true);
- $controller = str_replace('<span style="color: #0000BB">&lt;?php&nbsp;&nbsp;&nbsp;&nbsp;</span>', '&nbsp;&nbsp;&nbsp;&nbsp;', $controller);
-
- $template = htmlspecialchars($this->getTemplateCode($template), ENT_QUOTES, 'UTF-8');
-
- // remove the code block
- $template = str_replace('{% set code = code(_self) %}', '', $template);
-
- return <<<EOF
-<p><strong>Controller Code</strong></p>
-<pre>$controller</pre>
-
-<p><strong>Template Code</strong></p>
-<pre>$template</pre>
-EOF;
- }
-
- protected function getControllerCode()
- {
- $class = get_class($this->controller[0]);
- if (class_exists('CG\Core\ClassUtils')) {
- $class = ClassUtils::getUserClass($class);
- }
-
- $r = new \ReflectionClass($class);
- $m = $r->getMethod($this->controller[1]);
-
- $code = file($r->getFilename());
-
- return ' '.$m->getDocComment()."\n".implode('', array_slice($code, $m->getStartline() - 1, $m->getEndLine() - $m->getStartline() + 1));
- }
-
- protected function getTemplateCode($template)
- {
- return $this->loader->getSource($template->getTemplateName());
- }
-
- /**
- * Returns the name of the extension.
- *
- * @return string The extension name
- */
- public function getName()
- {
- return 'demo';
- }
-}
View
13 src/Gr/BackendBundle/Controller/DefaultController.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace Gr\BackendBundle\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+
+class DefaultController extends Controller
+{
+ public function indexAction($name)
+ {
+ return $this->render('GrBackendBundle:Default:index.html.twig', array('name' => $name));
+ }
+}
View
28 src/Gr/BackendBundle/DependencyInjection/Configuration.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Gr\BackendBundle\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_backend');
+
+ // 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/BackendBundle/DependencyInjection/GrBackendExtension.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Gr\BackendBundle\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 GrBackendExtension 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/BackendBundle/GrBackendBundle.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Gr\BackendBundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+class GrBackendBundle extends Bundle
+{
+}
View
3 src/Gr/BackendBundle/Resources/config/routing.yml
@@ -0,0 +1,3 @@
+gr_backend_homepage:
+ pattern: /hello/{name}
+ defaults: { _controller: GrBackendBundle:Default:index }
View
7 src/Gr/BackendBundle/Resources/config/services.yml
@@ -0,0 +1,7 @@
+parameters:
+# gr_backend.example.class: Gr\BackendBundle\Example
+
+services:
+# gr_backend.example:
+# class: %gr_backend.example.class%
+# arguments: [@service_id, "plain_value", %parameter%]
View
0 src/Gr/BackendBundle/Resources/doc/index.rst
No changes.
View
11 src/Gr/BackendBundle/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/BackendBundle/Resources/views/Default/index.html.twig
@@ -0,0 +1 @@
+Hello {{ name }}!
View
17 src/Gr/BackendBundle/Tests/Controller/DefaultControllerTest.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace Gr\BackendBundle\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 d0e9bee

Please sign in to comment.