Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/config/routing_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ _main:
# AcmeDemoBundle routes (to be removed)
_acme_demo:
resource: "@AcmeDemoBundle/Resources/config/routing.yml"

# Including my routes resource to routing_dev.yml
myrouting:
resource: "@AcmeDemoBundle/Resources/config/myrouting.yml"
47 changes: 47 additions & 0 deletions src/Acme/DemoBundle/Controller/MyController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Created by JetBrains PhpStorm.
* User: kanni
* Date: 11/6/13
* Time: 1:55 PM
* To change this template use File | Settings | File Templates.
*/

namespace Acme\DemoBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;


class MyController extends Controller
{
public function firstAction($name)
{
/*
* The action's view can be rendered using render() method
* or @Template annotation as demonstrated in DemoController.
*
*/
return new Response("Hello, ".$name);#$this->render('AcmeDemoBundle:Welcome:index.html.twig');
}

public function secondAction()
{
/*
* The action's view can be rendered using render() method
* or @Template annotation as demonstrated in DemoController.
*
*/
return $this->render('AcmeDemoBundle:SimpleTemplate:simple.html.twig');
}

public function thirdAction()
{
/*
* The action's view can be rendered using render() method
* or @Template annotation as demonstrated in DemoController.
*
*/
return $this->render('AcmeDemoBundle:ExtendingTemplate:extending.html.twig');
}
}
11 changes: 11 additions & 0 deletions src/Acme/DemoBundle/Resources/config/myrouting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
simple_response:
pattern: /1/{name}
defaults: { _controller: AcmeDemoBundle:My:first, name: "noob :)" }

simple_template:
pattern: /2
defaults: { _controller: AcmeDemoBundle:My:second }

extending_response:
pattern: /3
defaults: { _controller: AcmeDemoBundle:My:third }
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{% 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 'Rendered template that extends base template' %}

{% 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 %}
<p>Result of the 3nd action in advanced controller,
which returns rendered template
that extends base template</p>
{% 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 %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Rendered simple template</title>
<meta http-equiv="content-type"
content="text/html;charset=utf-8" />
</head>

<body>

<p>
Simple html. Result of the 2nd action in advanced controller,
which returns rendered simple template
</p>

</body>
</html>
6 changes: 3 additions & 3 deletions web/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# mod_rewrite). Additionally, this reduces the matching process for the
# start page (path "/") because otherwise Apache will apply the rewriting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex app.php
DirectoryIndex app_dev.php

<IfModule mod_rewrite.c>
RewriteEngine On
Expand Down Expand Up @@ -38,15 +38,15 @@ DirectoryIndex app.php
RewriteRule .? - [L]

# Rewrite all other queries to the front controller.
RewriteRule .? %{ENV:BASE}/app.php [L]
RewriteRule .? %{ENV:BASE}/app_dev.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
# When mod_rewrite is not available, we instruct a temporary redirect of
# the start page to the front controller explicitly so that the website
# and the generated links can still be used.
RedirectMatch 302 ^/$ /app.php/
RedirectMatch 302 ^/$ /app_dev.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>