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

@ -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'
);