mirror of
https://github.com/wallabag/wallabag.git
synced 2025-01-22 14:48:08 +00:00
Merge pull request #2556 from wallabag/replace-tokenstorage
Replaced TokenStorage with TokenStorageInterface
This commit is contained in:
commit
a4de2351a0
2 changed files with 21 additions and 10 deletions
|
@ -12,7 +12,7 @@ use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType;
|
|||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
|
||||
class EntryFilterType extends AbstractType
|
||||
{
|
||||
|
@ -23,12 +23,17 @@ class EntryFilterType extends AbstractType
|
|||
* Repository & user are used to get a list of language entries for this user.
|
||||
*
|
||||
* @param EntityRepository $entryRepository
|
||||
* @param TokenStorage $token
|
||||
* @param TokenStorageInterface $tokenStorage
|
||||
*/
|
||||
public function __construct(EntityRepository $entryRepository, TokenStorage $token)
|
||||
public function __construct(EntityRepository $entryRepository, TokenStorageInterface $tokenStorage)
|
||||
{
|
||||
$this->repository = $entryRepository;
|
||||
$this->user = $token->getToken()->getUser();
|
||||
|
||||
$this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser() : null;
|
||||
|
||||
if (null === $this->user || !is_object($this->user)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
|
|
|
@ -5,16 +5,16 @@ namespace Wallabag\CoreBundle\Helper;
|
|||
use Pagerfanta\Adapter\AdapterInterface;
|
||||
use Pagerfanta\Pagerfanta;
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
|
||||
class PreparePagerForEntries
|
||||
{
|
||||
private $user;
|
||||
private $router;
|
||||
private $tokenStorage;
|
||||
|
||||
public function __construct(TokenStorage $token, Router $router)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, Router $router)
|
||||
{
|
||||
$this->user = $token->getToken()->getUser();
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->router = $router;
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,14 @@ class PreparePagerForEntries
|
|||
*/
|
||||
public function prepare(AdapterInterface $adapter, $page = 1)
|
||||
{
|
||||
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
|
||||
|
||||
if (null === $user || !is_object($user)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$entries = new Pagerfanta($adapter);
|
||||
$entries->setMaxPerPage($this->user->getConfig()->getItemsPerPage());
|
||||
$entries->setMaxPerPage($user->getConfig()->getItemsPerPage());
|
||||
|
||||
return $entries;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue