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
fix deprecated security.context
  • Loading branch information
DenysMedvid committed Feb 26, 2016
commit 6c0d24a52b5205883e8ca383db3c7119389e8fb1
2 changes: 1 addition & 1 deletion Resources/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</service>

<service id="fos_message.participant_provider.default" class="FOS\MessageBundle\Security\ParticipantProvider" public="false">
<argument type="service" id="security.context" />
<argument type="service" id="security.token_storage" />
</service>

<service id="fos_message.authorizer.default" class="FOS\MessageBundle\Security\Authorizer" public="false">
Expand Down
2 changes: 1 addition & 1 deletion Resources/doc/90-sending-a-message-programatically.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This is probably all you will need in many cases.
To compose a message we retrieve the composer service and compose our message:

```php
$sender = $this->get('security.context')->getToken()->getUser();
$sender = $this->get('security.token_storage')->getToken()->getUser();
$threadBuilder = $this->get('fos_message.composer')->newThread();
$threadBuilder
->addRecipient($recipient) // Retrieved from your backend, your user manager or ...
Expand Down
16 changes: 6 additions & 10 deletions Security/ParticipantProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace FOS\MessageBundle\Security;

use FOS\MessageBundle\Model\ParticipantInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\SecurityContextInterface;

/**
* Provides the authenticated participant
Expand All @@ -13,16 +13,12 @@
*/
class ParticipantProvider implements ParticipantProviderInterface
{
/**
* The security context
*
* @var SecurityContextInterface
*/
protected $securityContext;
/** @var TokenStorageInterface */
protected $tokenStorage;

public function __construct(SecurityContextInterface $securityContext)
public function __construct(TokenStorageInterface $tokenStorage)
Copy link
Member

Choose a reason for hiding this comment

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

That's a bc break, the class should support both implementations.

{
$this->securityContext = $securityContext;
$this->tokenStorage = $tokenStorage;
}

/**
Expand All @@ -32,7 +28,7 @@ public function __construct(SecurityContextInterface $securityContext)
*/
public function getAuthenticatedParticipant()
{
$participant = $this->securityContext->getToken()->getUser();
$participant = $this->tokenStorage->getToken()->getUser();

if (!$participant instanceof ParticipantInterface) {
throw new AccessDeniedException('Must be logged in with a ParticipantInterface instance');
Expand Down