Skip to content

Commit ee8099c

Browse files
uikolasjaviereguiluz
authored andcommitted
Show better message when SQLite is not enabled
1 parent a5bec08 commit ee8099c

26 files changed

+466
-212
lines changed

app/AppKernel.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ public function registerBundles()
2222
new CodeExplorerBundle\CodeExplorerBundle(),
2323
new AppBundle\AppBundle(),
2424
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(), // used for initial population of non-SQLite databases in production envs
25-
// uncomment the following line if your application sends emails
26-
// new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
25+
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
2726
];
2827

2928
// Some bundles are only used while developing the application or during

app/Resources/translations/messages.en.xlf

+22
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@
243243
<source>menu.logout</source>
244244
<target>Logout</target>
245245
</trans-unit>
246+
<trans-unit id="menu.rss">
247+
<source>menu.rss</source>
248+
<target>Blog Posts RSS</target>
249+
</trans-unit>
246250

247251
<trans-unit id="post.to_publish_a_comment">
248252
<source>post.to_publish_a_comment</source>
@@ -277,6 +281,15 @@
277281
<target>Post deleted successfully!</target>
278282
</trans-unit>
279283

284+
<trans-unit id="notification.comment_created">
285+
<source>notification.comment_created</source>
286+
<target>Your post received a comment!</target>
287+
</trans-unit>
288+
<trans-unit id="notification.comment_created.description">
289+
<source>notification.comment_created.description</source>
290+
<target><![CDATA[Your post "%title%" has received a new comment. You can read the comment by following <a href="%link%">this link</a>]]></target>
291+
</trans-unit>
292+
280293
<trans-unit id="help.app_description">
281294
<source>help.app_description</source>
282295
<target><![CDATA[This is a <strong>demo application</strong> built in the Symfony Framework to illustrate the recommended way of developing Symfony applications.]]></target>
@@ -317,6 +330,15 @@
317330
<source>help.more_information</source>
318331
<target><![CDATA[For more information, check out the <a href="http://symfony.com/doc">Symfony doc</a>.]]></target>
319332
</trans-unit>
333+
334+
<trans-unit id="rss.title">
335+
<source>rss.title</source>
336+
<target>Symfony Demo blog</target>
337+
</trans-unit>
338+
<trans-unit id="rss.description">
339+
<source>rss.description</source>
340+
<target>Most recent posts published on the Symfony Demo blog</target>
341+
</trans-unit>
320342
</body>
321343
</file>
322344
</xliff>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{ include('blog/_delete_post_confirmation.html.twig') }}
2+
<form action="{{ url('admin_post_delete', { id: post.id }) }}" method="post" data-confirmation="true">
3+
<input type="hidden" name="token" value="{{ csrf_token('delete') }}" />
4+
<input type="submit" value="{{ 'action.delete_post'|trans }}" class="btn btn-lg btn-block btn-danger" />
5+
</form>

app/Resources/views/admin/blog/edit.html.twig

+2-7
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,15 @@
66
<h1>{{ 'title.edit_post'|trans({'%id%': post.id}) }}</h1>
77

88
{{ include('admin/blog/_form.html.twig', {
9-
form: edit_form,
9+
form: form,
1010
button_label: 'action.save'|trans,
1111
include_back_to_home_link: true,
1212
}, with_context = false) }}
1313
{% endblock %}
1414

1515
{% block sidebar %}
1616
<div class="section actions">
17-
{{ include('admin/blog/_form.html.twig', {
18-
form: delete_form,
19-
button_label: 'action.delete_post'|trans,
20-
button_css: 'btn btn-lg btn-block btn-danger',
21-
show_confirmation: true,
22-
}, with_context = false) }}
17+
{{ include('admin/blog/_delete_form.html.twig', { post: post }, with_context = false) }}
2318
</div>
2419

2520
{{ parent() }}

app/Resources/views/admin/blog/show.html.twig

+3-6
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,10 @@
3838
</div>
3939

4040
<div class="section">
41-
{{ include('admin/blog/_form.html.twig', {
42-
form: delete_form,
43-
button_label: 'action.delete_post'|trans,
44-
button_css: 'btn btn-lg btn-block btn-danger',
45-
show_confirmation: true,
46-
}, with_context = false) }}
41+
{{ include('admin/blog/_delete_form.html.twig', { post: post }, with_context = false) }}
4742
</div>
4843

44+
{{ parent() }}
45+
4946
{{ show_source_code(_self) }}
5047
{% endblock %}

app/Resources/views/base.html.twig

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<meta charset="UTF-8" />
1010
<meta name="viewport" content="width=device-width, initial-scale=1"/>
1111
<title>{% block title %}Symfony Demo application{% endblock %}</title>
12+
<link rel="alternate" type="application/rss+xml" title="{{ 'rss.title'|trans }}" href="{{ path('blog_rss') }}">
1213
{% block stylesheets %}
1314
<link rel="stylesheet" href="{{ asset('css/bootstrap-flatly-3.3.7.min.css') }}">
1415
<link rel="stylesheet" href="{{ asset('css/font-awesome-4.6.3.min.css') }}">
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="section rss">
2+
<a href="{{ path('blog_rss') }}">
3+
<i class="fa fa-rss" aria-hidden="true"></i> {{ 'menu.rss'|trans }}
4+
</a>
5+
</div>

app/Resources/views/blog/index.html.twig

+1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@
2828
{{ parent() }}
2929

