1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

Update to FOSUserBundle 3.1

Also remove some deprecation from Symfony.
Use `LegacyEventDispatcherProxy` to handle Symfony 4 dispatch from FOSUser
This commit is contained in:
Jeremy Benoist 2022-12-13 13:39:24 +01:00
parent 141d289ec0
commit 33267f0736
No known key found for this signature in database
GPG key ID: 7168D5DD29F38552
30 changed files with 90 additions and 92 deletions

View file

@ -12,9 +12,6 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('wallabag_annotation');
return $treeBuilder;
return new TreeBuilder('wallabag_annotation');
}
}

View file

@ -11,6 +11,7 @@ use JMS\Serializer\SerializerInterface;
use Nelmio\ApiDocBundle\Annotation\Operation;
use Swagger\Annotations as SWG;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
@ -159,7 +160,7 @@ class UserRestController extends WallabagRestController
// dispatch a created event so the associated config will be created
$event = new UserEvent($user, $request);
$this->get(EventDispatcherInterface::class)->dispatch(FOSUserEvents::USER_CREATED, $event);
LegacyEventDispatcherProxy::decorate($this->get(EventDispatcherInterface::class))->dispatch($event, FOSUserEvents::USER_CREATED);
return $this->sendUser($user, 'user_api_with_client', JsonResponse::HTTP_CREATED);
}

View file

@ -17,9 +17,6 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('wallabag_api');
return $treeBuilder;
return new TreeBuilder('wallabag_api');
}
}

View file

@ -18,6 +18,7 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
use Wallabag\CoreBundle\Entity\InternalSetting;
use Wallabag\UserBundle\Entity\User;
@ -281,7 +282,7 @@ class InstallCommand extends ContainerAwareCommand
// dispatch a created event so the associated config will be created
$event = new UserEvent($user);
$this->getContainer()->get(EventDispatcherInterface::class)->dispatch(FOSUserEvents::USER_CREATED, $event);
LegacyEventDispatcherProxy::decorate($this->getContainer()->get(EventDispatcherInterface::class))->dispatch($event, FOSUserEvents::USER_CREATED);
$this->io->text('<info>Administration successfully setup.</info>');

View file

@ -9,8 +9,8 @@ class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('wallabag_core');
$treeBuilder = new TreeBuilder('wallabag_core');
$rootNode = $treeBuilder->getRootNode();
$rootNode
->children()

View file

@ -2,10 +2,10 @@
namespace Wallabag\CoreBundle\Event\Subscriber;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Doctrine\Common\EventSubscriber;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\Persistence\ManagerRegistry;
use Wallabag\CoreBundle\Entity\Entry;
/**
@ -19,7 +19,7 @@ class SQLiteCascadeDeleteSubscriber implements EventSubscriber
{
private $doctrine;
public function __construct(Registry $doctrine)
public function __construct(ManagerRegistry $doctrine)
{
$this->doctrine = $doctrine;
}

View file

@ -4,7 +4,7 @@ namespace Wallabag\CoreBundle\Helper;
use Graby\Graby;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
use Symfony\Component\Mime\MimeTypes;
use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
use Symfony\Component\Validator\Constraints\Url as UrlConstraint;
use Symfony\Component\Validator\Validator\ValidatorInterface;
@ -22,7 +22,7 @@ class ContentProxy
protected $ignoreOriginProcessor;
protected $validator;
protected $logger;
protected $mimeGuesser;
protected $mimeTypes;
protected $fetchingErrorMessage;
protected $eventDispatcher;
protected $storeArticleHeaders;
@ -34,7 +34,7 @@ class ContentProxy
$this->ignoreOriginProcessor = $ignoreOriginProcessor;
$this->validator = $validator;
$this->logger = $logger;
$this->mimeGuesser = new MimeTypeExtensionGuesser();
$this->mimeTypes = new MimeTypes();
$this->fetchingErrorMessage = $fetchingErrorMessage;
$this->storeArticleHeaders = $storeArticleHeaders;
}
@ -296,7 +296,7 @@ class ContentProxy
}
// if content is an image, define it as a preview too
if (!empty($content['headers']['content-type']) && \in_array($this->mimeGuesser->guess($content['headers']['content-type']), ['jpeg', 'jpg', 'gif', 'png'], true)) {
if (!empty($content['headers']['content-type']) && \in_array(current($this->mimeTypes->getExtensions($content['headers']['content-type'])), ['jpeg', 'jpg', 'gif', 'png'], true)) {
$previewPictureUrl = $content['url'];
} elseif (empty($previewPictureUrl)) {
$this->logger->debug('Extracting images from content to provide a default preview picture');

View file

@ -15,7 +15,7 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
use Symfony\Component\Mime\MimeTypes;
class DownloadImages
{
@ -24,7 +24,7 @@ class DownloadImages
private $client;
private $baseFolder;
private $logger;
private $mimeGuesser;
private $mimeTypes;
private $wallabagUrl;
public function __construct(HttpClient $client, $baseFolder, $wallabagUrl, LoggerInterface $logger, MessageFactory $messageFactory = null)
@ -33,7 +33,7 @@ class DownloadImages
$this->baseFolder = $baseFolder;
$this->wallabagUrl = rtrim($wallabagUrl, '/');
$this->logger = $logger;
$this->mimeGuesser = new MimeTypeExtensionGuesser();
$this->mimeTypes = new MimeTypes();
$this->setFolder();
}
@ -355,7 +355,7 @@ class DownloadImages
*/
private function getExtensionFromResponse(ResponseInterface $res, $imagePath)
{
$ext = $this->mimeGuesser->guess(current($res->getHeader('content-type')));
$ext = current($this->mimeTypes->getExtensions(current($res->getHeader('content-type'))));
$this->logger->debug('DownloadImages: Checking extension', ['ext' => $ext, 'header' => $res->getHeader('content-type')]);
// ok header doesn't have the extension, try a different way

View file

@ -2,7 +2,7 @@
namespace Wallabag\CoreBundle\ParamConverter;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Persistence\ManagerRegistry;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
use Symfony\Component\HttpFoundation\Request;

View file

@ -9,8 +9,8 @@ class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('wallabag_import');
$treeBuilder = new TreeBuilder('wallabag_import');
$rootNode = $treeBuilder->getRootNode();
$rootNode
->children()

View file

@ -11,6 +11,7 @@ use Pagerfanta\Pagerfanta;
use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@ -49,7 +50,7 @@ class ManageController extends Controller
// dispatch a created event so the associated config will be created
$event = new UserEvent($user, $request);
$this->get(EventDispatcherInterface::class)->dispatch(FOSUserEvents::USER_CREATED, $event);
LegacyEventDispatcherProxy::decorate($this->get(EventDispatcherInterface::class))->dispatch($event, FOSUserEvents::USER_CREATED);
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',

View file

@ -9,9 +9,6 @@ class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('wallabag_user');
return $treeBuilder;
return new TreeBuilder('wallabag_user');
}
}

View file

@ -12,7 +12,6 @@ use Scheb\TwoFactorBundle\Model\BackupCodeInterface;
use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface as EmailTwoFactorInterface;
use Scheb\TwoFactorBundle\Model\Google\TwoFactorInterface as GoogleTwoFactorInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
use Wallabag\ApiBundle\Entity\Client;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\CoreBundle\Entity\Entry;
@ -205,11 +204,6 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
return $this->entries;
}
public function isEqualTo(UserInterface $user)
{
return $this->username === $user->getUsername();
}
/**
* Set config.
*