Skip to content

Commit a2a6831

Browse files
elkukujaviereguiluz
authored andcommitted
Use Symfony console style
1 parent 98898e4 commit a2a6831

27 files changed

+545
-385
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ script:
2929
- ./bin/console lint:yaml @CodeExplorerBundle
3030
# this checks that the Twig template files contain no syntax errors
3131
- ./bin/console lint:twig app/Resources @CodeExplorerBundle
32+
# this checks that the XLIFF translations contain no syntax errors
33+
- ./bin/console lint:xliff app/Resources
3234
# this checks that the application doesn't use dependencies with known security vulnerabilities
3335
- ./bin/console security:check --end-point=http://security.sensiolabs.org/check_lock

app/AppKernel.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ public function registerBundles()
4242
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
4343
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
4444
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
45-
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
45+
46+
if ('dev' === $this->getEnvironment()) {
47+
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
48+
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
49+
}
4650

4751
if ('test' === $this->getEnvironment()) {
4852
// this bundle makes it easier to work with databases in PHPUnit

app/Resources/views/default/_flash_messages.html.twig

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@
77
'_flash_messages.html.twig' instead of 'flash_messages.html.twig'
88
#}
99

10-
{% if app.session.started and app.session.flashBag.peekAll is not empty %}
11-
<div class="messages">
12-
{% for type, messages in app.session.flashBag.all %}
13-
{% for message in messages %}
14-
{# Bootstrap alert, see http://getbootstrap.com/components/#alerts #}
15-
<div class="alert alert-dismissible alert-{{ type }}" role="alert">
16-
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
17-
<span aria-hidden="true">&times;</span>
18-
</button>
10+
<div class="messages">
11+
{% for type, messages in app.flashes %}
12+
{% for message in messages %}
13+
{# Bootstrap alert, see http://getbootstrap.com/components/#alerts #}
14+
<div class="alert alert-dismissible alert-{{ type }}" role="alert">
15+
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
16+
<span aria-hidden="true">&times;</span>
17+
</button>
1918

20-
{{ message|trans }}
21-
</div>
22-
{% endfor %}
19+
{{ message|trans }}
20+
</div>
2321
{% endfor %}
24-
</div>
25-
{% endif %}
22+
{% endfor %}
23+
</div>

app/config/config.yml

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,51 +30,40 @@ framework:
3030
# and with different cache configurations for each fragment
3131
# https://symfony.com/doc/current/book/http_cache.html#edge-side-includes
3232
esi: { enabled: true }
33-
translator: { fallback: "%locale%" }
34-
secret: "%env(SYMFONY_SECRET)%"
33+
translator: { fallback: '%locale%' }
34+
secret: '%env(SYMFONY_SECRET)%'
3535
router:
36-
resource: "%kernel.root_dir%/config/routing.yml"
36+
resource: '%kernel.project_dir%/app/config/routing.yml'
3737
strict_requirements: ~
3838
form: ~
3939
csrf_protection: ~
4040
validation: { enable_annotations: true }
4141
templating:
4242
engines: ['twig']
43-
default_locale: "%locale%"
43+
default_locale: '%locale%'
4444
trusted_hosts: ~
45-
trusted_proxies: ~
4645
session:
4746
handler_id: session.handler.native_file
48-
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
47+
save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
4948
fragments: ~
5049
http_method_override: true
5150
assets: ~
5251

5352
# Twig Configuration (used for rendering application templates)
5453
twig:
55-
debug: "%kernel.debug%"
56-
strict_variables: "%kernel.debug%"
54+
debug: '%kernel.debug%'
55+
strict_variables: '%kernel.debug%'
5756
form_themes:
58-
- "form/layout.html.twig"
59-
- "form/fields.html.twig"
57+
- 'form/layout.html.twig'
58+
- 'form/fields.html.twig'
6059

6160
# Doctrine Configuration (used to access databases and manipulate their information)
6261
doctrine:
6362
dbal:
6463
# if you don't want to use SQLite, change the URL in parameters.yml or set the DATABASE_URL environment variable
65-
url: "%env(DATABASE_URL)%"
66-
67-
# instead of using a URL, you may also uncomment the following lines to configure your database
68-
# driver: pdo_mysql
69-
# host: "%database_host%"
70-
# port: "%database_port%"
71-
# dbname: "%database_name%"
72-
# user: "%database_user%"
73-
# password: "%database_password%"
74-
# charset: UTF8
75-
64+
url: '%env(DATABASE_URL)%'
7665
orm:
77-
auto_generate_proxy_classes: "%kernel.debug%"
66+
auto_generate_proxy_classes: '%kernel.debug%'
7867
auto_mapping: true
7968

8069
# Swiftmailer Configuration (used to send emails)
@@ -84,8 +73,5 @@ doctrine:
8473
# stores options that change from one server to another
8574
#
8675
swiftmailer:
87-
transport: "%mailer_transport%"
88-
host: "%mailer_host%"
89-
username: "%mailer_user%"
90-
password: "%mailer_password%"
91-
spool: { type: memory }
76+
url : '%env(MAILER_URL)%'
77+
spool: { type: memory }

app/config/config_dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ imports:
33

44
framework:
55
router:
6-
resource: "%kernel.root_dir%/config/routing_dev.yml"
6+
resource: "%kernel.project_dir%/app/config/routing_dev.yml"
77
strict_requirements: true
88
profiler: { only_exceptions: false }
99

app/config/config_test.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ web_profiler:
1515
# swiftmailer:
1616
# disable_delivery: true
1717

18-
# It's recommended to use a separate database for tests. This allows to have a
19-
# fixed and known set of data fixtures, it simplifies the code of tests and it
20-
# makes them more robust.
21-
# In this case we just need to define a different path for the application database.
22-
doctrine:
23-
dbal:
24-
path: "%kernel.root_dir%/../var/data/blog_test.sqlite"
25-
2618
# this configuration simplifies testing URLs protected by the security mechanism
2719
# See https://symfony.com/doc/current/cookbook/testing/http_authentication.html
2820
security:

app/config/parameters.yml.dist

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ parameters:
1717
# this demo application uses an embedded SQLite database to simplify setup.
1818
# in a real Symfony application you probably will use a MySQL or PostgreSQL database
1919
# the path must be relative or else it will not work on Windows
20-
env(DATABASE_URL): 'sqlite:///%kernel.root_dir%/../var/data/blog.sqlite'
20+
env(DATABASE_URL): 'sqlite:///%kernel.project_dir%/var/data/blog.sqlite'
2121

2222
# Uncomment this line to use a MySQL database instead of SQLite (and remove
2323
# the "doctrine" section from config_dev.yml regarding SQLite):
@@ -33,7 +33,4 @@ parameters:
3333

3434
# If you don't use a real mail server, you can send emails via your Gmail account.
3535
# see https://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: ~
36+
env(MAILER_URL): 'smtp://localhost:25?encryption=&auth_mode='

app/config/services.yml

Lines changed: 44 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,47 @@
11
services:
2-
# First we define some basic services to make these utilities available in
3-
# the entire application
4-
slugger:
5-
class: AppBundle\Utils\Slugger
6-
7-
markdown:
8-
class: AppBundle\Utils\Markdown
9-
10-
# These are the Twig extensions that create new filters and functions for
11-
# using them in the templates
12-
app.twig.app_extension:
13-
public: false
14-
class: AppBundle\Twig\AppExtension
15-
arguments: ['@markdown', '%app_locales%']
16-
tags:
17-
- { name: twig.extension }
18-
19-
app.twig.intl_extension:
20-
public: false
21-
class: Twig_Extensions_Extension_Intl
22-
tags:
23-
- { name: twig.extension }
24-
25-
# Defining a form type as a service is only required when the form type
26-
# needs to use some other services, such as the entity manager.
27-
# See https://symfony.com/doc/current/best_practices/forms.html
28-
app.form.type.tagsinput:
29-
class: AppBundle\Form\Type\TagsInputType
30-
arguments: ['@doctrine.orm.entity_manager']
31-
tags:
32-
- { name: form.type }
33-
34-
# Event Listeners are classes that listen to one or more specific events.
35-
# Those events are defined in the tags added to the service definition.
36-
# See https://symfony.com/doc/current/event_dispatcher.html#creating-an-event-listener
37-
app.redirect_to_preferred_locale_listener:
38-
class: AppBundle\EventListener\RedirectToPreferredLocaleListener
39-
arguments: ['@router', '%app_locales%', '%locale%']
40-
tags:
41-
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
42-
43-
app.comment_notification:
44-
class: AppBundle\EventListener\CommentNotificationListener
45-
arguments: ['@mailer', '@router', '@translator', '%app.notifications.email_sender%']
46-
# The "method" attribute of this tag is optional and defaults to "on + camelCasedEventName"
47-
# If the event is "comment.created" the method executed by default is "onCommentCreated()".
48-
tags:
49-
- { name: kernel.event_listener, event: comment.created, method: onCommentCreated }
50-
51-
# Event subscribers are similar to event listeners but they don't need service tags.
52-
# Instead, the PHP class of the event subscriber includes a method that returns
53-
# the list of events listened by that class.
54-
# See https://symfony.com/doc/current/event_dispatcher.html#creating-an-event-subscriber
55-
app.requirements_subscriber:
56-
class: AppBundle\EventListener\CheckRequirementsSubscriber
57-
arguments: ['@doctrine.orm.entity_manager']
58-
tags:
59-
- { name: kernel.event_subscriber }
60-
61-
# To inject the voter into the security layer, you must declare it as a service and tag it with security.voter.
62-
# See https://symfony.com/doc/current/security/voters.html#configuring-the-voter
63-
app.post_voter:
64-
class: AppBundle\Security\PostVoter
2+
# default configuration for services in *this* file
3+
_defaults:
4+
# automatically injects dependencies in your services
5+
autowire: true
6+
# automatically registers your services as commands, event subscribers, etc.
7+
autoconfigure: true
8+
# this means you cannot fetch services directly from the container via $container->get()
9+
# if you need to do this, you can override this setting on individual services
6510
public: false
66-
tags:
67-
- { name: security.voter }
6811

69-
# Uncomment the following lines to define a service for the Post Doctrine repository.
70-
# It's not mandatory to create these services, but if you use repositories a lot,
71-
# these services simplify your code:
72-
#
73-
# app.post_repository:
74-
# class: Doctrine\ORM\EntityRepository
75-
# factory: ['@doctrine.orm.entity_manager', getRepository]
76-
# arguments: [AppBundle\Entity\Post]
77-
#
78-
# // traditional code inside a controller
79-
# $entityManager = $this->getDoctrine()->getManager();
80-
# $posts = $entityManager->getRepository('AppBundle:Post')->findAll();
81-
#
82-
# // same code using repository services
83-
# $posts = $this->get('app.post_repository')->findAll();
12+
# makes classes in src/AppBundle available to be used as services
13+
# this creates a service per class whose id is the fully-qualified class name
14+
AppBundle\:
15+
resource: '../../src/AppBundle/*'
16+
# you can exclude directories or files
17+
# but if a service is unused, it's removed anyway
18+
exclude: '../../src/AppBundle/{Controller,Entity,Repository}'
19+
20+
# controllers are imported separately to make sure they're public
21+
# and have a tag that allows actions to type-hint services
22+
AppBundle\Controller\:
23+
resource: '../../src/AppBundle/Controller'
24+
public: true
25+
tags: ['controller.service_arguments']
26+
27+
# Autowiring can't guess the constructor arguments that are not type-hinted with
28+
# classes (e.g. container parameters) so you must define those arguments explicitly
29+
AppBundle\Command\ListUsersCommand:
30+
arguments:
31+
$emailSender: '%app.notifications.email_sender%'
32+
33+
AppBundle\Twig\AppExtension:
34+
arguments:
35+
$locales: '%app_locales%'
36+
37+
AppBundle\EventListener\CommentNotificationSubscriber:
38+
arguments:
39+
$sender: '%app.notifications.email_sender%'
40+
41+
AppBundle\EventListener\RedirectToPreferredLocaleSubscriber:
42+
arguments:
43+
$locales: '%app_locales%'
44+
$defaultLocale: '%locale%'
45+
46+
# needed for the localizeddate Twig filter
47+
Twig\Extensions\IntlExtension: ~

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"symfony/monolog-bundle" : "^3.0",
3030
"symfony/polyfill-apcu" : "^1.0",
3131
"symfony/swiftmailer-bundle" : "^2.3",
32-
"symfony/symfony" : "^3.2",
33-
"twig/extensions" : "^1.3",
32+
"symfony/symfony" : "^3.3",
33+
"twig/extensions" : "^1.5",
3434
"twig/twig" : "^1.28 || ^2.0",
3535
"white-october/pagerfanta-bundle" : "^1.0"
3636
},

0 commit comments

Comments
 (0)