Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Updated the application to Symfony 3.3.0 #562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 16 commits into from
Closed
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
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ script:
- ./bin/console lint:yaml @CodeExplorerBundle
# this checks that the Twig template files contain no syntax errors
- ./bin/console lint:twig app/Resources @CodeExplorerBundle
# this checks that the XLIFF translations contain no syntax errors
- ./bin/console lint:xliff app/Resources
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about more specific app/Resources/translations? We have translations only in that folder

# this checks that the application doesn't use dependencies with known security vulnerabilities
- ./bin/console security:check --end-point=http://security.sensiolabs.org/check_lock
6 changes: 5 additions & 1 deletion app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ public function registerBundles()
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();

if ('dev' === $this->getEnvironment()) {
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}

if ('test' === $this->getEnvironment()) {
// this bundle makes it easier to work with databases in PHPUnit
Expand Down
41 changes: 20 additions & 21 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,51 +30,50 @@ framework:
# and with different cache configurations for each fragment
# https://symfony.com/doc/current/book/http_cache.html#edge-side-includes
esi: { enabled: true }
translator: { fallback: "%locale%" }
secret: "%env(SYMFONY_SECRET)%"
translator: { fallback: '%locale%' }
secret: '%env(SYMFONY_SECRET)%'
router:
resource: "%kernel.root_dir%/config/routing.yml"
resource: '%kernel.root_dir%/config/routing.yml'
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: "%locale%"
default_locale: '%locale%'
trusted_hosts: ~
trusted_proxies: ~
session:
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
fragments: ~
http_method_override: true
assets: ~

# Twig Configuration (used for rendering application templates)
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
form_themes:
- "form/layout.html.twig"
- "form/fields.html.twig"
- 'form/layout.html.twig'
- 'form/fields.html.twig'

# Doctrine Configuration (used to access databases and manipulate their information)
doctrine:
dbal:
# if you don't want to use SQLite, change the URL in parameters.yml or set the DATABASE_URL environment variable
url: "%env(DATABASE_URL)%"
url: '%env(DATABASE_URL)%'

# instead of using a URL, you may also uncomment the following lines to configure your database
# driver: pdo_mysql
# host: "%database_host%"
# port: "%database_port%"
# dbname: "%database_name%"
# user: "%database_user%"
# password: "%database_password%"
# host: '%database_host%'
# port: '%database_port%'
# dbname: '%database_name%'
# user: '%database_user%'
# password: '%database_password%'
# charset: UTF8

orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_generate_proxy_classes: '%kernel.debug%'
auto_mapping: true

# Swiftmailer Configuration (used to send emails)
Expand All @@ -84,8 +83,8 @@ doctrine:
# stores options that change from one server to another
#
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
transport: '%mailer_transport%'
host: '%mailer_host%'
username: '%mailer_user%'
password: '%mailer_password%'
spool: { type: memory }
124 changes: 44 additions & 80 deletions app/config/services.yml
Original file line number Diff line number Diff line change
@@ -1,83 +1,47 @@
services:
# First we define some basic services to make these utilities available in
# the entire application
slugger:
class: AppBundle\Utils\Slugger

markdown:
class: AppBundle\Utils\Markdown

# These are the Twig extensions that create new filters and functions for
# using them in the templates
app.twig.app_extension:
public: false
class: AppBundle\Twig\AppExtension
arguments: ['@markdown', '%app_locales%']
tags:
- { name: twig.extension }

app.twig.intl_extension:
public: false
class: Twig_Extensions_Extension_Intl
tags:
- { name: twig.extension }

# Defining a form type as a service is only required when the form type
# needs to use some other services, such as the entity manager.
# See https://symfony.com/doc/current/best_practices/forms.html
app.form.type.tagsinput:
class: AppBundle\Form\Type\TagsInputType
arguments: ['@doctrine.orm.entity_manager']
tags:
- { name: form.type }

# Event Listeners are classes that listen to one or more specific events.
# Those events are defined in the tags added to the service definition.
# See https://symfony.com/doc/current/event_dispatcher.html#creating-an-event-listener
app.redirect_to_preferred_locale_listener:
class: AppBundle\EventListener\RedirectToPreferredLocaleListener
arguments: ['@router', '%app_locales%', '%locale%']
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

app.comment_notification:
class: AppBundle\EventListener\CommentNotificationListener
arguments: ['@mailer', '@router', '@translator', '%app.notifications.email_sender%']
# The "method" attribute of this tag is optional and defaults to "on + camelCasedEventName"
# If the event is "comment.created" the method executed by default is "onCommentCreated()".
tags:
- { name: kernel.event_listener, event: comment.created, method: onCommentCreated }

# Event subscribers are similar to event listeners but they don't need service tags.
# Instead, the PHP class of the event subscriber includes a method that returns
# the list of events listened by that class.
# See https://symfony.com/doc/current/event_dispatcher.html#creating-an-event-subscriber
app.requirements_subscriber:
class: AppBundle\EventListener\CheckRequirementsSubscriber
arguments: ['@doctrine.orm.entity_manager']
tags:
- { name: kernel.event_subscriber }

# To inject the voter into the security layer, you must declare it as a service and tag it with security.voter.
# See https://symfony.com/doc/current/security/voters.html#configuring-the-voter
app.post_voter:
class: AppBundle\Security\PostVoter
# default configuration for services in *this* file
_defaults:
# automatically injects dependencies in your services
autowire: true
# automatically registers your services as commands, event subscribers, etc.
autoconfigure: true
# this means you cannot fetch services directly from the container via $container->get()
# if you need to do this, you can override this setting on individual services
public: false
tags:
- { name: security.voter }

# Uncomment the following lines to define a service for the Post Doctrine repository.
# It's not mandatory to create these services, but if you use repositories a lot,
# these services simplify your code:
#
# app.post_repository:
# class: Doctrine\ORM\EntityRepository
# factory: ['@doctrine.orm.entity_manager', getRepository]
# arguments: [AppBundle\Entity\Post]
#
# // traditional code inside a controller
# $entityManager = $this->getDoctrine()->getManager();
# $posts = $entityManager->getRepository('AppBundle:Post')->findAll();
#
# // same code using repository services
# $posts = $this->get('app.post_repository')->findAll();
# makes classes in src/AppBundle available to be used as services
# this creates a service per class whose id is the fully-qualified class name
AppBundle\:
resource: '../../src/AppBundle/*'
# you can exclude directories or files
# but if a service is unused, it's removed anyway
exclude: '../../src/AppBundle/{Controller,Entity,Repository}'

# controllers are imported separately to make sure they're public
# and have a tag that allows actions to type-hint services
AppBundle\Controller\:
resource: '../../src/AppBundle/Controller'
public: true
tags: ['controller.service_arguments']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this is not needed if our controllers extend from Controller so it's already auto-tagged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right... but it's nice to be consistent with the official project skeleton


# Autowiring can't guess the constructor arguments that are not type-hinted with
# classes (e.g. container parameters) so you must define those arguments explicitly
AppBundle\Command\ListUsersCommand:
arguments:
$emailSender: '%app.notifications.email_sender%'

AppBundle\Twig\AppExtension:
arguments:
$locales: '%app_locales%'

AppBundle\EventListener\CommentNotificationSubscriber:
arguments:
$sender: '%app.notifications.email_sender%'

AppBundle\EventListener\RedirectToPreferredLocaleSubscriber:
arguments:
$locales: '%app_locales%'
$defaultLocale: '%locale%'

# needed for the localizeddate Twig filter
Twig\Extensions\IntlExtension: ~
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"symfony/monolog-bundle" : "^3.0",
"symfony/polyfill-apcu" : "^1.0",
"symfony/swiftmailer-bundle" : "^2.3",
"symfony/symfony" : "^3.2",
"twig/extensions" : "^1.3",
"symfony/symfony" : "^3.3",
"twig/extensions" : "^1.5",
"twig/twig" : "^1.28 || ^2.0",
"white-october/pagerfanta-bundle" : "^1.0"
},
Expand Down
Loading