Skip to content

Commit

Permalink
Use setter injection for optional security token storage
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Jul 17, 2017
1 parent 9e53148 commit 37b9d7c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
14 changes: 11 additions & 3 deletions src/Picker/AbstractPickerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ abstract class AbstractPickerProvider implements PickerProviderInterface
* Constructor.
*
* @param FactoryInterface $menuFactory
* @param TokenStorageInterface $tokenStorage
*/
public function __construct(FactoryInterface $menuFactory, TokenStorageInterface $tokenStorage)
public function __construct(FactoryInterface $menuFactory)
{
$this->menuFactory = $menuFactory;
$this->tokenStorage = $tokenStorage;
}

/**
Expand Down Expand Up @@ -70,6 +68,16 @@ public function createMenuItem(PickerConfig $config)
);
}

/**
* Setter injection for the security token storage.
*
* @param TokenStorageInterface $tokenStorage
*/
public function setTokenStorage(TokenStorageInterface $tokenStorage)
{
$this->tokenStorage = $tokenStorage;
}

/**
* {@inheritdoc}
*/
Expand Down
11 changes: 2 additions & 9 deletions src/Picker/FilePickerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ class FilePickerProvider extends AbstractPickerProvider implements DcaPickerProv
{
use FrameworkAwareTrait;

/**
* @var ContaoFrameworkInterface
*/
private $framework;

/**
* @var string
*/
Expand All @@ -42,13 +37,11 @@ class FilePickerProvider extends AbstractPickerProvider implements DcaPickerProv
* Constructor.
*
* @param FactoryInterface $menuFactory
* @param TokenStorageInterface $tokenStorage
* @param ContaoFrameworkInterface $framework
* @param string $uploadPath
*/
public function __construct(FactoryInterface $menuFactory, TokenStorageInterface $tokenStorage, $uploadPath)
public function __construct(FactoryInterface $menuFactory, $uploadPath)
{
parent::__construct($menuFactory, $tokenStorage);
parent::__construct($menuFactory);

$this->uploadPath = $uploadPath;
}
Expand Down
9 changes: 6 additions & 3 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ services:
public: false
arguments:
- "@knp_menu.factory"
- "@security.token_storage"
calls:
- [setTokenStorage, ["@security.token_storage"]]
tags:
- { name: contao.picker_provider, priority: 192 }

Expand All @@ -180,8 +181,9 @@ services:
public: false
arguments:
- "@knp_menu.factory"
- "@security.token_storage"
- "%contao.upload_path%"
calls:
- [setTokenStorage, ["@security.token_storage"]]
tags:
- { name: contao.picker_provider, priority: 160 }

Expand All @@ -190,7 +192,8 @@ services:
public: false
arguments:
- "@knp_menu.factory"
- "@security.token_storage"
calls:
- [setTokenStorage, ["@security.token_storage"]]
tags:
- { name: contao.picker_provider }

Expand Down

0 comments on commit 37b9d7c

Please sign in to comment.