From 798a7866bee196e156d39a092e67b177410f4b00 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 22 May 2017 09:53:09 +0200 Subject: [PATCH 01/16] Updated the application to Symfony 3.3.0 RC1 --- app/AppKernel.php | 6 +- app/config/config.yml | 1 - app/config/services.yml | 117 +++------ composer.json | 2 +- composer.lock | 231 +++++++++++++++++- .../Controller/Admin/BlogController.php | 9 +- .../Controller/SecurityController.php | 5 +- .../DataFixtures/ORM/PostFixtures.php | 1 + ....php => CommentNotificationSubscriber.php} | 10 +- ...> RedirectToPreferredLocaleSubscriber.php} | 11 +- .../Form/Type/DateTimePickerType.php | 4 +- 11 files changed, 296 insertions(+), 101 deletions(-) rename src/AppBundle/EventListener/{CommentNotificationListener.php => CommentNotificationSubscriber.php} (91%) rename src/AppBundle/EventListener/{RedirectToPreferredLocaleListener.php => RedirectToPreferredLocaleSubscriber.php} (90%) diff --git a/app/AppKernel.php b/app/AppKernel.php index 1ad4f6b3e..c0c4ad4b6 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -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 diff --git a/app/config/config.yml b/app/config/config.yml index 41c0a0047..79d826695 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -42,7 +42,6 @@ framework: engines: ['twig'] default_locale: "%locale%" trusted_hosts: ~ - trusted_proxies: ~ session: handler_id: session.handler.native_file save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%" diff --git a/app/config/services.yml b/app/config/services.yml index d54d2b579..4a78b9aae 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -1,83 +1,46 @@ 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 } + # 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 - app.twig.intl_extension: + # 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/{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'] + + # 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\Twig\AppExtension: + arguments: + $locales: '%app_locales%' + + AppBundle\EventListener\CommentNotificationSubscriber: + arguments: + $sender: '%app.notifications.email_sender%' + + AppBundle\EventListener\RedirectToPreferredLocaleSubscriber: + arguments: + $locales: '%app_locales%' + $defaultLocale: '%locale%' + + Twig_Extensions_Extension_Intl: 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 - 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(); diff --git a/composer.json b/composer.json index 51b395663..092e3f2c6 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "symfony/monolog-bundle" : "^3.0", "symfony/polyfill-apcu" : "^1.0", "symfony/swiftmailer-bundle" : "^2.3", - "symfony/symfony" : "^3.2", + "symfony/symfony" : "3.3.0-RC1", "twig/extensions" : "^1.3", "twig/twig" : "^1.28 || ^2.0", "white-october/pagerfanta-bundle" : "^1.0" diff --git a/composer.lock b/composer.lock index 59bb0aa16..76f365681 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "a201a8d92585c751f757f88752195add", + "content-hash": "9dedbfbff97aaca348e937cf124f55b3", "packages": [ { "name": "composer/ca-bundle", @@ -1036,6 +1036,60 @@ ], "time": "2017-03-13T06:30:53+00:00" }, + { + "name": "fig/link-util", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/link-util.git", + "reference": "1a07821801a148be4add11ab0603e4af55a72fac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/link-util/zipball/1a07821801a148be4add11ab0603e4af55a72fac", + "reference": "1a07821801a148be4add11ab0603e4af55a72fac", + "shasum": "" + }, + "require": { + "php": ">=5.5.0", + "psr/link": "~1.0@dev" + }, + "require-dev": { + "phpunit/phpunit": "^5.1", + "squizlabs/php_codesniffer": "^2.3.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Fig\\Link\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common utility implementations for HTTP links", + "keywords": [ + "http", + "http-link", + "link", + "psr", + "psr-13", + "rest" + ], + "time": "2016-10-17T18:31:11+00:00" + }, { "name": "incenteev/composer-parameter-handler", "version": "v2.1.2", @@ -1378,6 +1432,104 @@ ], "time": "2016-08-06T20:24:11+00:00" }, + { + "name": "psr/container", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-02-14T16:28:37+00:00" + }, + { + "name": "psr/link", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/link.git", + "reference": "eea8e8662d5cd3ae4517c9b864493f59fca95562" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/link/zipball/eea8e8662d5cd3ae4517c9b864493f59fca95562", + "reference": "eea8e8662d5cd3ae4517c9b864493f59fca95562", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Link\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for HTTP links", + "keywords": [ + "http", + "http-link", + "link", + "psr", + "psr-13", + "rest" + ], + "time": "2016-10-28T16:06:13+00:00" + }, { "name": "psr/log", "version": "1.0.2", @@ -1425,6 +1577,54 @@ ], "time": "2016-10-10T12:19:37+00:00" }, + { + "name": "psr/simple-cache", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "753fa598e8f3b9966c886fe13f370baa45ef0e24" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/753fa598e8f3b9966c886fe13f370baa45ef0e24", + "reference": "753fa598e8f3b9966c886fe13f370baa45ef0e24", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "time": "2017-01-02T13:31:39+00:00" + }, { "name": "sensio/distribution-bundle", "version": "v5.0.19", @@ -2104,29 +2304,33 @@ }, { "name": "symfony/symfony", - "version": "v3.2.8", + "version": "v3.3.0-RC1", "source": { "type": "git", "url": "https://github.com/symfony/symfony.git", - "reference": "85959c2abbe4d2f050f950f39c9c3cf83819f3df" + "reference": "a66d56bfde7edd0f3b9e2857131561348234832b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/symfony/zipball/85959c2abbe4d2f050f950f39c9c3cf83819f3df", - "reference": "85959c2abbe4d2f050f950f39c9c3cf83819f3df", + "url": "https://api.github.com/repos/symfony/symfony/zipball/a66d56bfde7edd0f3b9e2857131561348234832b", + "reference": "a66d56bfde7edd0f3b9e2857131561348234832b", "shasum": "" }, "require": { "doctrine/common": "~2.4", + "fig/link-util": "^1.0", "php": ">=5.5.9", "psr/cache": "~1.0", + "psr/container": "^1.0", + "psr/link": "^1.0", "psr/log": "~1.0", + "psr/simple-cache": "^1.0", "symfony/polyfill-intl-icu": "~1.0", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php56": "~1.0", "symfony/polyfill-php70": "~1.0", "symfony/polyfill-util": "~1.0", - "twig/twig": "~1.28|~2.0" + "twig/twig": "~1.32|~2.2" }, "conflict": { "phpdocumentor/reflection-docblock": "<3.0", @@ -2134,7 +2338,9 @@ "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0" }, "provide": { - "psr/cache-implementation": "1.0" + "psr/cache-implementation": "1.0", + "psr/container-implementation": "1.0", + "psr/simple-cache-implementation": "1.0" }, "replace": { "symfony/asset": "self.version", @@ -2149,6 +2355,7 @@ "symfony/dependency-injection": "self.version", "symfony/doctrine-bridge": "self.version", "symfony/dom-crawler": "self.version", + "symfony/dotenv": "self.version", "symfony/event-dispatcher": "self.version", "symfony/expression-language": "self.version", "symfony/filesystem": "self.version", @@ -2181,7 +2388,9 @@ "symfony/twig-bundle": "self.version", "symfony/validator": "self.version", "symfony/var-dumper": "self.version", + "symfony/web-link": "self.version", "symfony/web-profiler-bundle": "self.version", + "symfony/web-server-bundle": "self.version", "symfony/workflow": "self.version", "symfony/yaml": "self.version" }, @@ -2205,7 +2414,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "3.3-dev" } }, "autoload": { @@ -2244,7 +2453,7 @@ "keywords": [ "framework" ], - "time": "2017-05-01T17:47:03+00:00" + "time": "2017-05-17T18:10:19+00:00" }, { "name": "twig/extensions", @@ -3885,7 +4094,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "symfony/symfony": 5 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/AppBundle/Controller/Admin/BlogController.php b/src/AppBundle/Controller/Admin/BlogController.php index 7a0bb9f42..edaf6c2dd 100644 --- a/src/AppBundle/Controller/Admin/BlogController.php +++ b/src/AppBundle/Controller/Admin/BlogController.php @@ -13,6 +13,7 @@ use AppBundle\Entity\Post; use AppBundle\Form\PostType; +use AppBundle\Utils\Slugger; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; @@ -70,7 +71,7 @@ public function indexAction() * to constraint the HTTP methods each controller responds to (by default * it responds to all methods). */ - public function newAction(Request $request) + public function newAction(Request $request, Slugger $slugger) { $post = new Post(); $post->setAuthor($this->getUser()); @@ -86,7 +87,7 @@ public function newAction(Request $request) // However, we explicitly add it to improve code readability. // See https://symfony.com/doc/current/best_practices/forms.html#handling-form-submits if ($form->isSubmitted() && $form->isValid()) { - $post->setSlug($this->get('slugger')->slugify($post->getTitle())); + $post->setSlug($slugger->slugify($post->getTitle())); $entityManager = $this->getDoctrine()->getManager(); $entityManager->persist($post); @@ -134,7 +135,7 @@ public function showAction(Post $post) * @Route("/{id}/edit", requirements={"id": "\d+"}, name="admin_post_edit") * @Method({"GET", "POST"}) */ - public function editAction(Post $post, Request $request) + public function editAction(Request $request, Post $post, Slugger $slugger) { $this->denyAccessUnlessGranted('edit', $post, 'Posts can only be edited by their authors.'); @@ -145,7 +146,7 @@ public function editAction(Post $post, Request $request) $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $post->setSlug($this->get('slugger')->slugify($post->getTitle())); + $post->setSlug($slugger->slugify($post->getTitle())); $entityManager->flush(); $this->addFlash('success', 'post.updated_successfully'); diff --git a/src/AppBundle/Controller/SecurityController.php b/src/AppBundle/Controller/SecurityController.php index c5d304c63..cb2770e68 100644 --- a/src/AppBundle/Controller/SecurityController.php +++ b/src/AppBundle/Controller/SecurityController.php @@ -13,6 +13,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; /** * Controller used to manage the application security. @@ -26,10 +27,8 @@ class SecurityController extends Controller /** * @Route("/login", name="security_login") */ - public function loginAction() + public function loginAction(AuthenticationUtils $helper) { - $helper = $this->get('security.authentication_utils'); - return $this->render('security/login.html.twig', [ // last username entered by the user (if any) 'last_username' => $helper->getLastUsername(), diff --git a/src/AppBundle/DataFixtures/ORM/PostFixtures.php b/src/AppBundle/DataFixtures/ORM/PostFixtures.php index d441bdf53..97e5642b9 100644 --- a/src/AppBundle/DataFixtures/ORM/PostFixtures.php +++ b/src/AppBundle/DataFixtures/ORM/PostFixtures.php @@ -47,6 +47,7 @@ public function load(ObjectManager $manager) $post->setTitle($title); $post->setSummary($this->getRandomPostSummary()); + // TODO: fix this 'slugger' call $post->setSlug($this->container->get('slugger')->slugify($post->getTitle())); $post->setContent($this->getPostContent()); // "References" are the way to share objects between fixtures defined diff --git a/src/AppBundle/EventListener/CommentNotificationListener.php b/src/AppBundle/EventListener/CommentNotificationSubscriber.php similarity index 91% rename from src/AppBundle/EventListener/CommentNotificationListener.php rename to src/AppBundle/EventListener/CommentNotificationSubscriber.php index 93b521906..0cc5f683d 100644 --- a/src/AppBundle/EventListener/CommentNotificationListener.php +++ b/src/AppBundle/EventListener/CommentNotificationSubscriber.php @@ -12,6 +12,7 @@ namespace AppBundle\EventListener; use AppBundle\Entity\Comment; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\GenericEvent; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Translation\TranslatorInterface; @@ -21,7 +22,7 @@ * * @author Oleg Voronkovich */ -class CommentNotificationListener +class CommentNotificationSubscriber implements EventSubscriberInterface { /** * @var \Swift_Mailer @@ -59,6 +60,13 @@ public function __construct(\Swift_Mailer $mailer, UrlGeneratorInterface $urlGen $this->sender = $sender; } + public static function getSubscribedEvents() + { + return [ + 'comment.created' => 'onCommentCreated', + ]; + } + /** * @param GenericEvent $event */ diff --git a/src/AppBundle/EventListener/RedirectToPreferredLocaleListener.php b/src/AppBundle/EventListener/RedirectToPreferredLocaleSubscriber.php similarity index 90% rename from src/AppBundle/EventListener/RedirectToPreferredLocaleListener.php rename to src/AppBundle/EventListener/RedirectToPreferredLocaleSubscriber.php index 35b5c2745..2d95dc25e 100644 --- a/src/AppBundle/EventListener/RedirectToPreferredLocaleListener.php +++ b/src/AppBundle/EventListener/RedirectToPreferredLocaleSubscriber.php @@ -11,8 +11,10 @@ namespace AppBundle\EventListener; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** @@ -23,7 +25,7 @@ * * @author Oleg Voronkovich */ -class RedirectToPreferredLocaleListener +class RedirectToPreferredLocaleSubscriber implements EventSubscriberInterface { /** * @var UrlGeneratorInterface @@ -71,6 +73,13 @@ public function __construct(UrlGeneratorInterface $urlGenerator, $locales, $defa $this->locales = array_unique($this->locales); } + public static function getSubscribedEvents() + { + return [ + KernelEvents::REQUEST => 'onKernelRequest', + ]; + } + /** * @param GetResponseEvent $event */ diff --git a/src/AppBundle/Form/Type/DateTimePickerType.php b/src/AppBundle/Form/Type/DateTimePickerType.php index 0c54dd89e..d1f8d996e 100644 --- a/src/AppBundle/Form/Type/DateTimePickerType.php +++ b/src/AppBundle/Form/Type/DateTimePickerType.php @@ -30,9 +30,9 @@ class DateTimePickerType extends AbstractType { private $formatConverter; - public function __construct() + public function __construct(MomentFormatConverter $converter) { - $this->formatConverter = new MomentFormatConverter(); + $this->formatConverter = $converter; } /** From e2b40f7a068d6fbd45e314f1784ca34ee725b74e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 22 May 2017 16:16:36 +0200 Subject: [PATCH 02/16] Changes suggested by reviewers --- app/config/config.yml | 2 +- app/config/services.yml | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/config/config.yml b/app/config/config.yml index 79d826695..4fd048074 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -44,7 +44,7 @@ framework: trusted_hosts: ~ 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: ~ diff --git a/app/config/services.yml b/app/config/services.yml index 4a78b9aae..fd057684e 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -15,7 +15,7 @@ services: resource: '../../src/AppBundle/*' # you can exclude directories or files # but if a service is unused, it's removed anyway - exclude: '../../src/AppBundle/{Entity,Repository}' + 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 @@ -40,7 +40,4 @@ services: $defaultLocale: '%locale%' Twig_Extensions_Extension_Intl: - public: false class: Twig_Extensions_Extension_Intl - tags: - - { name: twig.extension } From faf65d3d86e8b4c2f5702c8e045627a0a8fcde27 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 22 May 2017 16:38:37 +0200 Subject: [PATCH 03/16] Use DI features for commands too --- app/config/services.yml | 4 +++ src/AppBundle/Command/AddUserCommand.php | 35 ++++++++------------ src/AppBundle/Command/DeleteUserCommand.php | 21 ++++++------ src/AppBundle/Command/ListUsersCommand.php | 36 +++++++++------------ 4 files changed, 44 insertions(+), 52 deletions(-) diff --git a/app/config/services.yml b/app/config/services.yml index fd057684e..05062f57f 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -26,6 +26,10 @@ services: # 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%' diff --git a/src/AppBundle/Command/AddUserCommand.php b/src/AppBundle/Command/AddUserCommand.php index 0cfa0c3f3..e1e8050f0 100644 --- a/src/AppBundle/Command/AddUserCommand.php +++ b/src/AppBundle/Command/AddUserCommand.php @@ -12,13 +12,14 @@ namespace AppBundle\Command; use AppBundle\Entity\User; -use Doctrine\Common\Persistence\ObjectManager; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use Doctrine\ORM\EntityManagerInterface; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; +use Symfony\Component\Security\Core\Encoder\UserPasswordEncoder; /** * A command console that creates users and stores them in the database. @@ -39,14 +40,20 @@ * @author Javier Eguiluz * @author Yonel Ceruto */ -class AddUserCommand extends ContainerAwareCommand +class AddUserCommand extends Command { const MAX_ATTEMPTS = 5; - /** - * @var ObjectManager - */ private $entityManager; + private $passwordEncoder; + + public function __construct(EntityManagerInterface $em, UserPasswordEncoder $encoder) + { + parent::__construct(); + + $this->entityManager = $em; + $this->passwordEncoder = $encoder; + } /** * {@inheritdoc} @@ -68,19 +75,6 @@ protected function configure() ; } - /** - * This method is executed before the interact() and the execute() methods. - * It's main purpose is to initialize the variables used in the rest of the - * command methods. - * - * Beware that the input options and arguments are validated after executing - * the interact() method, so you can't blindly trust their values in this method. - */ - protected function initialize(InputInterface $input, OutputInterface $output) - { - $this->entityManager = $this->getContainer()->get('doctrine')->getManager(); - } - /** * This method is executed after initialize() and before execute(). Its purpose * is to check if some of the options/arguments are missing and interactively @@ -206,8 +200,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $user->setRoles([$isAdmin ? 'ROLE_ADMIN' : 'ROLE_USER']); // See https://symfony.com/doc/current/book/security.html#security-encoding-password - $encoder = $this->getContainer()->get('security.password_encoder'); - $encodedPassword = $encoder->encodePassword($user, $plainPassword); + $encodedPassword = $this->passwordEncoder->encodePassword($user, $plainPassword); $user->setPassword($encodedPassword); $this->entityManager->persist($user); diff --git a/src/AppBundle/Command/DeleteUserCommand.php b/src/AppBundle/Command/DeleteUserCommand.php index bf8e09c86..9e3c8eaf7 100644 --- a/src/AppBundle/Command/DeleteUserCommand.php +++ b/src/AppBundle/Command/DeleteUserCommand.php @@ -12,8 +12,8 @@ namespace AppBundle\Command; use AppBundle\Entity\User; -use Doctrine\Common\Persistence\ObjectManager; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use Doctrine\ORM\EntityManagerInterface; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -36,15 +36,19 @@ * * @author Oleg Voronkovich */ -class DeleteUserCommand extends ContainerAwareCommand +class DeleteUserCommand extends Command { const MAX_ATTEMPTS = 5; - /** - * @var ObjectManager - */ private $entityManager; + public function __construct(EntityManagerInterface $em) + { + parent::__construct(); + + $this->entityManager = $em; + } + /** * {@inheritdoc} */ @@ -67,11 +71,6 @@ protected function configure() ); } - protected function initialize(InputInterface $input, OutputInterface $output) - { - $this->entityManager = $this->getContainer()->get('doctrine')->getManager(); - } - protected function interact(InputInterface $input, OutputInterface $output) { if (null !== $input->getArgument('username')) { diff --git a/src/AppBundle/Command/ListUsersCommand.php b/src/AppBundle/Command/ListUsersCommand.php index 327a3b65c..0aac641fd 100644 --- a/src/AppBundle/Command/ListUsersCommand.php +++ b/src/AppBundle/Command/ListUsersCommand.php @@ -12,8 +12,8 @@ namespace AppBundle\Command; use AppBundle\Entity\User; -use Doctrine\Common\Persistence\ObjectManager; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use Doctrine\ORM\EntityManagerInterface; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -34,12 +34,19 @@ * * @author Javier Eguiluz */ -class ListUsersCommand extends ContainerAwareCommand +class ListUsersCommand extends Command { - /** - * @var ObjectManager - */ private $entityManager; + private $mailer; + + public function __construct(EntityManagerInterface $em, \Swift_Mailer $mailer, $emailSender) + { + parent::__construct(); + + $this->entityManager = $em; + $this->mailer = $mailer; + $this->emailSender = $emailSender; + } /** * {@inheritdoc} @@ -74,15 +81,6 @@ protected function configure() ; } - /** - * This method is executed before the the execute() method. It's main purpose - * is to initialize the variables used in the rest of the command methods. - */ - protected function initialize(InputInterface $input, OutputInterface $output) - { - $this->entityManager = $this->getContainer()->get('doctrine')->getManager(); - } - /** * This method is executed after initialize(). It usually contains the logic * to execute to complete this command task. @@ -133,15 +131,13 @@ protected function execute(InputInterface $input, OutputInterface $output) private function sendReport($contents, $recipient) { // See https://symfony.com/doc/current/cookbook/email/email.html - $mailer = $this->getContainer()->get('mailer'); - - $message = $mailer->createMessage() + $message = $this->mailer->createMessage() ->setSubject(sprintf('app:list-users report (%s)', date('Y-m-d H:i:s'))) - ->setFrom($this->getContainer()->getParameter('app.notifications.email_sender')) + ->setFrom($this->emailSender) ->setTo($recipient) ->setBody($contents, 'text/plain') ; - $mailer->send($message); + $this->mailer->send($message); } } From a718f1fc2a41371d74b21e47fbfc93dbdeba9c09 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 22 May 2017 16:55:56 +0200 Subject: [PATCH 04/16] Use single quotes in config.yml --- app/config/config.yml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/app/config/config.yml b/app/config/config.yml index 4fd048074..15302787c 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -30,50 +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: ~ session: handler_id: session.handler.native_file - save_path: "%kernel.project_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) @@ -83,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 } From 8447d8f930cd2c672b3958fec03a733964a8a0e7 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 22 May 2017 17:03:52 +0200 Subject: [PATCH 05/16] Used DI features in controllers --- .../Controller/Admin/BlogController.php | 31 ++++++++----------- src/AppBundle/Controller/BlogController.php | 21 +++++++------ 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/AppBundle/Controller/Admin/BlogController.php b/src/AppBundle/Controller/Admin/BlogController.php index edaf6c2dd..3ccd09534 100644 --- a/src/AppBundle/Controller/Admin/BlogController.php +++ b/src/AppBundle/Controller/Admin/BlogController.php @@ -14,12 +14,14 @@ use AppBundle\Entity\Post; use AppBundle\Form\PostType; use AppBundle\Utils\Slugger; +use Doctrine\ORM\EntityManagerInterface; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Security\Core\User\UserInterface; /** * Controller used to manage blog contents in the backend. @@ -53,10 +55,9 @@ class BlogController extends Controller * @Route("/", name="admin_post_index") * @Method("GET") */ - public function indexAction() + public function indexAction(EntityManagerInterface $em, UserInterface $user = null) { - $entityManager = $this->getDoctrine()->getManager(); - $posts = $entityManager->getRepository(Post::class)->findBy(['author' => $this->getUser()], ['publishedAt' => 'DESC']); + $posts = $em->getRepository(Post::class)->findBy(['author' => $user], ['publishedAt' => 'DESC']); return $this->render('admin/blog/index.html.twig', ['posts' => $posts]); } @@ -71,10 +72,10 @@ public function indexAction() * to constraint the HTTP methods each controller responds to (by default * it responds to all methods). */ - public function newAction(Request $request, Slugger $slugger) + public function newAction(Request $request, UserInterface $user = null, Slugger $slugger) { $post = new Post(); - $post->setAuthor($this->getUser()); + $post->setAuthor($user); // See https://symfony.com/doc/current/book/forms.html#submitting-forms-with-multiple-buttons $form = $this->createForm(PostType::class, $post) @@ -89,9 +90,8 @@ public function newAction(Request $request, Slugger $slugger) if ($form->isSubmitted() && $form->isValid()) { $post->setSlug($slugger->slugify($post->getTitle())); - $entityManager = $this->getDoctrine()->getManager(); - $entityManager->persist($post); - $entityManager->flush(); + $em->persist($post); + $em->flush(); // Flash messages are used to notify the user about the result of the // actions. They are deleted automatically from the session as soon @@ -135,19 +135,16 @@ public function showAction(Post $post) * @Route("/{id}/edit", requirements={"id": "\d+"}, name="admin_post_edit") * @Method({"GET", "POST"}) */ - public function editAction(Request $request, Post $post, Slugger $slugger) + public function editAction(Request $request, EntityManagerInterface $em, Post $post, Slugger $slugger) { $this->denyAccessUnlessGranted('edit', $post, 'Posts can only be edited by their authors.'); - $entityManager = $this->getDoctrine()->getManager(); - $form = $this->createForm(PostType::class, $post); - $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $post->setSlug($slugger->slugify($post->getTitle())); - $entityManager->flush(); + $em->flush(); $this->addFlash('success', 'post.updated_successfully'); @@ -170,21 +167,19 @@ public function editAction(Request $request, Post $post, Slugger $slugger) * The Security annotation value is an expression (if it evaluates to false, * the authorization mechanism will prevent the user accessing this resource). */ - public function deleteAction(Request $request, Post $post) + public function deleteAction(Request $request, EntityManagerInterface $em, Post $post) { if (!$this->isCsrfTokenValid('delete', $request->request->get('token'))) { return $this->redirectToRoute('admin_post_index'); } - $entityManager = $this->getDoctrine()->getManager(); - // Delete the tags associated with this blog post. This is done automatically // by Doctrine, except for SQLite (the database used in this application) // because foreign key support is not enabled by default in SQLite $post->getTags()->clear(); - $entityManager->remove($post); - $entityManager->flush(); + $em->remove($post); + $em->flush(); $this->addFlash('success', 'post.deleted_successfully'); diff --git a/src/AppBundle/Controller/BlogController.php b/src/AppBundle/Controller/BlogController.php index 38c42b03c..e203778fb 100644 --- a/src/AppBundle/Controller/BlogController.php +++ b/src/AppBundle/Controller/BlogController.php @@ -15,15 +15,19 @@ use AppBundle\Entity\Post; use AppBundle\Events; use AppBundle\Form\CommentType; +use Doctrine\ORM\EntityManagerInterface; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Symfony\Component\Security\Core\User\UserInterface; /** * Controller used to manage blog contents in the public part of the site. @@ -46,9 +50,9 @@ class BlogController extends Controller * Content-Type header for the response. * See https://symfony.com/doc/current/quick_tour/the_controller.html#using-formats */ - public function indexAction($page, $_format) + public function indexAction(EntityManagerInterface $em, $page, $_format) { - $posts = $this->getDoctrine()->getRepository(Post::class)->findLatest($page); + $posts = $em->getRepository(Post::class)->findLatest($page); // Every template name also has two extensions that specify the format and // engine for that template. @@ -65,7 +69,7 @@ public function indexAction($page, $_format) * value given in the route. * See https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html */ - public function postShowAction(Post $post) + public function postShowAction(Post $post, UserInterface $user = null) { // Symfony provides a function called 'dump()' which is an improved version // of the 'var_dump()' function. It's useful to quickly debug the contents @@ -74,7 +78,7 @@ public function postShowAction(Post $post) // This function can be used both in PHP files and Twig templates. The only // requirement is to have enabled the DebugBundle. if ('dev' === $this->getParameter('kernel.environment')) { - dump($post, $this->get('security.token_storage')->getToken()->getUser(), new \DateTime()); + dump($post, $user, new \DateTime()); } return $this->render('blog/post_show.html.twig', ['post' => $post]); @@ -90,7 +94,7 @@ public function postShowAction(Post $post) * (postSlug) doesn't match any of the Doctrine entity properties (slug). * See https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html#doctrine-converter */ - public function commentNewAction(Request $request, Post $post) + public function commentNewAction(Request $request, Post $post, EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher) { $comment = new Comment(); $comment->setAuthor($this->getUser()); @@ -102,9 +106,8 @@ public function commentNewAction(Request $request, Post $post) $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $entityManager = $this->getDoctrine()->getManager(); - $entityManager->persist($comment); - $entityManager->flush(); + $em->persist($comment); + $em->flush(); // When triggering an event, you can optionally pass some information. // For simple applications, use the GenericEvent object provided by Symfony @@ -118,7 +121,7 @@ public function commentNewAction(Request $request, Post $post) // passed in the event and they can even modify the execution flow, so // there's no guarantee that the rest of this controller will be executed. // See https://symfony.com/doc/current/components/event_dispatcher.html - $this->get('event_dispatcher')->dispatch(Events::COMMENT_CREATED, $event); + $eventDispatcher->dispatch(Events::COMMENT_CREATED, $event); return $this->redirectToRoute('blog_post', ['slug' => $post->getSlug()]); } From 73ec12f8be4992879d451d644dea9bc95920fc99 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 24 May 2017 15:50:16 +0200 Subject: [PATCH 06/16] Added missing $em injection --- src/AppBundle/Controller/Admin/BlogController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppBundle/Controller/Admin/BlogController.php b/src/AppBundle/Controller/Admin/BlogController.php index 3ccd09534..9a4fff322 100644 --- a/src/AppBundle/Controller/Admin/BlogController.php +++ b/src/AppBundle/Controller/Admin/BlogController.php @@ -72,7 +72,7 @@ public function indexAction(EntityManagerInterface $em, UserInterface $user = nu * to constraint the HTTP methods each controller responds to (by default * it responds to all methods). */ - public function newAction(Request $request, UserInterface $user = null, Slugger $slugger) + public function newAction(Request $request, EntityManagerInterface $em, UserInterface $user = null, Slugger $slugger) { $post = new Post(); $post->setAuthor($user); From 6149f6187b56ad3049613f2ae55755c41ba827ec Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 24 May 2017 15:52:42 +0200 Subject: [PATCH 07/16] Added a missing property declaration --- src/AppBundle/Command/ListUsersCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/AppBundle/Command/ListUsersCommand.php b/src/AppBundle/Command/ListUsersCommand.php index 0aac641fd..f19791762 100644 --- a/src/AppBundle/Command/ListUsersCommand.php +++ b/src/AppBundle/Command/ListUsersCommand.php @@ -38,6 +38,7 @@ class ListUsersCommand extends Command { private $entityManager; private $mailer; + private $emailSender; public function __construct(EntityManagerInterface $em, \Swift_Mailer $mailer, $emailSender) { From 5226a1eb6c3c9c4c5b5f8aba47bfee009f58bf77 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 24 May 2017 15:55:23 +0200 Subject: [PATCH 08/16] Enable the linter of translation files --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0e29c036b..7abec01fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 # 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 From cec08f3639c95c3d522a8004a5c765012512cdf8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 25 May 2017 09:30:58 +0200 Subject: [PATCH 09/16] Fixed tests --- tests/AppBundle/Command/AddUserCommandTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/AppBundle/Command/AddUserCommandTest.php b/tests/AppBundle/Command/AddUserCommandTest.php index 6424f98cb..6c67f0619 100644 --- a/tests/AppBundle/Command/AddUserCommandTest.php +++ b/tests/AppBundle/Command/AddUserCommandTest.php @@ -103,7 +103,8 @@ private function executeCommand(array $arguments, array $inputs = []) { self::bootKernel(); - $command = new AddUserCommand(); + $container = self::$kernel->getContainer(); + $command = new AddUserCommand($container->get('doctrine')->getManager(), $container->get('security.password_encoder')); $command->setApplication(new Application(self::$kernel)); $commandTester = new CommandTester($command); From 64b57bcf08e41c3d88ffdef0b8862dcc92ab5edb Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 25 May 2017 09:44:36 +0200 Subject: [PATCH 10/16] Fixed a CS issue --- src/AppBundle/Controller/BlogController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/AppBundle/Controller/BlogController.php b/src/AppBundle/Controller/BlogController.php index e203778fb..9e6100e7d 100644 --- a/src/AppBundle/Controller/BlogController.php +++ b/src/AppBundle/Controller/BlogController.php @@ -26,7 +26,6 @@ use Symfony\Component\EventDispatcher\GenericEvent; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\User\UserInterface; /** From b04612853b53f994791d26dd60f5c64e1329c889 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 26 May 2017 11:56:26 +0200 Subject: [PATCH 11/16] Removed a TODO messages because this won't be changed --- src/AppBundle/DataFixtures/ORM/PostFixtures.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/AppBundle/DataFixtures/ORM/PostFixtures.php b/src/AppBundle/DataFixtures/ORM/PostFixtures.php index 97e5642b9..d441bdf53 100644 --- a/src/AppBundle/DataFixtures/ORM/PostFixtures.php +++ b/src/AppBundle/DataFixtures/ORM/PostFixtures.php @@ -47,7 +47,6 @@ public function load(ObjectManager $manager) $post->setTitle($title); $post->setSummary($this->getRandomPostSummary()); - // TODO: fix this 'slugger' call $post->setSlug($this->container->get('slugger')->slugify($post->getTitle())); $post->setContent($this->getPostContent()); // "References" are the way to share objects between fixtures defined From 573ddda16715571b0763cf5ea3c8bd72b39dfc5b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 26 May 2017 17:15:33 +0200 Subject: [PATCH 12/16] Reverted some autowired arguments --- app/config/services.yml | 4 ++-- composer.json | 2 +- composer.lock | 22 +++++++++++-------- .../Controller/Admin/BlogController.php | 17 ++++++++------ src/AppBundle/Controller/BlogController.php | 12 +++++----- 5 files changed, 32 insertions(+), 25 deletions(-) diff --git a/app/config/services.yml b/app/config/services.yml index 05062f57f..88a6af5ba 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -43,5 +43,5 @@ services: $locales: '%app_locales%' $defaultLocale: '%locale%' - Twig_Extensions_Extension_Intl: - class: Twig_Extensions_Extension_Intl + + Twig\Extensions\IntlExtension: ~ diff --git a/composer.json b/composer.json index 092e3f2c6..a59814642 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "symfony/polyfill-apcu" : "^1.0", "symfony/swiftmailer-bundle" : "^2.3", "symfony/symfony" : "3.3.0-RC1", - "twig/extensions" : "^1.3", + "twig/extensions" : "^1.5", "twig/twig" : "^1.28 || ^2.0", "white-october/pagerfanta-bundle" : "^1.0" }, diff --git a/composer.lock b/composer.lock index 76f365681..4cb58c517 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "9dedbfbff97aaca348e937cf124f55b3", + "content-hash": "d5a37bc6b067ad03bda45a809f62b03f", "packages": [ { "name": "composer/ca-bundle", @@ -2457,23 +2457,24 @@ }, { "name": "twig/extensions", - "version": "v1.4.1", + "version": "v1.5.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig-extensions.git", - "reference": "f0bb8431c8691f5a39f1017d9a5967a082bf01ff" + "reference": "d6d74d6f3213a9574c460c4390c25a1a67c17cc3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig-extensions/zipball/f0bb8431c8691f5a39f1017d9a5967a082bf01ff", - "reference": "f0bb8431c8691f5a39f1017d9a5967a082bf01ff", + "url": "https://api.github.com/repos/twigphp/Twig-extensions/zipball/d6d74d6f3213a9574c460c4390c25a1a67c17cc3", + "reference": "d6d74d6f3213a9574c460c4390c25a1a67c17cc3", "shasum": "" }, "require": { - "twig/twig": "~1.20|~2.0" + "twig/twig": "~1.27|~2.0" }, "require-dev": { - "symfony/translation": "~2.3" + "symfony/phpunit-bridge": "~3.3@dev", + "symfony/translation": "~2.3|~3.0" }, "suggest": { "symfony/translation": "Allow the time_diff output to be translated" @@ -2481,12 +2482,15 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "1.5-dev" } }, "autoload": { "psr-0": { "Twig_Extensions_": "lib/" + }, + "psr-4": { + "Twig\\Extensions\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -2505,7 +2509,7 @@ "i18n", "text" ], - "time": "2016-10-25T17:34:14+00:00" + "time": "2017-05-24T06:24:07+00:00" }, { "name": "twig/twig", diff --git a/src/AppBundle/Controller/Admin/BlogController.php b/src/AppBundle/Controller/Admin/BlogController.php index 9a4fff322..db73af154 100644 --- a/src/AppBundle/Controller/Admin/BlogController.php +++ b/src/AppBundle/Controller/Admin/BlogController.php @@ -55,9 +55,10 @@ class BlogController extends Controller * @Route("/", name="admin_post_index") * @Method("GET") */ - public function indexAction(EntityManagerInterface $em, UserInterface $user = null) + public function indexAction() { - $posts = $em->getRepository(Post::class)->findBy(['author' => $user], ['publishedAt' => 'DESC']); + $em = $this->getDoctrine()->getManager(); + $posts = $em->getRepository(Post::class)->findBy(['author' => $this->getUser()], ['publishedAt' => 'DESC']); return $this->render('admin/blog/index.html.twig', ['posts' => $posts]); } @@ -72,10 +73,10 @@ public function indexAction(EntityManagerInterface $em, UserInterface $user = nu * to constraint the HTTP methods each controller responds to (by default * it responds to all methods). */ - public function newAction(Request $request, EntityManagerInterface $em, UserInterface $user = null, Slugger $slugger) + public function newAction(Request $request, Slugger $slugger) { $post = new Post(); - $post->setAuthor($user); + $post->setAuthor($this->getUser()); // See https://symfony.com/doc/current/book/forms.html#submitting-forms-with-multiple-buttons $form = $this->createForm(PostType::class, $post) @@ -90,6 +91,7 @@ public function newAction(Request $request, EntityManagerInterface $em, UserInte if ($form->isSubmitted() && $form->isValid()) { $post->setSlug($slugger->slugify($post->getTitle())); + $em = $this->getDoctrine()->getManager(); $em->persist($post); $em->flush(); @@ -135,7 +137,7 @@ public function showAction(Post $post) * @Route("/{id}/edit", requirements={"id": "\d+"}, name="admin_post_edit") * @Method({"GET", "POST"}) */ - public function editAction(Request $request, EntityManagerInterface $em, Post $post, Slugger $slugger) + public function editAction(Request $request, Post $post, Slugger $slugger) { $this->denyAccessUnlessGranted('edit', $post, 'Posts can only be edited by their authors.'); @@ -144,7 +146,7 @@ public function editAction(Request $request, EntityManagerInterface $em, Post $p if ($form->isSubmitted() && $form->isValid()) { $post->setSlug($slugger->slugify($post->getTitle())); - $em->flush(); + $this->getDoctrine()->getManager()->flush(); $this->addFlash('success', 'post.updated_successfully'); @@ -167,7 +169,7 @@ public function editAction(Request $request, EntityManagerInterface $em, Post $p * The Security annotation value is an expression (if it evaluates to false, * the authorization mechanism will prevent the user accessing this resource). */ - public function deleteAction(Request $request, EntityManagerInterface $em, Post $post) + public function deleteAction(Request $request, Post $post) { if (!$this->isCsrfTokenValid('delete', $request->request->get('token'))) { return $this->redirectToRoute('admin_post_index'); @@ -178,6 +180,7 @@ public function deleteAction(Request $request, EntityManagerInterface $em, Post // because foreign key support is not enabled by default in SQLite $post->getTags()->clear(); + $em = $this->getDoctrine()->getManager(); $em->remove($post); $em->flush(); diff --git a/src/AppBundle/Controller/BlogController.php b/src/AppBundle/Controller/BlogController.php index 9e6100e7d..bbcc689de 100644 --- a/src/AppBundle/Controller/BlogController.php +++ b/src/AppBundle/Controller/BlogController.php @@ -49,8 +49,9 @@ class BlogController extends Controller * Content-Type header for the response. * See https://symfony.com/doc/current/quick_tour/the_controller.html#using-formats */ - public function indexAction(EntityManagerInterface $em, $page, $_format) + public function indexAction($page, $_format) { + $em = $this->getDoctrine()->getManager(); $posts = $em->getRepository(Post::class)->findLatest($page); // Every template name also has two extensions that specify the format and @@ -68,7 +69,7 @@ public function indexAction(EntityManagerInterface $em, $page, $_format) * value given in the route. * See https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html */ - public function postShowAction(Post $post, UserInterface $user = null) + public function postShowAction(Post $post) { // Symfony provides a function called 'dump()' which is an improved version // of the 'var_dump()' function. It's useful to quickly debug the contents @@ -77,7 +78,7 @@ public function postShowAction(Post $post, UserInterface $user = null) // This function can be used both in PHP files and Twig templates. The only // requirement is to have enabled the DebugBundle. if ('dev' === $this->getParameter('kernel.environment')) { - dump($post, $user, new \DateTime()); + dump($post, $this->getUser(), new \DateTime()); } return $this->render('blog/post_show.html.twig', ['post' => $post]); @@ -93,18 +94,17 @@ public function postShowAction(Post $post, UserInterface $user = null) * (postSlug) doesn't match any of the Doctrine entity properties (slug). * See https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html#doctrine-converter */ - public function commentNewAction(Request $request, Post $post, EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher) + public function commentNewAction(Request $request, Post $post, EventDispatcherInterface $eventDispatcher) { $comment = new Comment(); $comment->setAuthor($this->getUser()); - $post->addComment($comment); $form = $this->createForm(CommentType::class, $comment); - $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); $em->persist($comment); $em->flush(); From 0d82f42972d5f4edb669153410d4b6140facf6ba Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 26 May 2017 17:16:52 +0200 Subject: [PATCH 13/16] Used the event name constant --- src/AppBundle/EventListener/CommentNotificationSubscriber.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/AppBundle/EventListener/CommentNotificationSubscriber.php b/src/AppBundle/EventListener/CommentNotificationSubscriber.php index 0cc5f683d..8ae7de977 100644 --- a/src/AppBundle/EventListener/CommentNotificationSubscriber.php +++ b/src/AppBundle/EventListener/CommentNotificationSubscriber.php @@ -12,6 +12,7 @@ namespace AppBundle\EventListener; use AppBundle\Entity\Comment; +use AppBundle\Events; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\GenericEvent; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; @@ -63,7 +64,7 @@ public function __construct(\Swift_Mailer $mailer, UrlGeneratorInterface $urlGen public static function getSubscribedEvents() { return [ - 'comment.created' => 'onCommentCreated', + Events::COMMENT_CREATED => 'onCommentCreated', ]; } From a71756ba0599ee489dfbcc68873a87135049d855 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 30 May 2017 08:54:53 +0200 Subject: [PATCH 14/16] Updated to 3.3.0 final --- composer.json | 2 +- composer.lock | 165 ++++++++++++++++++++++-------------- var/SymfonyRequirements.php | 6 -- web/config.php | 2 +- 4 files changed, 104 insertions(+), 71 deletions(-) diff --git a/composer.json b/composer.json index a59814642..1de49445a 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "symfony/monolog-bundle" : "^3.0", "symfony/polyfill-apcu" : "^1.0", "symfony/swiftmailer-bundle" : "^2.3", - "symfony/symfony" : "3.3.0-RC1", + "symfony/symfony" : "^3.3", "twig/extensions" : "^1.5", "twig/twig" : "^1.28 || ^2.0", "white-october/pagerfanta-bundle" : "^1.0" diff --git a/composer.lock b/composer.lock index 4cb58c517..cf8759aa4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "d5a37bc6b067ad03bda45a809f62b03f", + "content-hash": "746cbb988fffb23fbb88c44470958d5d", "packages": [ { "name": "composer/ca-bundle", @@ -472,37 +472,37 @@ }, { "name": "doctrine/doctrine-bundle", - "version": "1.6.7", + "version": "1.6.8", "source": { "type": "git", "url": "https://github.com/doctrine/DoctrineBundle.git", - "reference": "a01d99bc6c9a6c8a8ace0012690099dd957ce9b9" + "reference": "6e96577cbbdbb5b6dcca2ff203d665976b51beb0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/a01d99bc6c9a6c8a8ace0012690099dd957ce9b9", - "reference": "a01d99bc6c9a6c8a8ace0012690099dd957ce9b9", + "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/6e96577cbbdbb5b6dcca2ff203d665976b51beb0", + "reference": "6e96577cbbdbb5b6dcca2ff203d665976b51beb0", "shasum": "" }, "require": { "doctrine/dbal": "~2.3", - "doctrine/doctrine-cache-bundle": "~1.0", + "doctrine/doctrine-cache-bundle": "~1.2", "jdorn/sql-formatter": "~1.1", "php": ">=5.5.9", - "symfony/console": "~2.7|~3.0", - "symfony/dependency-injection": "~2.7|~3.0", - "symfony/doctrine-bridge": "~2.7|~3.0", - "symfony/framework-bundle": "~2.7|~3.0" + "symfony/console": "~2.7|~3.0|~4.0", + "symfony/dependency-injection": "~2.7|~3.0|~4.0", + "symfony/doctrine-bridge": "~2.7|~3.0|~4.0", + "symfony/framework-bundle": "~2.7|~3.0|~4.0" }, "require-dev": { "doctrine/orm": "~2.3", "phpunit/phpunit": "~4", "satooshi/php-coveralls": "^1.0", - "symfony/phpunit-bridge": "~2.7|~3.0", - "symfony/property-info": "~2.8|~3.0", - "symfony/validator": "~2.7|~3.0", - "symfony/yaml": "~2.7|~3.0", - "twig/twig": "~1.10|~2.0" + "symfony/phpunit-bridge": "~2.7|~3.0|~4.0", + "symfony/property-info": "~2.8|~3.0|~4.0", + "symfony/validator": "~2.7|~3.0|~4.0", + "symfony/yaml": "~2.7|~3.0|~4.0", + "twig/twig": "~1.12|~2.0" }, "suggest": { "doctrine/orm": "The Doctrine ORM integration is optional in the bundle.", @@ -549,7 +549,7 @@ "orm", "persistence" ], - "time": "2017-01-16T12:01:26+00:00" + "time": "2017-05-18T08:15:18+00:00" }, { "name": "doctrine/doctrine-cache-bundle", @@ -1627,16 +1627,16 @@ }, { "name": "sensio/distribution-bundle", - "version": "v5.0.19", + "version": "v5.0.20", "source": { "type": "git", "url": "https://github.com/sensiolabs/SensioDistributionBundle.git", - "reference": "654c4fa3d11448c8005400a244987896243a990a" + "reference": "4b019d4c0bd64438c42e4b6b0726085b409be8d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sensiolabs/SensioDistributionBundle/zipball/654c4fa3d11448c8005400a244987896243a990a", - "reference": "654c4fa3d11448c8005400a244987896243a990a", + "url": "https://api.github.com/repos/sensiolabs/SensioDistributionBundle/zipball/4b019d4c0bd64438c42e4b6b0726085b409be8d9", + "reference": "4b019d4c0bd64438c42e4b6b0726085b409be8d9", "shasum": "" }, "require": { @@ -1675,20 +1675,20 @@ "configuration", "distribution" ], - "time": "2017-04-23T22:28:23+00:00" + "time": "2017-05-11T16:21:03+00:00" }, { "name": "sensio/framework-extra-bundle", - "version": "v3.0.25", + "version": "v3.0.26", "source": { "type": "git", "url": "https://github.com/sensiolabs/SensioFrameworkExtraBundle.git", - "reference": "472b339cf0c82f3a033b29f85d9d9cada3cd1a9c" + "reference": "6d6cbe971554f0a2cc84965850481eb04a2a0059" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/472b339cf0c82f3a033b29f85d9d9cada3cd1a9c", - "reference": "472b339cf0c82f3a033b29f85d9d9cada3cd1a9c", + "url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/6d6cbe971554f0a2cc84965850481eb04a2a0059", + "reference": "6d6cbe971554f0a2cc84965850481eb04a2a0059", "shasum": "" }, "require": { @@ -1745,7 +1745,7 @@ "annotations", "controllers" ], - "time": "2017-03-21T23:34:44+00:00" + "time": "2017-05-11T17:01:57+00:00" }, { "name": "sensiolabs/security-checker", @@ -2245,21 +2245,21 @@ }, { "name": "symfony/swiftmailer-bundle", - "version": "v2.5.4", + "version": "v2.6.2", "source": { "type": "git", "url": "https://github.com/symfony/swiftmailer-bundle.git", - "reference": "8ab32ce31a7156621fb92e0466586186beb89759" + "reference": "deabc81120c2086571f7c4484ab785c5e1b84f75" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/swiftmailer-bundle/zipball/8ab32ce31a7156621fb92e0466586186beb89759", - "reference": "8ab32ce31a7156621fb92e0466586186beb89759", + "url": "https://api.github.com/repos/symfony/swiftmailer-bundle/zipball/deabc81120c2086571f7c4484ab785c5e1b84f75", + "reference": "deabc81120c2086571f7c4484ab785c5e1b84f75", "shasum": "" }, "require": { "php": ">=5.3.2", - "swiftmailer/swiftmailer": ">=4.2.0,~5.0", + "swiftmailer/swiftmailer": "~4.2|~5.0", "symfony/config": "~2.7|~3.0", "symfony/dependency-injection": "~2.7|~3.0", "symfony/http-kernel": "~2.7|~3.0" @@ -2267,7 +2267,7 @@ "require-dev": { "symfony/console": "~2.7|~3.0", "symfony/framework-bundle": "~2.7|~3.0", - "symfony/phpunit-bridge": "~2.7|~3.0", + "symfony/phpunit-bridge": "~3.3@dev", "symfony/yaml": "~2.7|~3.0" }, "suggest": { @@ -2276,7 +2276,7 @@ "type": "symfony-bundle", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -2300,20 +2300,20 @@ ], "description": "Symfony SwiftmailerBundle", "homepage": "http://symfony.com", - "time": "2017-03-21T21:47:36+00:00" + "time": "2017-05-22T04:58:24+00:00" }, { "name": "symfony/symfony", - "version": "v3.3.0-RC1", + "version": "v3.3.0", "source": { "type": "git", "url": "https://github.com/symfony/symfony.git", - "reference": "a66d56bfde7edd0f3b9e2857131561348234832b" + "reference": "5a7e31c48e7cd4831efa409fffb661beb9995174" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/symfony/zipball/a66d56bfde7edd0f3b9e2857131561348234832b", - "reference": "a66d56bfde7edd0f3b9e2857131561348234832b", + "url": "https://api.github.com/repos/symfony/symfony/zipball/5a7e31c48e7cd4831efa409fffb661beb9995174", + "reference": "5a7e31c48e7cd4831efa409fffb661beb9995174", "shasum": "" }, "require": { @@ -2453,7 +2453,7 @@ "keywords": [ "framework" ], - "time": "2017-05-17T18:10:19+00:00" + "time": "2017-05-29T21:02:32+00:00" }, { "name": "twig/extensions", @@ -2683,21 +2683,23 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v2.2.3", + "version": "v2.2.4", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "8f33cf3da0da94b67b9cd696b2b9dda81c928f72" + "reference": "5191e01d0fa0f579eb709350306cd11ad6427ca6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/8f33cf3da0da94b67b9cd696b2b9dda81c928f72", - "reference": "8f33cf3da0da94b67b9cd696b2b9dda81c928f72", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/5191e01d0fa0f579eb709350306cd11ad6427ca6", + "reference": "5191e01d0fa0f579eb709350306cd11ad6427ca6", "shasum": "" }, "require": { "doctrine/annotations": "^1.2", + "ext-json": "*", "ext-tokenizer": "*", + "gecko-packages/gecko-php-unit": "^2.0", "php": "^5.3.6 || >=7.0 <7.2", "sebastian/diff": "^1.4", "symfony/console": "^2.4 || ^3.0", @@ -2716,9 +2718,9 @@ "hhvm": "<3.18" }, "require-dev": { - "gecko-packages/gecko-php-unit": "^2.0", + "johnkary/phpunit-speedtrap": "^1.0.1", "justinrainbow/json-schema": "^5.0", - "phpunit/phpunit": "^4.5 || ^5.0", + "phpunit/phpunit": "^4.8.35 || ^5.4.3", "satooshi/php-coveralls": "^1.0", "symfony/phpunit-bridge": "^3.2.2" }, @@ -2756,7 +2758,46 @@ } ], "description": "A tool to automatically fix PHP code style", - "time": "2017-04-25T20:39:28+00:00" + "time": "2017-05-24T21:55:27+00:00" + }, + { + "name": "gecko-packages/gecko-php-unit", + "version": "v2.0", + "source": { + "type": "git", + "url": "https://github.com/GeckoPackages/GeckoPHPUnit.git", + "reference": "40a697ec261f3526e8196363b481b24383740c13" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GeckoPackages/GeckoPHPUnit/zipball/40a697ec261f3526e8196363b481b24383740c13", + "reference": "40a697ec261f3526e8196363b481b24383740c13", + "shasum": "" + }, + "require": { + "php": "^5.3.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "GeckoPackages\\PHPUnit\\": "src\\PHPUnit" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Additional PHPUnit tests.", + "homepage": "https://github.com/GeckoPackages", + "keywords": [ + "extension", + "filesystem", + "phpunit" + ], + "time": "2016-11-22T11:01:27+00:00" }, { "name": "ircmaxell/password-compat", @@ -3451,23 +3492,23 @@ }, { "name": "sebastian/diff", - "version": "1.4.1", + "version": "1.4.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.8" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" }, "type": "library", "extra": { @@ -3499,7 +3540,7 @@ "keywords": [ "diff" ], - "time": "2015-12-08T07:14:41+00:00" + "time": "2017-05-22T07:24:03+00:00" }, { "name": "sebastian/environment", @@ -3813,23 +3854,23 @@ }, { "name": "symfony/phpunit-bridge", - "version": "v3.2.8", + "version": "v3.3.0", "source": { "type": "git", "url": "https://github.com/symfony/phpunit-bridge.git", - "reference": "00916603c524b8048906de460b7ea0dfa1651281" + "reference": "1a09124ea479cca85fc66a6f21e59aa952ebed1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/00916603c524b8048906de460b7ea0dfa1651281", - "reference": "00916603c524b8048906de460b7ea0dfa1651281", + "url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/1a09124ea479cca85fc66a6f21e59aa952ebed1f", + "reference": "1a09124ea479cca85fc66a6f21e59aa952ebed1f", "shasum": "" }, "require": { "php": ">=5.3.3" }, "conflict": { - "phpunit/phpunit": ">=6.0" + "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0" }, "suggest": { "ext-zip": "Zip support is required when using bin/simple-phpunit", @@ -3841,7 +3882,7 @@ "type": "symfony-bridge", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "3.3-dev" } }, "autoload": { @@ -3871,7 +3912,7 @@ ], "description": "Symfony PHPUnit Bridge", "homepage": "https://symfony.com", - "time": "2017-04-12T14:13:17+00:00" + "time": "2017-05-28T11:10:04+00:00" }, { "name": "symfony/polyfill-php54", @@ -4098,9 +4139,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "symfony/symfony": 5 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/var/SymfonyRequirements.php b/var/SymfonyRequirements.php index 7e7a99de9..3b14a4022 100644 --- a/var/SymfonyRequirements.php +++ b/var/SymfonyRequirements.php @@ -633,12 +633,6 @@ function_exists('mb_strlen'), 'Install and enable the mbstring extension.' ); - $this->addRecommendation( - function_exists('iconv'), - 'iconv() should be available', - 'Install and enable the iconv extension.' - ); - $this->addRecommendation( function_exists('utf8_decode'), 'utf8_decode() should be available', diff --git a/web/config.php b/web/config.php index 69df43cf7..fd7e17e6b 100644 --- a/web/config.php +++ b/web/config.php @@ -11,7 +11,7 @@ */ if (!isset($_SERVER['HTTP_HOST'])) { - exit('This script cannot be run from the CLI. Run it from a browser.'); + exit("This script cannot be run from the CLI. Run it from a browser.\n"); } if (!in_array(@$_SERVER['REMOTE_ADDR'], array( From 927920ab0426e41fa227eaa49af24bf055bc0d86 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 30 May 2017 09:27:05 +0200 Subject: [PATCH 15/16] Added a minor help note --- app/config/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/services.yml b/app/config/services.yml index 88a6af5ba..5da4664dc 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -43,5 +43,5 @@ services: $locales: '%app_locales%' $defaultLocale: '%locale%' - + # needed for the localizeddate Twig filter Twig\Extensions\IntlExtension: ~ From c94a06abe1343cb08cd7bc5ffc645ebfe4719c51 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 30 May 2017 09:53:31 +0200 Subject: [PATCH 16/16] Removed unused imports --- src/AppBundle/Controller/Admin/BlogController.php | 2 -- src/AppBundle/Controller/BlogController.php | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/AppBundle/Controller/Admin/BlogController.php b/src/AppBundle/Controller/Admin/BlogController.php index db73af154..ceffe9372 100644 --- a/src/AppBundle/Controller/Admin/BlogController.php +++ b/src/AppBundle/Controller/Admin/BlogController.php @@ -14,14 +14,12 @@ use AppBundle\Entity\Post; use AppBundle\Form\PostType; use AppBundle\Utils\Slugger; -use Doctrine\ORM\EntityManagerInterface; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Security\Core\User\UserInterface; /** * Controller used to manage blog contents in the backend. diff --git a/src/AppBundle/Controller/BlogController.php b/src/AppBundle/Controller/BlogController.php index bbcc689de..7bce8958f 100644 --- a/src/AppBundle/Controller/BlogController.php +++ b/src/AppBundle/Controller/BlogController.php @@ -15,7 +15,6 @@ use AppBundle\Entity\Post; use AppBundle\Events; use AppBundle\Form\CommentType; -use Doctrine\ORM\EntityManagerInterface; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; @@ -26,7 +25,6 @@ use Symfony\Component\EventDispatcher\GenericEvent; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Security\Core\User\UserInterface; /** * Controller used to manage blog contents in the public part of the site.