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

Use FQCN instead of service alias

This commit is contained in:
Yassine Guedidi 2022-08-28 02:01:46 +02:00
parent 156158673f
commit eb43c78720
62 changed files with 579 additions and 404 deletions

View file

@ -3,7 +3,9 @@
namespace Wallabag\AnnotationBundle\Controller;
use FOS\RestBundle\Controller\AbstractFOSRestController;
use JMS\Serializer\SerializerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Wallabag\AnnotationBundle\Entity\Annotation;
@ -29,7 +31,7 @@ class WallabagAnnotationController extends AbstractFOSRestController
$total = \count($annotationRows);
$annotations = ['total' => $total, 'rows' => $annotationRows];
$json = $this->get('jms_serializer')->serialize($annotations, 'json');
$json = $this->get(SerializerInterface::class)->serialize($annotations, 'json');
return (new JsonResponse())->setJson($json);
}
@ -49,7 +51,7 @@ class WallabagAnnotationController extends AbstractFOSRestController
$annotation = new Annotation($this->getUser());
$annotation->setEntry($entry);
$form = $this->get('form.factory')->createNamed('', NewAnnotationType::class, $annotation, [
$form = $this->get(FormFactoryInterface::class)->createNamed('', NewAnnotationType::class, $annotation, [
'csrf_protection' => false,
'allow_extra_fields' => true,
]);
@ -59,7 +61,7 @@ class WallabagAnnotationController extends AbstractFOSRestController
$em->persist($annotation);
$em->flush();
$json = $this->get('jms_serializer')->serialize($annotation, 'json');
$json = $this->get(SerializerInterface::class)->serialize($annotation, 'json');
return JsonResponse::fromJsonString($json);
}
@ -80,7 +82,7 @@ class WallabagAnnotationController extends AbstractFOSRestController
{
$data = json_decode($request->getContent(), true);
$form = $this->get('form.factory')->createNamed('', EditAnnotationType::class, $annotation, [
$form = $this->get(FormFactoryInterface::class)->createNamed('', EditAnnotationType::class, $annotation, [
'csrf_protection' => false,
'allow_extra_fields' => true,
]);
@ -91,7 +93,7 @@ class WallabagAnnotationController extends AbstractFOSRestController
$em->persist($annotation);
$em->flush();
$json = $this->get('jms_serializer')->serialize($annotation, 'json');
$json = $this->get(SerializerInterface::class)->serialize($annotation, 'json');
return JsonResponse::fromJsonString($json);
}
@ -114,7 +116,7 @@ class WallabagAnnotationController extends AbstractFOSRestController
$em->remove($annotation);
$em->flush();
$json = $this->get('jms_serializer')->serialize($annotation, 'json');
$json = $this->get(SerializerInterface::class)->serialize($annotation, 'json');
return (new JsonResponse())->setJson($json);
}

View file

@ -3,6 +3,7 @@
namespace Wallabag\ApiBundle\Controller;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerInterface;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\HttpFoundation\JsonResponse;
@ -19,7 +20,7 @@ class ConfigRestController extends WallabagRestController
{
$this->validateAuthentication();
$json = $this->get('jms_serializer')->serialize(
$json = $this->get(SerializerInterface::class)->serialize(
$this->getUser()->getConfig(),
'json',
SerializationContext::create()->setGroups(['config_api'])

View file

@ -4,7 +4,9 @@ namespace Wallabag\ApiBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\ApiBundle\Entity\Client;
use Wallabag\ApiBundle\Form\Type\ClientType;
@ -45,9 +47,9 @@ class DeveloperController extends Controller
$em->persist($client);
$em->flush();
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.developer.notice.client_created', ['%name%' => $client->getName()])
$this->get(TranslatorInterface::class)->trans('flashes.developer.notice.client_created', ['%name%' => $client->getName()])
);
return $this->render('@WallabagCore/themes/common/Developer/client_parameters.html.twig', [
@ -79,9 +81,9 @@ class DeveloperController extends Controller
$em->remove($client);
$em->flush();
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.developer.notice.client_deleted', ['%name%' => $client->getName()])
$this->get(TranslatorInterface::class)->trans('flashes.developer.notice.client_deleted', ['%name%' => $client->getName()])
);
return $this->redirect($this->generateUrl('developer'));

View file

@ -5,6 +5,7 @@ namespace Wallabag\ApiBundle\Controller;
use Hateoas\Configuration\Route;
use Hateoas\Representation\Factory\PagerfantaFactory;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@ -257,7 +258,7 @@ class EntryRestController extends WallabagRestController
if (false !== $entry) {
// entry deleted, dispatch event about it!
$this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
$this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
$em = $this->getDoctrine()->getManager();
$em->remove($entry);
@ -322,7 +323,7 @@ class EntryRestController extends WallabagRestController
$results[$key]['entry'] = $entry instanceof Entry ? $entry->getId() : false;
// entry saved, dispatch event about it!
$this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
$this->get(EventDispatcherInterface::class)->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
}
return $this->sendResponse($results);
@ -430,7 +431,7 @@ class EntryRestController extends WallabagRestController
$em->flush();
// entry saved, dispatch event about it!
$this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
$this->get(EventDispatcherInterface::class)->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
return $this->sendResponse($entry);
}
@ -547,7 +548,7 @@ class EntryRestController extends WallabagRestController
$em->flush();
// entry saved, dispatch event about it!
$this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
$this->get(EventDispatcherInterface::class)->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
return $this->sendResponse($entry);
}
@ -590,7 +591,7 @@ class EntryRestController extends WallabagRestController
$em->flush();
// entry saved, dispatch event about it!
$this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
$this->get(EventDispatcherInterface::class)->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
return $this->sendResponse($entry);
}
@ -628,7 +629,7 @@ class EntryRestController extends WallabagRestController
}
// entry deleted, dispatch event about it!
$this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
$this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
$em = $this->getDoctrine()->getManager();
$em->remove($entry);

View file

@ -2,6 +2,7 @@
namespace Wallabag\ApiBundle\Controller;
use JMS\Serializer\SerializerInterface;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
@ -25,7 +26,7 @@ class TagRestController extends WallabagRestController
->getRepository(Tag::class)
->findAllTags($this->getUser()->getId());
$json = $this->get('jms_serializer')->serialize($tags, 'json');
$json = $this->get(SerializerInterface::class)->serialize($tags, 'json');
return (new JsonResponse())->setJson($json);
}
@ -60,7 +61,7 @@ class TagRestController extends WallabagRestController
$this->cleanOrphanTag($tag);
$json = $this->get('jms_serializer')->serialize($tag, 'json');
$json = $this->get(SerializerInterface::class)->serialize($tag, 'json');
return (new JsonResponse())->setJson($json);
}
@ -94,7 +95,7 @@ class TagRestController extends WallabagRestController
$this->cleanOrphanTag($tags);
$json = $this->get('jms_serializer')->serialize($tags, 'json');
$json = $this->get(SerializerInterface::class)->serialize($tags, 'json');
return (new JsonResponse())->setJson($json);
}
@ -126,7 +127,7 @@ class TagRestController extends WallabagRestController
$this->cleanOrphanTag($tag);
$json = $this->get('jms_serializer')->serialize($tag, 'json');
$json = $this->get(SerializerInterface::class)->serialize($tag, 'json');
return (new JsonResponse())->setJson($json);
}

