Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c15f204
fix of deprecated functions
DenysMedvid Feb 26, 2016
6c0d24a
fix deprecated security.context
DenysMedvid Feb 26, 2016
5a5aaf0
Add Czech translation
dfridrich Apr 2, 2016
f502d35
Fix a typo
dfridrich Apr 2, 2016
e7e0ca5
Merge pull request #276 from dfridrich/patch-2
tgalopin Apr 2, 2016
e8f7956
Merge pull request #277 from dfridrich/patch-1
tgalopin Apr 2, 2016
fd2752f
Fixing deprecations
bassrock Apr 16, 2016
c78c9a7
Fix a typo
dfridrich Apr 18, 2016
f824ef8
Merge pull request #279 from dfridrich/patch-4
tgalopin Apr 18, 2016
cd4d911
Merge pull request #1 from Klinche/master
ownede May 6, 2016
e3a8d89
Merge pull request #2 from FriendsOfSymfony/symfony3
ownede May 6, 2016
ce904d7
Removed use of ContainerAware (removed in Symfony 3.0)
May 6, 2016
1837ca1
Update scoped services to use request_stack
ubermuda May 11, 2016
d0c3481
Update services to use token storage instead of security context
ubermuda May 11, 2016
f5843ea
Switch from ContainerAware to ContainerAwareInterface
ubermuda May 11, 2016
e367a88
Make container property protected in message controller
ubermuda May 11, 2016
b865d10
Update form factory configuration
ubermuda May 11, 2016
946e99e
Update form handler to use handleRequest instead of bind
ubermuda May 11, 2016
77bf522
Update forms to use new type declaration
ubermuda May 11, 2016
0608251
Update forms to use configureOptions
ubermuda May 11, 2016
aa9eaf5
Merge branch 'symfony3' of https://github.com/ubermuda/FOSMessageBund…
Jul 7, 2016
c334607
Merge branch 'symfony3' of https://github.com/ubermuda/FOSMessageBund…
Jul 7, 2016
90912fc
Merge branch 'ubermuda-symfony3' into symfony3
Jul 7, 2016
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
Prev Previous commit
Next Next commit
Update scoped services to use request_stack
  • Loading branch information
ubermuda committed May 11, 2016
commit 1837ca135bc5acc67a53237117ca3bc415b44f5c
6 changes: 3 additions & 3 deletions FormHandler/AbstractMessageFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace FOS\MessageBundle\FormHandler;

use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use FOS\MessageBundle\Composer\ComposerInterface;
use FOS\MessageBundle\FormModel\AbstractMessage;
use FOS\MessageBundle\Security\ParticipantProviderInterface;
Expand All @@ -22,9 +22,9 @@ abstract class AbstractMessageFormHandler
protected $sender;
protected $participantProvider;

public function __construct(Request $request, ComposerInterface $composer, SenderInterface $sender, ParticipantProviderInterface $participantProvider)
public function __construct(RequestStack $requestStack, ComposerInterface $composer, SenderInterface $sender, ParticipantProviderInterface $participantProvider)
Copy link
Member

Choose a reason for hiding this comment

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

bc break

{
$this->request = $request;
$this->request = $requestStack->getCurrentRequest();
Copy link
Member

@GuilhemN GuilhemN Jul 22, 2016

Choose a reason for hiding this comment

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

The request must not be retrieved in the constructor.
You can do something like:

/**
 * @param Request|RequestStack $request
 */
public function __construct($request, ...) {
    if ($request instanceof Request) {
         @trigger_error(sprintf('Using an instance of "%s" as first parameter of "%s" is deprecated since version 1.3 and won\'t be supported in 2.0. Use an instance of "Symfony\Component\HttpFoundation\RequestStack" instead.', get_class($request), __METHOD), E_USER_DEPRECATED);
    }
    $this->request = $request;
    // ...
}

private function getCurrentRequest() {
   if ($this->request instanceof Request) {
      return $this->request;
   }

   return $this->request->getCurrentRequest();
}

public function process() {
    // ...
    $request = $this->getCurrentRequest();
}

$this->composer = $composer;
$this->sender = $sender;
$this->participantProvider = $participantProvider;
Expand Down
4 changes: 2 additions & 2 deletions Resources/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
<tag name="twig.extension" alias="fos_message" />
</service>

<service id="fos_message.search_query_factory.default" class="FOS\MessageBundle\Search\QueryFactory" scope="request" public="true">
<argument type="service" id="request" />
<service id="fos_message.search_query_factory.default" class="FOS\MessageBundle\Search\QueryFactory" public="true">
<argument type="service" id="request_stack" />
Copy link
Member

@GuilhemN GuilhemN Jul 22, 2016

Choose a reason for hiding this comment

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

this should be managed in a compiler pass or we must remove support of symfony/framework-bundle < 2.4.

@tgalopin do you agree to bump sf constraints to ^2.7 ?

Copy link
Contributor

@tgalopin tgalopin Sep 3, 2016

Choose a reason for hiding this comment

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

I don't, 2.3 is still supported and we should as well. I'll create a CompilerPass.

Copy link
Member

Choose a reason for hiding this comment

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

2.3 only receives security fixes and it's really easy to upgrade to a higher version. I don't think we should give people an argument to not upgrade.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind, that's wrong, 2.3 is not supported anymore. Let's drop it yes.

<argument /> <!-- query parameter containing the search terms -->
</service>

Expand Down
12 changes: 6 additions & 6 deletions Resources/config/form.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@
<argument>%fos_message.reply_form.model%</argument>
</service>

<service id="fos_message.new_thread_form.handler.default" class="FOS\MessageBundle\FormHandler\NewThreadMessageFormHandler" scope="request" public="false">
<argument type="service" id="request" />
<service id="fos_message.new_thread_form.handler.default" class="FOS\MessageBundle\FormHandler\NewThreadMessageFormHandler" public="false">
<argument type="service" id="request_stack" />
<argument type="service" id="fos_message.composer" />
<argument type="service" id="fos_message.sender" />
<argument type="service" id="fos_message.participant_provider" />
</service>

<service id="fos_message.new_thread_multiple_form.handler" class="FOS\MessageBundle\FormHandler\NewThreadMultipleMessageFormHandler" scope="request" public="false">
<argument type="service" id="request" />
<service id="fos_message.new_thread_multiple_form.handler" class="FOS\MessageBundle\FormHandler\NewThreadMultipleMessageFormHandler" public="false">
<argument type="service" id="request_stack" />
<argument type="service" id="fos_message.composer" />
<argument type="service" id="fos_message.sender" />
<argument type="service" id="fos_message.participant_provider" />
</service>

<service id="fos_message.reply_form.handler.default" class="FOS\MessageBundle\FormHandler\ReplyMessageFormHandler" scope="request" public="false">
<argument type="service" id="request" />
<service id="fos_message.reply_form.handler.default" class="FOS\MessageBundle\FormHandler\ReplyMessageFormHandler" public="false">
<argument type="service" id="request_stack" />
<argument type="service" id="fos_message.composer" />
<argument type="service" id="fos_message.sender" />
<argument type="service" id="fos_message.participant_provider" />
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/spam_detection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<service id="fos_message.noop_spam_detector" class="FOS\MessageBundle\SpamDetection\NoopSpamDetector" public="false" />

<service id="fos_message.akismet_spam_detector" class="FOS\MessageBundle\SpamDetection\AkismetSpamDetector" public="false" scope="request">
<service id="fos_message.akismet_spam_detector" class="FOS\MessageBundle\SpamDetection\AkismetSpamDetector" public="false">
<argument type="service" id="ornicar_akismet" />
<argument type="service" id="fos_message.participant_provider" />
</service>
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/validator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<tag name="validator.constraint_validator" alias="fos_message.validator.reply_authorization" />
</service>

<service id="fos_message.validator.spam" class="FOS\MessageBundle\Validator\SpamValidator" scope="request">
<service id="fos_message.validator.spam" class="FOS\MessageBundle\Validator\SpamValidator">
<argument type="service" id="fos_message.spam_detector" />
<tag name="validator.constraint_validator" alias="fos_message.validator.spam" />
</service>
Expand Down
10 changes: 5 additions & 5 deletions Search/QueryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace FOS\MessageBundle\Search;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

/**
* Gets the search term from the request and prepares it
*/
class QueryFactory implements QueryFactoryInterface
{
/**
* @var Request
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request = null;

Expand All @@ -24,12 +24,12 @@ class QueryFactory implements QueryFactoryInterface
/**
* Instanciates a new TermGetter
*
* @param Request $request
* @param RequestStack $requestStack
* @param string $queryParameter
*/
public function __construct(Request $request, $queryParameter)
public function __construct(RequestStack $requestStack, $queryParameter)
{
$this->request = $request;
$this->request = $requestStack->getCurrentRequest();
Copy link
Member

Choose a reason for hiding this comment

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

should be implemented as described earlier

$this->queryParameter = $queryParameter;
}

Expand Down