-
Notifications
You must be signed in to change notification settings - Fork 184
Add support of Symfony 3 and drop support for Symfony < 2.7 #289
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,45 @@ | ||
| language: php | ||
|
|
||
| php: | ||
| - 5.3 | ||
| - 5.4 | ||
| - 5.5 | ||
| - 5.6 | ||
| - hhvm | ||
| sudo: false | ||
|
|
||
| env: | ||
| - SYMFONY_VERSION=2.1.* | ||
| - SYMFONY_VERSION=2.2.* | ||
| - SYMFONY_VERSION=2.3.* | ||
| - SYMFONY_VERSION=dev-master | ||
| branches: | ||
| only: | ||
| - master | ||
|
|
||
| matrix: | ||
| include: | ||
| - php: 5.3 | ||
| env: | ||
| - deps=low | ||
| - SYMFONY_VERSION=2.7.* | ||
| - php: 5.4 | ||
| env: | ||
| - deps=high | ||
| - SYMFONY_VERSION=2.7.* | ||
| - php: 5.5 | ||
| env: | ||
| - deps=low | ||
| - SYMFONY_VERSION=2.8.* | ||
| - php: 5.6 | ||
| env: | ||
| - deps=high | ||
| - SYMFONY_VERSION=3.0.* | ||
| - php: 7.0 | ||
| env: | ||
| - deps=low | ||
| - SYMFONY_VERSION=3.1.* | ||
| - php: 7.1 | ||
| env: | ||
| - deps=high | ||
| - SYMFONY_VERSION=3.1.* | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we actually need to test each version one by one? Imo as both php and symfony has a bc policy, we can only test the lowest and highest version of each major (php 5.3/sf 2.7/sf 3.0, php 7.1/sf 2./sf 3.).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PHP BC policy is quite messy and not really followed (see 7.1 BC breaks, and proposals for 7.2). I want to test every PHP version, I think it's more future-proof (and it does not add much overhead, it's done by Travis :) ). And if I test all the PHP versions, why not test the different Symfony versions as well? It's still a much lighter configuration than before, but test most of the cases.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We know more or less which php versions are bc (so you could remove 5.4, 5.5 and 5.6 for example).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with this argument, but for the moment the test suite run in less than 2 minutes. I think we should consider optimizing it if we need faster builds when we have a real test suite :) . |
||
|
|
||
| before_script: | ||
| - composer require symfony/framework-bundle:${SYMFONY_VERSION} --no-update | ||
| - composer update --dev | ||
| - if [[ $deps = high ]]; then composer update --no-progress --ansi; fi | ||
| - if [[ $deps = low ]]; then composer update --no-progress --ansi --prefer-lowest --prefer-stable; fi | ||
|
|
||
| script: phpunit --coverage-text | ||
|
|
||
| notifications: | ||
| email: | ||
| - friendsofsymfony-dev@googlegroups.com | ||
|
|
||
| matrix: | ||
| allow_failures: | ||
| - env: SYMFONY_VERSION=dev-master | ||
| - php: 5.6 | ||
| - php: hhvm | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,19 @@ | |
|
|
||
| namespace FOS\MessageBundle\Controller; | ||
|
|
||
| use Symfony\Component\DependencyInjection\ContainerAware; | ||
| use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||
| use Symfony\Component\HttpFoundation\RedirectResponse; | ||
| use FOS\MessageBundle\Provider\ProviderInterface; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
|
|
||
| class MessageController extends ContainerAware | ||
| class MessageController implements ContainerAwareInterface | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only bc break, should it be described in a UPGRADING file?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I will do that. |
||
| { | ||
| /** | ||
| * @var ContainerInterface | ||
| */ | ||
| protected $container; | ||
|
|
||
| /** | ||
| * Displays the authenticated participant inbox | ||
| * | ||
|
|
@@ -55,7 +61,7 @@ public function deletedAction() | |
| * Displays a thread, also allows to reply to it | ||
| * | ||
| * @param string $threadId the thread id | ||
| * | ||
| * | ||
| * @return Response | ||
| */ | ||
| public function threadAction($threadId) | ||
|
|
@@ -100,9 +106,9 @@ public function newThreadAction() | |
|
|
||
| /** | ||
| * Deletes a thread | ||
| * | ||
| * | ||
| * @param string $threadId the thread id | ||
| * | ||
| * | ||
| * @return RedirectResponse | ||
| */ | ||
| public function deleteAction($threadId) | ||
|
|
@@ -116,9 +122,9 @@ public function deleteAction($threadId) | |
|
|
||
| /** | ||
| * Undeletes a thread | ||
| * | ||
| * | ||
| * @param string $threadId | ||
| * | ||
| * | ||
| * @return RedirectResponse | ||
| */ | ||
| public function undeleteAction($threadId) | ||
|
|
@@ -155,4 +161,12 @@ protected function getProvider() | |
| { | ||
| return $this->container->get('fos_message.provider'); | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function setContainer(ContainerInterface $container = null) | ||
| { | ||
| $this->container = $container; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| namespace FOS\MessageBundle\DependencyInjection; | ||
|
|
||
| use FOS\MessageBundle\Util\LegacyFormHelper; | ||
| use Symfony\Component\Config\Definition\Processor; | ||
| use Symfony\Component\DependencyInjection\Reference; | ||
| use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
|
|
@@ -23,6 +24,7 @@ public function load(array $configs, ContainerBuilder $container) | |
| if (!in_array(strtolower($config['db_driver']), array('orm', 'mongodb'))) { | ||
| throw new \InvalidArgumentException(sprintf('Invalid db driver "%s".', $config['db_driver'])); | ||
| } | ||
|
|
||
| $loader->load(sprintf('%s.xml', $config['db_driver'])); | ||
| $loader->load('config.xml'); | ||
| $loader->load('form.xml'); | ||
|
|
@@ -51,10 +53,34 @@ public function load(array $configs, ContainerBuilder $container) | |
| $container->setAlias('fos_message.spam_detector', $config['spam_detector']); | ||
| $container->setAlias('fos_message.twig_extension', $config['twig_extension']); | ||
|
|
||
| $container->setAlias('fos_message.new_thread_form.type', $config['new_thread_form']['type']); | ||
| // BC management | ||
| $newThreadFormType = $config['new_thread_form']['type']; | ||
| $replyFormType = $config['reply_form']['type']; | ||
|
|
||
| if (!class_exists($newThreadFormType)) { | ||
| @trigger_error('Using a service reference in configuration key "fos_message.new_thread_form.type" is deprecated since version 1.2 and will be removed in 2.0. Use the class name of your form type instead.', E_USER_DEPRECATED); | ||
|
|
||
| // Old syntax (service reference) | ||
| $container->setAlias('fos_message.new_thread_form.type', $newThreadFormType); | ||
| } else { | ||
| // New syntax (class name) | ||
| $container->getDefinition('fos_message.new_thread_form.factory.default') | ||
| ->replaceArgument(1, $newThreadFormType); | ||
| } | ||
|
|
||
| if (!class_exists($replyFormType)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be merged with the check above thanks to a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find this more readable than a foreach, as there would be a concatenated variable everywhere.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no you could loop over |
||
| @trigger_error('Using a service reference in configuration key "fos_message.reply_form.type" is deprecated since version 1.2 and will be removed in 2.0. Use the class name of your form type instead.', E_USER_DEPRECATED); | ||
|
|
||
| // Old syntax (service reference) | ||
| $container->setAlias('fos_message.reply_form.type', $replyFormType); | ||
| } else { | ||
| // New syntax (class name) | ||
| $container->getDefinition('fos_message.reply_form.factory.default') | ||
| ->replaceArgument(1, $replyFormType); | ||
| } | ||
|
|
||
| $container->setAlias('fos_message.new_thread_form.factory', $config['new_thread_form']['factory']); | ||
| $container->setAlias('fos_message.new_thread_form.handler', $config['new_thread_form']['handler']); | ||
| $container->setAlias('fos_message.reply_form.type', $config['reply_form']['type']); | ||
| $container->setAlias('fos_message.reply_form.factory', $config['reply_form']['factory']); | ||
| $container->setAlias('fos_message.reply_form.handler', $config['reply_form']['handler']); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks useless and might hide forgotten dependencies, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain a bit more your idea? I don't understand why it would hide dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because you are always loading symfony entirely and you might depend on symfony libraries not included in the real composer file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are requiring the framework bundle, not Symfony entirely, and we do require the framework bundle in the composer.json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed sorry, i'm used to libraries loading the entire framework...
That's fine for me then 👍