3030
{{ show_source_code(_self) }}
31+
{{ include('blog/_rss.html.twig') }}
3132
{% endblock %}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<rss version="2.0">
3+
<channel>
4+
<title>{{ 'rss.title'|trans }}</title>
5+
<description>{{ 'rss.description'|trans }}</description>
6+
<pubDate>{{ 'now'|date('r', timezone='GMT') }}</pubDate>
7+
<lastBuildDate>{{ (posts|last).publishedAt|default('now')|date('r', timezone='GMT') }}</lastBuildDate>
8+
<link>{{ url('blog_index') }}</link>
9+
<language>{{ app.request.locale }}</language>
10+
11+
{% for post in posts %}
12+
<item>
13+
<title>{{ post.title }}</title>
14+
<description>{{ post.summary }}</description>
15+
<link>{{ url('blog_post', {'slug': post.slug}) }}</link>
16+
<guid>{{ url('blog_post', {'slug': post.slug}) }}</guid>
17+
<pubDate>{{ post.publishedAt|date(format='r', timezone='GMT') }}</pubDate>
18+
<author>{{ post.authorEmail }}</author>
19+
</item>
20+
{% endfor %}
21+
</channel>
22+
</rss>

app/Resources/views/blog/post_show.html.twig

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
{% for comment in post.comments %}
3232
<div class="row post-comment">
33+
<a name="comment_{{ comment.id }}"></a>
3334
<h4 class="col-sm-3">
3435
<strong>{{ comment.authorEmail }}</strong> {{ 'post.commented_on'|trans }}
3536
{# it's not mandatory to set the timezone in localizeddate(). This is done to
@@ -63,4 +64,5 @@
6364
{{ parent() }}
6465

6566
{{ show_source_code(_self) }}
67+
{{ include('blog/_rss.html.twig') }}
6668
{% endblock %}

app/Resources/views/form/fields.html.twig

+6-8
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
#}
99

1010
{% block date_time_picker_widget %}
11-
{% spaceless %}
12-
<div class="input-group date" data-toggle="datetimepicker">
13-
{{ block('datetime_widget') }}
14-
<span class="input-group-addon">
15-
<span class="fa fa-calendar" aria-hidden="true"></span>
16-
</span>
17-
</div>
18-
{% endspaceless %}
11+
<div class="input-group date" data-toggle="datetimepicker">
12+
{{ block('datetime_widget') }}
13+
<span class="input-group-addon">
14+
<span class="fa fa-calendar" aria-hidden="true"></span>
15+
</span>
16+
</div>
1917
{% endblock %}

app/Resources/views/security/login.html.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080
</div>
8181
</div>
8282
{% endblock %}
83-
{% block sidebar %}
8483

84+
{% block sidebar %}
8585
{{ parent() }}
8686

8787
{{ show_source_code(_self) }}

app/config/config.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ doctrine:
8383
# stores options that change the application behavior and parameters.yml
8484
# stores options that change from one server to another
8585
#
86-
# swiftmailer:
87-
# transport: "%mailer_transport%"
88-
# host: "%mailer_host%"
89-
# username: "%mailer_user%"
90-
# password: "%mailer_password%"
91-
# spool: { type: memory }
86+
swiftmailer:
87+
transport: "%mailer_transport%"
88+
host: "%mailer_host%"
89+
username: "%mailer_user%"
90+
password: "%mailer_password%"
91+
spool: { type: memory }

app/config/config_dev.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ monolog:
2929
# type: chromephp
3030
# level: info
3131

32-
#swiftmailer:
33-
# delivery_address: [email protected]
32+
swiftmailer:
33+
disable_delivery: true

app/config/parameters.yml.dist

+4-7
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,9 @@ parameters:
3131
# $ php bin/console doctrine:schema:create
3232
# $ php bin/console doctrine:fixtures:load
3333

34-
# Uncomment these parameters if your application sends emails:
35-
#
36-
# mailer_transport: smtp
37-
# mailer_host: 127.0.0.1
38-
# mailer_user: ~
39-
# mailer_password: ~
40-
#
4134
# If you don't use a real mail server, you can send emails via your Gmail account.
4235
# see http://symfony.com/doc/current/cookbook/email/gmail.html
36+
mailer_transport: smtp
37+
mailer_host: 127.0.0.1
38+
mailer_user: ~
39+
mailer_password: ~

app/config/services.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,21 @@ services:
3131
tags:
3232
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
3333

34-
# Event subscribers are similar to event listeners but they don't need to add
35-
# a separate tag for each listened event. Instead, the PHP class of the event
36-
# subscriber includes a method that returns the list of listened events.
34+
app.comment_notification:
35+
class: AppBundle\EventListener\CommentNotificationListener
36+
arguments: ['@mailer', '@router', '@translator', '%app.notifications.email_sender%']
37+
# The "method" attribute of this tag is optional and defaults to "on + camelCasedEventName"
38+
# If the event is "comment.created" the method executed by default is "onCommentCreated()".
39+
tags:
40+
- { name: kernel.event_listener, event: comment.created, method: onCommentCreated }
41+
42+
# Event subscribers are similar to event listeners but they don't need service tags.
43+
# Instead, the PHP class of the event subscriber includes a method that returns
44+
# the list of events listened by that class.
3745
# See http://symfony.com/doc/current/event_dispatcher.html#creating-an-event-subscriber
3846
app.console_subscriber:
39-
class: AppBundle\EventListener\ConsoleEventSubscriber
47+
class: AppBundle\EventListener\CheckSQLiteEventSubscriber
48+
arguments: ['@doctrine.orm.entity_manager']
4049
tags:
4150
- { name: kernel.event_subscriber }
4251

0 commit comments

Comments
 (0)