View file

@ -2,12 +2,17 @@
namespace Wallabag\ApiBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Model\UserManagerInterface;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerInterface;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\ApiBundle\Entity\Client;
use Wallabag\UserBundle\Entity\User;
@ -45,15 +50,15 @@ class UserRestController extends WallabagRestController
*/
public function putUserAction(Request $request)
{
if (!$this->container->getParameter('fosuser_registration') || !$this->get('craue_config')->get('api_user_registration')) {
$json = $this->get('jms_serializer')->serialize(['error' => "Server doesn't allow registrations"], 'json');
if (!$this->container->getParameter('fosuser_registration') || !$this->get(Config::class)->get('api_user_registration')) {
$json = $this->get(SerializerInterface::class)->serialize(['error' => "Server doesn't allow registrations"], 'json');
return (new JsonResponse())
->setJson($json)
->setStatusCode(JsonResponse::HTTP_FORBIDDEN);
}
$userManager = $this->get('fos_user.user_manager');
$userManager = $this->get(UserManagerInterface::class);
$user = $userManager->createUser();
// user will be disabled BY DEFAULT to avoid spamming account to be enabled
$user->setEnabled(false);
@ -92,7 +97,7 @@ class UserRestController extends WallabagRestController
$errors['password'] = $this->translateErrors($data['plainPassword']['children']['first']['errors']);
}
$json = $this->get('jms_serializer')->serialize(['error' => $errors], 'json');
$json = $this->get(SerializerInterface::class)->serialize(['error' => $errors], 'json');
return (new JsonResponse())
->setJson($json)
@ -111,7 +116,7 @@ class UserRestController extends WallabagRestController
// dispatch a created event so the associated config will be created
$event = new UserEvent($user, $request);
$this->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event);
$this->get(EventDispatcherInterface::class)->dispatch(FOSUserEvents::USER_CREATED, $event);
return $this->sendUser($user, 'user_api_with_client', JsonResponse::HTTP_CREATED);
}
@ -126,7 +131,7 @@ class UserRestController extends WallabagRestController
*/
private function sendUser(User $user, $group = 'user_api', $status = JsonResponse::HTTP_OK)
{
$json = $this->get('jms_serializer')->serialize(
$json = $this->get(SerializerInterface::class)->serialize(
$user,
'json',
SerializationContext::create()->setGroups([$group])
@ -148,7 +153,7 @@ class UserRestController extends WallabagRestController
{
$translatedErrors = [];
foreach ($errors as $error) {
$translatedErrors[] = $this->get('translator')->trans($error);
$translatedErrors[] = $this->get(TranslatorInterface::class)->trans($error);
}
return $translatedErrors;

View file

@ -4,8 +4,11 @@ namespace Wallabag\ApiBundle\Controller;
use FOS\RestBundle\Controller\AbstractFOSRestController;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerInterface;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
class WallabagRestController extends AbstractFOSRestController
@ -22,7 +25,7 @@ class WallabagRestController extends AbstractFOSRestController
public function getVersionAction()
{
$version = $this->container->getParameter('wallabag_core.version');
$json = $this->get('jms_serializer')->serialize($version, 'json');
$json = $this->get(SerializerInterface::class)->serialize($version, 'json');
return (new JsonResponse())->setJson($json);
}
@ -42,12 +45,12 @@ class WallabagRestController extends AbstractFOSRestController
'allowed_registration' => $this->container->getParameter('fosuser_registration'),
];
return (new JsonResponse())->setJson($this->get('jms_serializer')->serialize($info, 'json'));
return (new JsonResponse())->setJson($this->get(SerializerInterface::class)->serialize($info, 'json'));
}
protected function validateAuthentication()
{
if (false === $this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
if (false === $this->get(AuthorizationCheckerInterface::class)->isGranted('IS_AUTHENTICATED_FULLY')) {
throw new AccessDeniedException();
}
}
@ -60,7 +63,7 @@ class WallabagRestController extends AbstractFOSRestController
*/
protected function validateUserAccess($requestUserId)
{
$user = $this->get('security.token_storage')->getToken()->getUser();
$user = $this->get(TokenStorageInterface::class)->getToken()->getUser();
if ($requestUserId !== $user->getId()) {
throw $this->createAccessDeniedException('Access forbidden. Entry user id: ' . $requestUserId . ', logged user id: ' . $user->getId());
}
@ -79,7 +82,7 @@ class WallabagRestController extends AbstractFOSRestController
$context = new SerializationContext();
$context->setSerializeNull(true);
$json = $this->get('jms_serializer')->serialize($data, 'json', $context);
$json = $this->get(SerializerInterface::class)->serialize($data, 'json', $context);
return (new JsonResponse())->setJson($json);
}

View file

@ -2,6 +2,7 @@
namespace Wallabag\CoreBundle\Command;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\NoResultException;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
@ -67,7 +68,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
private function cleanDuplicates(User $user)
{
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
$em = $this->getContainer()->get(EntityManagerInterface::class);
$repo = $this->getContainer()->get(EntryRepository::class);
$entries = $repo->findAllEntriesIdAndUrlByUserId($user->getId());

View file

@ -2,7 +2,9 @@
namespace Wallabag\CoreBundle\Command;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\NoResultException;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@ -57,7 +59,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
private function generateHashedUrls(User $user)
{
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
$em = $this->getContainer()->get(EntityManagerInterface::class);
$repo = $this->getDoctrine()->getRepository(Entry::class);
$entries = $repo->findByEmptyHashedUrlAndUserId($user->getId());
@ -92,6 +94,6 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
private function getDoctrine()
{
return $this->getContainer()->get('doctrine');
return $this->getContainer()->get(ManagerRegistry::class);
}
}

View file

@ -2,8 +2,12 @@
namespace Wallabag\CoreBundle\Command;
use Doctrine\DBAL\Connection;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Model\UserManagerInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
@ -12,6 +16,7 @@ use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
use Wallabag\CoreBundle\Entity\InternalSetting;
@ -72,7 +77,7 @@ class InstallCommand extends ContainerAwareCommand
{
$this->io->section('Step 1 of 4: Checking system requirements.');
$doctrineManager = $this->getContainer()->get('doctrine')->getManager();
$doctrineManager = $this->getContainer()->get(ManagerRegistry::class)->getManager();
$rows = [];
@ -95,7 +100,7 @@ class InstallCommand extends ContainerAwareCommand
$status = '<info>OK!</info>';
$help = '';
$conn = $this->getContainer()->get('doctrine')->getManager()->getConnection();
$conn = $this->getContainer()->get(ManagerRegistry::class)->getManager()->getConnection();
try {
$conn->connect();
@ -244,9 +249,9 @@ class InstallCommand extends ContainerAwareCommand
return $this;
}
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
$em = $this->getContainer()->get(EntityManagerInterface::class);
$userManager = $this->getContainer()->get('fos_user.user_manager');
$userManager = $this->getContainer()->get(UserManagerInterface::class);
$user = $userManager->createUser();
$user->setUsername($this->io->ask('Username', 'wallabag'));
@ -264,7 +269,7 @@ class InstallCommand extends ContainerAwareCommand
// dispatch a created event so the associated config will be created
$event = new UserEvent($user);
$this->getContainer()->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event);
$this->getContainer()->get(EventDispatcherInterface::class)->dispatch(FOSUserEvents::USER_CREATED, $event);
$this->io->text('<info>Administration successfully setup.</info>');
@ -274,7 +279,7 @@ class InstallCommand extends ContainerAwareCommand
protected function setupConfig()
{
$this->io->section('Step 4 of 4: Config setup.');
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
$em = $this->getContainer()->get(EntityManagerInterface::class);
// cleanup before insert new stuff
$em->createQuery('DELETE FROM Wallabag\CoreBundle\Entity\InternalSetting')->execute();
@ -329,7 +334,7 @@ class InstallCommand extends ContainerAwareCommand
// PDO does not always close the connection after Doctrine commands.
// See https://github.com/symfony/symfony/issues/11750.
$this->getContainer()->get('doctrine')->getManager()->getConnection()->close();
$this->getContainer()->get(ManagerRegistry::class)->getManager()->getConnection()->close();
if (0 !== $exitCode) {
$this->getApplication()->setAutoExit(true);
@ -347,7 +352,7 @@ class InstallCommand extends ContainerAwareCommand
*/
private function isDatabasePresent()
{
$connection = $this->getContainer()->get('doctrine')->getManager()->getConnection();
$connection = $this->getContainer()->get(ManagerRegistry::class)->getManager()->getConnection();
$databaseName = $connection->getDatabase();
try {
@ -368,7 +373,7 @@ class InstallCommand extends ContainerAwareCommand
// custom verification for sqlite, since `getListDatabasesSQL` doesn't work for sqlite
if ('sqlite' === $schemaManager->getDatabasePlatform()->getName()) {
$params = $this->getContainer()->get('doctrine.dbal.default_connection')->getParams();
$params = $this->getContainer()->get(Connection::class)->getParams();
if (isset($params['path']) && file_exists($params['path'])) {
return true;
@ -394,7 +399,7 @@ class InstallCommand extends ContainerAwareCommand
*/
private function isSchemaPresent()
{
$schemaManager = $this->getContainer()->get('doctrine')->getManager()->getConnection()->getSchemaManager();
$schemaManager = $this->getContainer()->get(ManagerRegistry::class)->getManager()->getConnection()->getSchemaManager();
return \count($schemaManager->listTableNames()) > 0 ? true : false;
}

View file

@ -3,11 +3,13 @@
namespace Wallabag\CoreBundle\Command;
use Doctrine\ORM\NoResultException;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Wallabag\CoreBundle\Event\EntrySavedEvent;
use Wallabag\CoreBundle\Helper\ContentProxy;
use Wallabag\CoreBundle\Repository\EntryRepository;
@ -67,8 +69,8 @@ class ReloadEntryCommand extends ContainerAwareCommand
$progressBar = $io->createProgressBar($nbEntries);
$contentProxy = $this->getContainer()->get(ContentProxy::class);
$em = $this->getContainer()->get('doctrine')->getManager();
$dispatcher = $this->getContainer()->get('event_dispatcher');
$em = $this->getContainer()->get(ManagerRegistry::class)->getManager();
$dispatcher = $this->getContainer()->get(EventDispatcherInterface::class);
$progressBar->start();
foreach ($entryIds as $entryId) {

View file

@ -3,6 +3,7 @@
namespace Wallabag\CoreBundle\Command;
use Doctrine\ORM\NoResultException;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@ -70,6 +71,6 @@ class TagAllCommand extends ContainerAwareCommand
private function getDoctrine()
{
return $this->getContainer()->get('doctrine');
return $this->getContainer()->get(ManagerRegistry::class);
}
}

View file

@ -2,9 +2,14 @@
namespace Wallabag\CoreBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use Doctrine\Persistence\ManagerRegistry;
use FOS\UserBundle\Model\UserManagerInterface;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerBuilder;
use Liip\ThemeBundle\ActiveTheme;
use PragmaRX\Recovery\Recovery as BackupCodes;
use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
@ -12,7 +17,9 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Wallabag\AnnotationBundle\Entity\Annotation;
use Wallabag\CoreBundle\Entity\Config as ConfigEntity;
use Wallabag\CoreBundle\Entity\IgnoreOriginUserRule;
@ -39,7 +46,7 @@ class ConfigController extends Controller
{
$em = $this->getDoctrine()->getManager();
$config = $this->getConfig();
$userManager = $this->container->get('fos_user.user_manager');
$userManager = $this->container->get(UserManagerInterface::class);
$user = $this->getUser();
// handle basic config detail (this form is defined as a service)
@ -63,7 +70,7 @@ class ConfigController extends Controller
$request->getSession()->set('_locale', $config->getLanguage());
// switch active theme
$activeTheme = $this->get('liip_theme.active_theme');
$activeTheme = $this->get(ActiveTheme::class);
$activeTheme->setName($config->getTheme());
$this->addFlash(
@ -79,7 +86,7 @@ class ConfigController extends Controller
$pwdForm->handleRequest($request);
if ($pwdForm->isSubmitted() && $pwdForm->isValid()) {
if ($this->get('craue_config')->get('demo_mode_enabled') && $this->get('craue_config')->get('demo_mode_username') === $user->getUsername()) {
if ($this->get(Config::class)->get('demo_mode_enabled') && $this->get(Config::class)->get('demo_mode_username') === $user->getUsername()) {
$message = 'flashes.config.notice.password_not_updated_demo';
} else {
$message = 'flashes.config.notice.password_updated';
@ -258,7 +265,7 @@ class ConfigController extends Controller
$user = $this->getUser();
$user->setEmailTwoFactor(false);
$this->container->get('fos_user.user_manager')->updateUser($user, true);
$this->container->get(UserManagerInterface::class)->updateUser($user, true);
$this->addFlash(
'notice',
@ -285,7 +292,7 @@ class ConfigController extends Controller
$user->setBackupCodes(null);
$user->setEmailTwoFactor(true);
$this->container->get('fos_user.user_manager')->updateUser($user, true);
$this->container->get(UserManagerInterface::class)->updateUser($user, true);
$this->addFlash(
'notice',
@ -311,7 +318,7 @@ class ConfigController extends Controller
$user->setGoogleAuthenticatorSecret('');
$user->setBackupCodes(null);
$this->container->get('fos_user.user_manager')->updateUser($user, true);
$this->container->get(UserManagerInterface::class)->updateUser($user, true);
$this->addFlash(
'notice',
@ -333,7 +340,7 @@ class ConfigController extends Controller
}
$user = $this->getUser();
$secret = $this->get('scheb_two_factor.security.google_authenticator')->generateSecret();
$secret = $this->get(GoogleAuthenticatorInterface::class)->generateSecret();
$user->setGoogleAuthenticatorSecret($secret);
$user->setEmailTwoFactor(false);
@ -348,7 +355,7 @@ class ConfigController extends Controller
$user->setBackupCodes($backupCodesHashed);
$this->container->get('fos_user.user_manager')->updateUser($user, true);
$this->container->get(UserManagerInterface::class)->updateUser($user, true);
$this->addFlash(
'notice',
@ -357,7 +364,7 @@ class ConfigController extends Controller
return $this->render('@WallabagCore/Config/otp_app.html.twig', [
'backupCodes' => $backupCodes,
'qr_code' => $this->get('scheb_two_factor.security.google_authenticator')->getQRContent($user),
'qr_code' => $this->get(GoogleAuthenticatorInterface::class)->getQRContent($user),
'secret' => $secret,
]);
}
@ -377,7 +384,7 @@ class ConfigController extends Controller
$user->setGoogleAuthenticatorSecret(null);
$user->setBackupCodes(null);
$this->container->get('fos_user.user_manager')->updateUser($user, true);
$this->container->get(UserManagerInterface::class)->updateUser($user, true);
return $this->redirect($this->generateUrl('config') . '#set3');
}
@ -389,7 +396,7 @@ class ConfigController extends Controller
*/
public function otpAppCheckAction(Request $request)
{
$isValid = $this->get('scheb_two_factor.security.google_authenticator')->checkCode(
$isValid = $this->get(GoogleAuthenticatorInterface::class)->checkCode(
$this->getUser(),
$request->get('_auth_code')
);
@ -558,7 +565,7 @@ class ConfigController extends Controller
case 'entries':
// SQLite doesn't care about cascading remove, so we need to manually remove associated stuff
// otherwise they won't be removed ...
if ($this->get('doctrine')->getConnection()->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
if ($this->get(ManagerRegistry::class)->getConnection()->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
$this->getDoctrine()->getRepository(Annotation::class)->removeAllByUserId($this->getUser()->getId());
}
@ -568,7 +575,7 @@ class ConfigController extends Controller
$this->get(EntryRepository::class)->removeAllByUserId($this->getUser()->getId());
break;
case 'archived':
if ($this->get('doctrine')->getConnection()->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
if ($this->get(ManagerRegistry::class)->getConnection()->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
$this->removeAnnotationsForArchivedByUserId($this->getUser()->getId());
}
@ -608,10 +615,10 @@ class ConfigController extends Controller
$user = $this->getUser();
// logout current user
$this->get('security.token_storage')->setToken(null);
$this->get(TokenStorageInterface::class)->setToken(null);
$request->getSession()->invalidate();
$em = $this->get('fos_user.user_manager');
$em = $this->get(UserManagerInterface::class);
$em->deleteUser($user);
return $this->redirect($this->generateUrl('fos_user_security_login'));
@ -647,7 +654,7 @@ class ConfigController extends Controller
*/
public function setLocaleAction(Request $request, $language = null)
{
$errors = $this->get('validator')->validate($language, (new LocaleConstraint()));
$errors = $this->get(ValidatorInterface::class)->validate($language, (new LocaleConstraint()));
if (0 === \count($errors)) {
$request->getSession()->set('_locale', $language);

View file

@ -2,14 +2,19 @@
namespace Wallabag\CoreBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use Doctrine\ORM\NoResultException;
use Lexik\Bundle\FormFilterBundle\Filter\FilterBuilderUpdaterInterface;
use Pagerfanta\Doctrine\ORM\QueryAdapter as DoctrineORMAdapter;
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Event\EntryDeletedEvent;
@ -95,7 +100,7 @@ class EntryController extends Controller
$entry->removeTag($tag);
}
} elseif ('delete' === $action) {
$this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
$this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
$em->remove($entry);
}
}
@ -156,9 +161,9 @@ class EntryController extends Controller
$existingEntry = $this->checkIfEntryAlreadyExists($entry);
if (false !== $existingEntry) {
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.entry.notice.entry_already_saved', ['%date%' => $existingEntry->getCreatedAt()->format('d-m-Y')])
$this->get(TranslatorInterface::class)->trans('flashes.entry.notice.entry_already_saved', ['%date%' => $existingEntry->getCreatedAt()->format('d-m-Y')])
);
return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()]));
@ -171,7 +176,7 @@ class EntryController extends Controller
$em->flush();
// entry saved, dispatch event about it!
$this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
$this->get(EventDispatcherInterface::class)->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
return $this->redirect($this->generateUrl('homepage'));
}
@ -199,7 +204,7 @@ class EntryController extends Controller
$em->flush();
// entry saved, dispatch event about it!
$this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
$this->get(EventDispatcherInterface::class)->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
}
return $this->redirect($this->generateUrl('homepage'));
@ -235,7 +240,7 @@ class EntryController extends Controller
$em->persist($entry);
$em->flush();
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
'flashes.entry.notice.entry_updated'
);
@ -352,7 +357,7 @@ class EntryController extends Controller
$entry = $this->get(EntryRepository::class)
->getRandomEntry($this->getUser()->getId(), $type);
} catch (NoResultException $e) {
$bag = $this->get('session')->getFlashBag();
$bag = $this->get(SessionInterface::class)->getFlashBag();
$bag->clear();
$bag->add('notice', 'flashes.entry.notice.no_random_entry');
@ -395,7 +400,7 @@ class EntryController extends Controller
// if refreshing entry failed, don't save it
if ($this->getParameter('wallabag_core.fetching_error_message') === $entry->getContent()) {
$bag = $this->get('session')->getFlashBag();
$bag = $this->get(SessionInterface::class)->getFlashBag();
$bag->clear();
$bag->add('notice', 'flashes.entry.notice.entry_reloaded_failed');
@ -407,7 +412,7 @@ class EntryController extends Controller
$em->flush();
// entry saved, dispatch event about it!
$this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
$this->get(EventDispatcherInterface::class)->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
}
@ -431,7 +436,7 @@ class EntryController extends Controller
$message = 'flashes.entry.notice.entry_archived';
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$message
);
@ -461,7 +466,7 @@ class EntryController extends Controller
$message = 'flashes.entry.notice.entry_starred';
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$message
);
@ -491,13 +496,13 @@ class EntryController extends Controller
);
// entry deleted, dispatch event about it!
$this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
$this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
$em = $this->getDoctrine()->getManager();
$em->remove($entry);
$em->flush();
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
'flashes.entry.notice.entry_deleted'
);
@ -567,7 +572,7 @@ class EntryController extends Controller
*/
public function shareEntryAction(Entry $entry)
{
if (!$this->get('craue_config')->get('share_public')) {
if (!$this->get(Config::class)->get('share_public')) {
throw $this->createAccessDeniedException('Sharing an entry is disabled for this user.');
}
@ -647,7 +652,7 @@ class EntryController extends Controller
$form->submit($request->query->get($form->getName()));
// build the query from the given form object
$this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $qb);
$this->get(FilterBuilderUpdaterInterface::class)->addFilterConditions($form, $qb);
}
$pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false);
@ -706,7 +711,7 @@ class EntryController extends Controller
$this->get(ContentProxy::class)->setDefaultEntryTitle($entry);
}
$this->get('session')->getFlashBag()->add('notice', $message);
$this->get(SessionInterface::class)->getFlashBag()->add('notice', $message);
}
/**

View file

@ -4,7 +4,9 @@ namespace Wallabag\CoreBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
use Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository;
@ -48,9 +50,9 @@ class IgnoreOriginInstanceRuleController extends Controller
$em->persist($ignoreOriginInstanceRule);
$em->flush();
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.ignore_origin_instance_rule.notice.added')
$this->get(TranslatorInterface::class)->trans('flashes.ignore_origin_instance_rule.notice.added')
);
return $this->redirectToRoute('ignore_origin_instance_rules_index');
@ -80,9 +82,9 @@ class IgnoreOriginInstanceRuleController extends Controller
$em->persist($ignoreOriginInstanceRule);
$em->flush();
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.ignore_origin_instance_rule.notice.updated')
$this->get(TranslatorInterface::class)->trans('flashes.ignore_origin_instance_rule.notice.updated')
);
return $this->redirectToRoute('ignore_origin_instance_rules_index');
@ -108,9 +110,9 @@ class IgnoreOriginInstanceRuleController extends Controller
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.ignore_origin_instance_rule.notice.deleted')
$this->get(TranslatorInterface::class)->trans('flashes.ignore_origin_instance_rule.notice.deleted')
);
$em = $this->getDoctrine()->getManager();

View file

@ -2,9 +2,12 @@
namespace Wallabag\CoreBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\CoreBundle\Entity\SiteCredential;
use Wallabag\CoreBundle\Helper\CryptoProxy;
use Wallabag\CoreBundle\Repository\SiteCredentialRepository;
@ -57,9 +60,9 @@ class SiteCredentialController extends Controller
$em->persist($credential);
$em->flush();
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.site_credential.notice.added', ['%host%' => $credential->getHost()])
$this->get(TranslatorInterface::class)->trans('flashes.site_credential.notice.added', ['%host%' => $credential->getHost()])
);
return $this->redirectToRoute('site_credentials_index');
@ -96,9 +99,9 @@ class SiteCredentialController extends Controller
$em->persist($siteCredential);
$em->flush();
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.site_credential.notice.updated', ['%host%' => $siteCredential->getHost()])
$this->get(TranslatorInterface::class)->trans('flashes.site_credential.notice.updated', ['%host%' => $siteCredential->getHost()])
);
return $this->redirectToRoute('site_credentials_index');
@ -128,9 +131,9 @@ class SiteCredentialController extends Controller
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.site_credential.notice.deleted', ['%host%' => $siteCredential->getHost()])
$this->get(TranslatorInterface::class)->trans('flashes.site_credential.notice.deleted', ['%host%' => $siteCredential->getHost()])
);
$em = $this->getDoctrine()->getManager();
@ -146,7 +149,7 @@ class SiteCredentialController extends Controller
*/
private function isSiteCredentialsEnabled()
{
if (!$this->get('craue_config')->get('restricted_access')) {
if (!$this->get(Config::class)->get('restricted_access')) {
throw $this->createNotFoundException('Feature "restricted_access" is disabled, controllers too.');
}
}

View file

@ -8,6 +8,7 @@ use Pagerfanta\Exception\OutOfRangeCurrentPageException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
@ -41,7 +42,7 @@ class TagController extends Controller
$em->persist($entry);
$em->flush();
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
'flashes.tag.notice.tag_added'
);
@ -188,7 +189,7 @@ class TagController extends Controller
$this->getDoctrine()->getManager()->flush();
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
'flashes.tag.notice.tag_renamed'
);

View file

@ -2,12 +2,14 @@
namespace Wallabag\ImportBundle\Command;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Wallabag\ImportBundle\Import\ChromeImport;
use Wallabag\ImportBundle\Import\DeliciousImport;
@ -43,7 +45,7 @@ class ImportCommand extends ContainerAwareCommand
throw new Exception(sprintf('File "%s" not found', $input->getArgument('filepath')));
}
$em = $this->getContainer()->get('doctrine')->getManager();
$em = $this->getContainer()->get(ManagerRegistry::class)->getManager();
// Turning off doctrine default logs queries for saving memory
$em->getConnection()->getConfiguration()->setSQLLogger(null);
@ -64,8 +66,8 @@ class ImportCommand extends ContainerAwareCommand
'main',
$entityUser->getRoles());
$this->getContainer()->get('security.token_storage')->setToken($token);
$user = $this->getContainer()->get('security.token_storage')->getToken()->getUser();
$this->getContainer()->get(TokenStorageInterface::class)->setToken($token);
$user = $this->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser();
switch ($input->getOption('importer')) {
case 'v2':

View file

@ -5,7 +5,9 @@ namespace Wallabag\ImportBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
abstract class BrowserController extends Controller
@ -38,13 +40,13 @@ abstract class BrowserController extends Controller
if (true === $res) {
$summary = $wallabag->getSummary();
$message = $this->get('translator')->trans('flashes.import.notice.summary', [
$message = $this->get(TranslatorInterface::class)->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
]);
if (0 < $summary['queued']) {
$message = $this->get('translator')->trans('flashes.import.notice.summary_with_queue', [
$message = $this->get(TranslatorInterface::class)->trans('flashes.import.notice.summary_with_queue', [
'%queued%' => $summary['queued'],
]);
}
@ -52,14 +54,14 @@ abstract class BrowserController extends Controller
unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$message
);
return $this->redirect($this->generateUrl('homepage'));
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);

View file

@ -2,6 +2,7 @@
namespace Wallabag\ImportBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Import\ChromeImport;
@ -23,9 +24,9 @@ class ChromeController extends BrowserController
{
$service = $this->get(ChromeImport::class);
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
if ($this->get(Config::class)->get('import_with_rabbitmq')) {
$service->setProducer($this->get('old_sound_rabbit_mq.import_chrome_producer'));
} elseif ($this->get('craue_config')->get('import_with_redis')) {
} elseif ($this->get(Config::class)->get('import_with_redis')) {
$service->setProducer($this->get('wallabag_import.producer.redis.chrome'));
}

View file

@ -2,9 +2,12 @@
namespace Wallabag\ImportBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
use Wallabag\ImportBundle\Import\DeliciousImport;
@ -21,9 +24,9 @@ class DeliciousController extends Controller
$delicious = $this->get(DeliciousImport::class);
$delicious->setUser($this->getUser());
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
if ($this->get(Config::class)->get('import_with_rabbitmq')) {
$delicious->setProducer($this->get('old_sound_rabbit_mq.import_delicious_producer'));
} elseif ($this->get('craue_config')->get('import_with_redis')) {
} elseif ($this->get(Config::class)->get('import_with_redis')) {
$delicious->setProducer($this->get('wallabag_import.producer.redis.delicious'));
}
@ -42,13 +45,13 @@ class DeliciousController extends Controller
if (true === $res) {
$summary = $delicious->getSummary();
$message = $this->get('translator')->trans('flashes.import.notice.summary', [
$message = $this->get(TranslatorInterface::class)->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
]);
if (0 < $summary['queued']) {
$message = $this->get('translator')->trans('flashes.import.notice.summary_with_queue', [
$message = $this->get(TranslatorInterface::class)->trans('flashes.import.notice.summary_with_queue', [
'%queued%' => $summary['queued'],
]);
}
@ -56,7 +59,7 @@ class DeliciousController extends Controller
unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$message
);
@ -64,7 +67,7 @@ class DeliciousController extends Controller
return $this->redirect($this->generateUrl('homepage'));
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);

View file

@ -2,6 +2,7 @@
namespace Wallabag\ImportBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Import\ElcuratorImport;
@ -23,9 +24,9 @@ class ElcuratorController extends WallabagController
{
$service = $this->get(ElcuratorImport::class);
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
if ($this->get(Config::class)->get('import_with_rabbitmq')) {
$service->setProducer($this->get('old_sound_rabbit_mq.import_elcurator_producer'));
} elseif ($this->get('craue_config')->get('import_with_redis')) {
} elseif ($this->get(Config::class)->get('import_with_redis')) {
$service->setProducer($this->get('wallabag_import.producer.redis.elcurator'));
}

View file

@ -2,6 +2,7 @@
namespace Wallabag\ImportBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Import\FirefoxImport;
@ -23,9 +24,9 @@ class FirefoxController extends BrowserController
{
$service = $this->get(FirefoxImport::class);
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
if ($this->get(Config::class)->get('import_with_rabbitmq')) {
$service->setProducer($this->get('old_sound_rabbit_mq.import_firefox_producer'));
} elseif ($this->get('craue_config')->get('import_with_redis')) {
} elseif ($this->get(Config::class)->get('import_with_redis')) {
$service->setProducer($this->get('wallabag_import.producer.redis.firefox'));
}

View file

@ -2,9 +2,11 @@
namespace Wallabag\ImportBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use Predis\Client;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Wallabag\ImportBundle\Import\ImportChain;
class ImportController extends Controller
@ -30,11 +32,11 @@ class ImportController extends Controller
$redisNotInstalled = false;
$rabbitNotInstalled = false;
if (!$this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) {
if (!$this->get(AuthorizationCheckerInterface::class)->isGranted('ROLE_SUPER_ADMIN')) {
return $this->render('@WallabagImport/Import/check_queue.html.twig');
}
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
if ($this->get(Config::class)->get('import_with_rabbitmq')) {
// in case rabbit is activated but not installed
try {
$nbRabbitMessages = $this->getTotalMessageInRabbitQueue('pocket')
@ -51,7 +53,7 @@ class ImportController extends Controller
} catch (\Exception $e) {
$rabbitNotInstalled = true;
}
} elseif ($this->get('craue_config')->get('import_with_redis')) {
} elseif ($this->get(Config::class)->get('import_with_redis')) {
$redis = $this->get(Client::class);
try {

View file

@ -2,9 +2,12 @@
namespace Wallabag\ImportBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
use Wallabag\ImportBundle\Import\InstapaperImport;
@ -21,9 +24,9 @@ class InstapaperController extends Controller
$instapaper = $this->get(InstapaperImport::class);
$instapaper->setUser($this->getUser());
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
if ($this->get(Config::class)->get('import_with_rabbitmq')) {
$instapaper->setProducer($this->get('old_sound_rabbit_mq.import_instapaper_producer'));
} elseif ($this->get('craue_config')->get('import_with_redis')) {
} elseif ($this->get(Config::class)->get('import_with_redis')) {
$instapaper->setProducer($this->get('wallabag_import.producer.redis.instapaper'));
}
@ -42,13 +45,13 @@ class InstapaperController extends Controller
if (true === $res) {
$summary = $instapaper->getSummary();
$message = $this->get('translator')->trans('flashes.import.notice.summary', [
$message = $this->get(TranslatorInterface::class)->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
]);
if (0 < $summary['queued']) {
$message = $this->get('translator')->trans('flashes.import.notice.summary_with_queue', [
$message = $this->get(TranslatorInterface::class)->trans('flashes.import.notice.summary_with_queue', [
'%queued%' => $summary['queued'],
]);
}
@ -56,7 +59,7 @@ class InstapaperController extends Controller
unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$message
);
@ -64,7 +67,7 @@ class InstapaperController extends Controller
return $this->redirect($this->generateUrl('homepage'));
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);

View file

@ -2,9 +2,12 @@
namespace Wallabag\ImportBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
use Wallabag\ImportBundle\Import\PinboardImport;
@ -21,9 +24,9 @@ class PinboardController extends Controller
$pinboard = $this->get(PinboardImport::class);
$pinboard->setUser($this->getUser());
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
if ($this->get(Config::class)->get('import_with_rabbitmq')) {
$pinboard->setProducer($this->get('old_sound_rabbit_mq.import_pinboard_producer'));
} elseif ($this->get('craue_config')->get('import_with_redis')) {
} elseif ($this->get(Config::class)->get('import_with_redis')) {
$pinboard->setProducer($this->get('wallabag_import.producer.redis.pinboard'));
}
@ -42,13 +45,13 @@ class PinboardController extends Controller
if (true === $res) {
$summary = $pinboard->getSummary();
$message = $this->get('translator')->trans('flashes.import.notice.summary', [
$message = $this->get(TranslatorInterface::class)->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
]);
if (0 < $summary['queued']) {
$message = $this->get('translator')->trans('flashes.import.notice.summary_with_queue', [
$message = $this->get(TranslatorInterface::class)->trans('flashes.import.notice.summary_with_queue', [
'%queued%' => $summary['queued'],
]);
}
@ -56,7 +59,7 @@ class PinboardController extends Controller
unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$message
);
@ -64,7 +67,7 @@ class PinboardController extends Controller
return $this->redirect($this->generateUrl('homepage'));
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);

View file

@ -2,11 +2,14 @@
namespace Wallabag\ImportBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\ImportBundle\Import\PocketImport;
class PocketController extends Controller
@ -40,7 +43,7 @@ class PocketController extends Controller
->getRequestToken($this->generateUrl('import', [], UrlGeneratorInterface::ABSOLUTE_URL));
if (false === $requestToken) {
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
'flashes.import.notice.failed'
);
@ -50,9 +53,9 @@ class PocketController extends Controller
$form = $request->request->get('form');
$this->get('session')->set('import.pocket.code', $requestToken);
$this->get(SessionInterface::class)->set('import.pocket.code', $requestToken);
if (null !== $form && \array_key_exists('mark_as_read', $form)) {
$this->get('session')->set('mark_as_read', $form['mark_as_read']);
$this->get(SessionInterface::class)->set('mark_as_read', $form['mark_as_read']);
}
return $this->redirect(
@ -69,12 +72,12 @@ class PocketController extends Controller
$message = 'flashes.import.notice.failed';
$pocket = $this->getPocketImportService();
$markAsRead = $this->get('session')->get('mark_as_read');
$this->get('session')->remove('mark_as_read');
$markAsRead = $this->get(SessionInterface::class)->get('mark_as_read');
$this->get(SessionInterface::class)->remove('mark_as_read');
// something bad happend on pocket side
if (false === $pocket->authorize($this->get('session')->get('import.pocket.code'))) {
$this->get('session')->getFlashBag()->add(
if (false === $pocket->authorize($this->get(SessionInterface::class)->get('import.pocket.code'))) {
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$message
);
@ -84,19 +87,19 @@ class PocketController extends Controller
if (true === $pocket->setMarkAsRead($markAsRead)->import()) {
$summary = $pocket->getSummary();
$message = $this->get('translator')->trans('flashes.import.notice.summary', [
$message = $this->get(TranslatorInterface::class)->trans('flashes.import.notice.summary', [
'%imported%' => null !== $summary && \array_key_exists('imported', $summary) ? $summary['imported'] : 0,
'%skipped%' => null !== $summary && \array_key_exists('skipped', $summary) ? $summary['skipped'] : 0,
]);
if (null !== $summary && \array_key_exists('queued', $summary) && 0 < $summary['queued']) {
$message = $this->get('translator')->trans('flashes.import.notice.summary_with_queue', [
$message = $this->get(TranslatorInterface::class)->trans('flashes.import.notice.summary_with_queue', [
'%queued%' => $summary['queued'],
]);
}
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$message
);
@ -114,9 +117,9 @@ class PocketController extends Controller
$pocket = $this->get(PocketImport::class);
$pocket->setUser($this->getUser());
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
if ($this->get(Config::class)->get('import_with_rabbitmq')) {
$pocket->setProducer($this->get('old_sound_rabbit_mq.import_pocket_producer'));
} elseif ($this->get('craue_config')->get('import_with_redis')) {
} elseif ($this->get(Config::class)->get('import_with_redis')) {
$pocket->setProducer($this->get('wallabag_import.producer.redis.pocket'));
}

View file

@ -2,9 +2,12 @@
namespace Wallabag\ImportBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
use Wallabag\ImportBundle\Import\ReadabilityImport;
@ -21,9 +24,9 @@ class ReadabilityController extends Controller
$readability = $this->get(ReadabilityImport::class);
$readability->setUser($this->getUser());
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
if ($this->get(Config::class)->get('import_with_rabbitmq')) {
$readability->setProducer($this->get('old_sound_rabbit_mq.import_readability_producer'));
} elseif ($this->get('craue_config')->get('import_with_redis')) {
} elseif ($this->get(Config::class)->get('import_with_redis')) {
$readability->setProducer($this->get('wallabag_import.producer.redis.readability'));
}
@ -42,13 +45,13 @@ class ReadabilityController extends Controller
if (true === $res) {
$summary = $readability->getSummary();
$message = $this->get('translator')->trans('flashes.import.notice.summary', [
$message = $this->get(TranslatorInterface::class)->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
]);
if (0 < $summary['queued']) {
$message = $this->get('translator')->trans('flashes.import.notice.summary_with_queue', [
$message = $this->get(TranslatorInterface::class)->trans('flashes.import.notice.summary_with_queue', [
'%queued%' => $summary['queued'],
]);
}
@ -56,7 +59,7 @@ class ReadabilityController extends Controller
unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$message
);
@ -64,7 +67,7 @@ class ReadabilityController extends Controller
return $this->redirect($this->generateUrl('homepage'));
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);

View file

@ -6,6 +6,8 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
/**
@ -41,13 +43,13 @@ abstract class WallabagController extends Controller
if (true === $res) {
$summary = $wallabag->getSummary();
$message = $this->get('translator')->trans('flashes.import.notice.summary', [
$message = $this->get(TranslatorInterface::class)->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
]);
if (0 < $summary['queued']) {
$message = $this->get('translator')->trans('flashes.import.notice.summary_with_queue', [
$message = $this->get(TranslatorInterface::class)->trans('flashes.import.notice.summary_with_queue', [
'%queued%' => $summary['queued'],
]);
}
@ -55,7 +57,7 @@ abstract class WallabagController extends Controller
unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$message
);
@ -63,7 +65,7 @@ abstract class WallabagController extends Controller
return $this->redirect($this->generateUrl('homepage'));
}
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);

View file

@ -2,6 +2,7 @@
namespace Wallabag\ImportBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Import\WallabagV1Import;
@ -23,9 +24,9 @@ class WallabagV1Controller extends WallabagController
{
$service = $this->get(WallabagV1Import::class);
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
if ($this->get(Config::class)->get('import_with_rabbitmq')) {
$service->setProducer($this->get('old_sound_rabbit_mq.import_wallabag_v1_producer'));
} elseif ($this->get('craue_config')->get('import_with_redis')) {
} elseif ($this->get(Config::class)->get('import_with_redis')) {
$service->setProducer($this->get('wallabag_import.producer.redis.wallabag_v1'));
}

View file

@ -2,6 +2,7 @@
namespace Wallabag\ImportBundle\Controller;
use Craue\ConfigBundle\Util\Config;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Import\WallabagV2Import;
@ -23,9 +24,9 @@ class WallabagV2Controller extends WallabagController
{
$service = $this->get(WallabagV2Import::class);
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
if ($this->get(Config::class)->get('import_with_rabbitmq')) {
$service->setProducer($this->get('old_sound_rabbit_mq.import_wallabag_v2_producer'));
} elseif ($this->get('craue_config')->get('import_with_redis')) {
} elseif ($this->get(Config::class)->get('import_with_redis')) {
$service->setProducer($this->get('wallabag_import.producer.redis.wallabag_v2'));
}

View file

@ -4,12 +4,17 @@ namespace Wallabag\UserBundle\Controller;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Model\UserManagerInterface;
use Pagerfanta\Doctrine\ORM\QueryAdapter as DoctrineORMAdapter;
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
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\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\UserBundle\Entity\User;
use Wallabag\UserBundle\Form\SearchUserType;
@ -25,7 +30,7 @@ class ManageController extends Controller
*/
public function newAction(Request $request)
{
$userManager = $this->container->get('fos_user.user_manager');
$userManager = $this->container->get(UserManagerInterface::class);
$user = $userManager->createUser();
// enable created user by default
@ -39,11 +44,11 @@ class ManageController extends Controller
// dispatch a created event so the associated config will be created
$event = new UserEvent($user, $request);
$this->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event);
$this->get(EventDispatcherInterface::class)->dispatch(FOSUserEvents::USER_CREATED, $event);
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.user.notice.added', ['%username%' => $user->getUsername()])
$this->get(TranslatorInterface::class)->trans('flashes.user.notice.added', ['%username%' => $user->getUsername()])
);
return $this->redirectToRoute('user_edit', ['id' => $user->getId()]);
@ -62,7 +67,7 @@ class ManageController extends Controller
*/
public function editAction(Request $request, User $user)
{
$userManager = $this->container->get('fos_user.user_manager');
$userManager = $this->container->get(UserManagerInterface::class);
$deleteForm = $this->createDeleteForm($user);
$form = $this->createForm('Wallabag\UserBundle\Form\UserType', $user);
@ -77,7 +82,7 @@ class ManageController extends Controller
// handle creation / reset of the OTP secret if checkbox changed from the previous state
if ($this->getParameter('twofactor_auth')) {
if (true === $form->get('googleTwoFactor')->getData() && false === $user->isGoogleAuthenticatorEnabled()) {
$user->setGoogleAuthenticatorSecret($this->get('scheb_two_factor.security.google_authenticator')->generateSecret());
$user->setGoogleAuthenticatorSecret($this->get(GoogleAuthenticatorInterface::class)->generateSecret());
$user->setEmailTwoFactor(false);
} elseif (false === $form->get('googleTwoFactor')->getData() && true === $user->isGoogleAuthenticatorEnabled()) {
$user->setGoogleAuthenticatorSecret(null);
@ -86,9 +91,9 @@ class ManageController extends Controller
$userManager->updateUser($user);
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.user.notice.updated', ['%username%' => $user->getUsername()])
$this->get(TranslatorInterface::class)->trans('flashes.user.notice.updated', ['%username%' => $user->getUsername()])
);
return $this->redirectToRoute('user_edit', ['id' => $user->getId()]);
@ -113,9 +118,9 @@ class ManageController extends Controller
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->get('session')->getFlashBag()->add(
$this->get(SessionInterface::class)->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.user.notice.deleted', ['%username%' => $user->getUsername()])
$this->get(TranslatorInterface::class)->trans('flashes.user.notice.deleted', ['%username%' => $user->getUsername()])
);
$em = $this->getDoctrine()->getManager();