Skip to content

Commit

Permalink
use attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
MDevster committed Jan 7, 2025
1 parent 97d7836 commit 5931a4c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Types of changes
> [!Tip]
> Thank you to all [EAP](https://pdir.de/crowdfunding/social-feed-bundle.html) supporters!
## [2.14.0](https://github.com/pdir/social-feed-bundle/tree/2.14.0) - 2025-01-08

- [Added] Add compatibility for Contao 5.4+
- [Fixed] Instagram import (You need a Business ?)

## [2.13.6](https://github.com/pdir/social-feed-bundle/tree/2.13.6) - 2024-11-21

-[Fixed] Update kevinrob/guzzle-cache-middleware fix #150 🤗 [contaoacademy](https://github.com/contaoacademy)
Expand Down
4 changes: 0 additions & 4 deletions config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ services:

Pdir\SocialFeedBundle\EventListener\DataContainer\SocialFeedListener:
public: true
arguments:
- "@router"
- '@security.helper'
- '@contao.image.sizes'

pdir_social_feed_moderate.controller:
class: Pdir\SocialFeedBundle\Controller\ModerateController
Expand Down
21 changes: 7 additions & 14 deletions src/EventListener/DataContainer/SocialFeedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,27 @@
use Pdir\SocialFeedBundle\EventListener\Config;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;

class SocialFeedListener
{
public const SESSION_KEY = 'social-feed-id';

/**
* @var RouterInterface
*/
private $router;

/**
* @var SessionInterface
*/
private $session;

private Security $security;
private ImageSizes $imageSizes;

/**
* ModuleListener constructor.
*/
public function __construct(RouterInterface $router, Security $security, ImageSizes $imageSizes)
public function __construct(
private readonly RouterInterface $router,
private readonly TokenStorageInterface $tokenStorage,
private readonly ImageSizes $imageSizes
)
{
$this->router = $router;
$this->session = System::getContainer()->get('request_stack')->getCurrentRequest()->getSession();
$this->security = $security;
$this->imageSizes = $imageSizes;
}

/**
Expand Down Expand Up @@ -92,7 +85,7 @@ public function onRequestTokenSave()
*/
public function getImageSizeOptions(): array
{
$user = $this->security->getUser();
$user = $this->tokenStorage->getToken()?->getUser();

if (!$user instanceof BackendUser) {
return [];
Expand Down

0 comments on commit 5931a4c

Please sign in to comment.