Use FQCN as service name for helper services

This commit is contained in:
Yassine Guedidi 2022-04-24 17:48:59 +02:00
parent 7227d55913
commit 844e8e9d22
16 changed files with 103 additions and 85 deletions

View file

@ -406,7 +406,7 @@ sensio_framework_extra:
httplug: httplug:
clients: clients:
wallabag_core: wallabag_core:
factory: 'wallabag_core.http_client_factory' factory: Wallabag\CoreBundle\Helper\HttpClientFactory
config: config:
defaults: defaults:
timeout: 10 timeout: 10

View file

@ -14,6 +14,9 @@ use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Event\EntryDeletedEvent; use Wallabag\CoreBundle\Event\EntryDeletedEvent;
use Wallabag\CoreBundle\Event\EntrySavedEvent; use Wallabag\CoreBundle\Event\EntrySavedEvent;
use Wallabag\CoreBundle\Helper\ContentProxy;
use Wallabag\CoreBundle\Helper\EntriesExport;
use Wallabag\CoreBundle\Helper\TagsAssigner;
use Wallabag\CoreBundle\Helper\UrlHasher; use Wallabag\CoreBundle\Helper\UrlHasher;
class EntryRestController extends WallabagRestController class EntryRestController extends WallabagRestController
@ -212,7 +215,7 @@ class EntryRestController extends WallabagRestController
$this->validateAuthentication(); $this->validateAuthentication();
$this->validateUserAccess($entry->getUser()->getId()); $this->validateUserAccess($entry->getUser()->getId());
return $this->get('wallabag_core.helper.entries_export') return $this->get(EntriesExport::class)
->setEntries($entry) ->setEntries($entry)
->updateTitle('entry') ->updateTitle('entry')
->updateAuthor('entry') ->updateAuthor('entry')
@ -308,7 +311,7 @@ class EntryRestController extends WallabagRestController
if (false === $entry) { if (false === $entry) {
$entry = new Entry($this->getUser()); $entry = new Entry($this->getUser());
$this->get('wallabag_core.content_proxy')->updateEntry($entry, $url); $this->get(ContentProxy::class)->updateEntry($entry, $url);
} }
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
@ -368,7 +371,7 @@ class EntryRestController extends WallabagRestController
$data = $this->retrieveValueFromRequest($request); $data = $this->retrieveValueFromRequest($request);
try { try {
$this->get('wallabag_core.content_proxy')->updateEntry( $this->get(ContentProxy::class)->updateEntry(
$entry, $entry,
$entry->getUrl(), $entry->getUrl(),
[ [
@ -398,7 +401,7 @@ class EntryRestController extends WallabagRestController
} }
if (!empty($data['tags'])) { if (!empty($data['tags'])) {
$this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $data['tags']); $this->get(TagsAssigner::class)->assignTagsToEntry($entry, $data['tags']);
} }
if (!empty($data['origin_url'])) { if (!empty($data['origin_url'])) {
@ -414,11 +417,11 @@ class EntryRestController extends WallabagRestController
} }
if (empty($entry->getDomainName())) { if (empty($entry->getDomainName())) {
$this->get('wallabag_core.content_proxy')->setEntryDomainName($entry); $this->get(ContentProxy::class)->setEntryDomainName($entry);
} }
if (empty($entry->getTitle())) { if (empty($entry->getTitle())) {
$this->get('wallabag_core.content_proxy')->setDefaultEntryTitle($entry); $this->get(ContentProxy::class)->setDefaultEntryTitle($entry);
} }
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
@ -460,7 +463,7 @@ class EntryRestController extends WallabagRestController
$this->validateAuthentication(); $this->validateAuthentication();
$this->validateUserAccess($entry->getUser()->getId()); $this->validateUserAccess($entry->getUser()->getId());
$contentProxy = $this->get('wallabag_core.content_proxy'); $contentProxy = $this->get(ContentProxy::class);
$data = $this->retrieveValueFromRequest($request); $data = $this->retrieveValueFromRequest($request);
@ -515,7 +518,7 @@ class EntryRestController extends WallabagRestController
if (!empty($data['tags'])) { if (!empty($data['tags'])) {
$entry->removeAllTags(); $entry->removeAllTags();
$this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $data['tags']); $this->get(TagsAssigner::class)->assignTagsToEntry($entry, $data['tags']);
} }
if (null !== $data['isPublic']) { if (null !== $data['isPublic']) {
@ -531,11 +534,11 @@ class EntryRestController extends WallabagRestController
} }
if (empty($entry->getDomainName())) { if (empty($entry->getDomainName())) {
$this->get('wallabag_core.content_proxy')->setEntryDomainName($entry); $this->get(ContentProxy::class)->setEntryDomainName($entry);
} }
if (empty($entry->getTitle())) { if (empty($entry->getTitle())) {
$this->get('wallabag_core.content_proxy')->setDefaultEntryTitle($entry); $this->get(ContentProxy::class)->setDefaultEntryTitle($entry);
} }
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
@ -566,7 +569,7 @@ class EntryRestController extends WallabagRestController
$this->validateUserAccess($entry->getUser()->getId()); $this->validateUserAccess($entry->getUser()->getId());
try { try {
$this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl()); $this->get(ContentProxy::class)->updateEntry($entry, $entry->getUrl());
} catch (\Exception $e) { } catch (\Exception $e) {
$this->get('logger')->error('Error while saving an entry', [ $this->get('logger')->error('Error while saving an entry', [
'exception' => $e, 'exception' => $e,
@ -673,7 +676,7 @@ class EntryRestController extends WallabagRestController
$tags = $request->request->get('tags', ''); $tags = $request->request->get('tags', '');
if (!empty($tags)) { if (!empty($tags)) {
$this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags); $this->get(TagsAssigner::class)->assignTagsToEntry($entry, $tags);
} }
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
@ -802,7 +805,7 @@ class EntryRestController extends WallabagRestController
$tags = $element->tags; $tags = $element->tags;
if (false !== $entry && !(empty($tags))) { if (false !== $entry && !(empty($tags))) {
$this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags); $this->get(TagsAssigner::class)->assignTagsToEntry($entry, $tags);
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$em->persist($entry); $em->persist($entry);

View file

@ -8,6 +8,7 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
use Wallabag\CoreBundle\Helper\DownloadImages;
class CleanDownloadedImagesCommand extends ContainerAwareCommand class CleanDownloadedImagesCommand extends ContainerAwareCommand
{ {
@ -34,7 +35,7 @@ class CleanDownloadedImagesCommand extends ContainerAwareCommand
$io->text('Dry run mode <info>enabled</info> (no images will be removed)'); $io->text('Dry run mode <info>enabled</info> (no images will be removed)');
} }
$downloadImages = $this->getContainer()->get('wallabag_core.entry.download_images'); $downloadImages = $this->getContainer()->get(DownloadImages::class);
$baseFolder = $downloadImages->getBaseFolder(); $baseFolder = $downloadImages->getBaseFolder();
$io->text('Retrieve existing images'); $io->text('Retrieve existing images');

View file

@ -8,6 +8,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
use Wallabag\CoreBundle\Helper\EntriesExport;
use Wallabag\UserBundle\Repository\UserRepository; use Wallabag\UserBundle\Repository\UserRepository;
class ExportCommand extends ContainerAwareCommand class ExportCommand extends ContainerAwareCommand
@ -57,7 +58,7 @@ class ExportCommand extends ContainerAwareCommand
} }
try { try {
$data = $this->getContainer()->get('wallabag_core.helper.entries_export') $data = $this->getContainer()->get(EntriesExport::class)
->setEntries($entries) ->setEntries($entries)
->updateTitle('All') ->updateTitle('All')
->updateAuthor('All') ->updateAuthor('All')

View file

@ -9,6 +9,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
use Wallabag\CoreBundle\Event\EntrySavedEvent; use Wallabag\CoreBundle\Event\EntrySavedEvent;
use Wallabag\CoreBundle\Helper\ContentProxy;
use Wallabag\UserBundle\Repository\UserRepository; use Wallabag\UserBundle\Repository\UserRepository;
class ReloadEntryCommand extends ContainerAwareCommand class ReloadEntryCommand extends ContainerAwareCommand
@ -64,7 +65,7 @@ class ReloadEntryCommand extends ContainerAwareCommand
$progressBar = $io->createProgressBar($nbEntries); $progressBar = $io->createProgressBar($nbEntries);
$contentProxy = $this->getContainer()->get('wallabag_core.content_proxy'); $contentProxy = $this->getContainer()->get(ContentProxy::class);
$em = $this->getContainer()->get('doctrine')->getManager(); $em = $this->getContainer()->get('doctrine')->getManager();
$dispatcher = $this->getContainer()->get('event_dispatcher'); $dispatcher = $this->getContainer()->get('event_dispatcher');

View file

@ -8,6 +8,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
use Wallabag\CoreBundle\Helper\RuleBasedTagger;
use Wallabag\UserBundle\Repository\UserRepository; use Wallabag\UserBundle\Repository\UserRepository;
class TagAllCommand extends ContainerAwareCommand class TagAllCommand extends ContainerAwareCommand
@ -36,7 +37,7 @@ class TagAllCommand extends ContainerAwareCommand
return 1; return 1;
} }
$tagger = $this->getContainer()->get('wallabag_core.rule_based_tagger'); $tagger = $this->getContainer()->get(RuleBasedTagger::class);
$io->text(sprintf('Tagging entries for user <info>%s</info>...', $user->getUserName())); $io->text(sprintf('Tagging entries for user <info>%s</info>...', $user->getUserName()));

View file

@ -18,6 +18,9 @@ use Wallabag\CoreBundle\Form\Type\EditEntryType;
use Wallabag\CoreBundle\Form\Type\EntryFilterType; use Wallabag\CoreBundle\Form\Type\EntryFilterType;
use Wallabag\CoreBundle\Form\Type\NewEntryType; use Wallabag\CoreBundle\Form\Type\NewEntryType;
use Wallabag\CoreBundle\Form\Type\SearchEntryType; use Wallabag\CoreBundle\Form\Type\SearchEntryType;
use Wallabag\CoreBundle\Helper\ContentProxy;
use Wallabag\CoreBundle\Helper\PreparePagerForEntries;
use Wallabag\CoreBundle\Helper\Redirect;
class EntryController extends Controller class EntryController extends Controller
{ {
@ -98,7 +101,7 @@ class EntryController extends Controller
$em->flush(); $em->flush();
} }
$redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer')); $redirectUrl = $this->get(Redirect::class)->to($request->headers->get('referer'));
return $this->redirect($redirectUrl); return $this->redirect($redirectUrl);
} }
@ -431,7 +434,7 @@ class EntryController extends Controller
$message $message
); );
$redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer')); $redirectUrl = $this->get(Redirect::class)->to($request->headers->get('referer'));
return $this->redirect($redirectUrl); return $this->redirect($redirectUrl);
} }
@ -461,7 +464,7 @@ class EntryController extends Controller
$message $message
); );
$redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer')); $redirectUrl = $this->get(Redirect::class)->to($request->headers->get('referer'));
return $this->redirect($redirectUrl); return $this->redirect($redirectUrl);
} }
@ -501,7 +504,7 @@ class EntryController extends Controller
$referer = $request->headers->get('referer'); $referer = $request->headers->get('referer');
$to = (1 !== preg_match('#' . $url . '$#i', $referer) ? $referer : null); $to = (1 !== preg_match('#' . $url . '$#i', $referer) ? $referer : null);
$redirectUrl = $this->get('wallabag_core.helper.redirect')->to($to); $redirectUrl = $this->get(Redirect::class)->to($to);
return $this->redirect($redirectUrl); return $this->redirect($redirectUrl);
} }
@ -647,7 +650,7 @@ class EntryController extends Controller
$pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false); $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false);
$entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')->prepare($pagerAdapter); $entries = $this->get(PreparePagerForEntries::class)->prepare($pagerAdapter);
try { try {
$entries->setCurrentPage($page); $entries->setCurrentPage($page);
@ -683,7 +686,7 @@ class EntryController extends Controller
$message = 'flashes.entry.notice.' . $prefixMessage; $message = 'flashes.entry.notice.' . $prefixMessage;
try { try {
$this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl()); $this->get(ContentProxy::class)->updateEntry($entry, $entry->getUrl());
} catch (\Exception $e) { } catch (\Exception $e) {
$this->get('logger')->error('Error while saving an entry', [ $this->get('logger')->error('Error while saving an entry', [
'exception' => $e, 'exception' => $e,
@ -694,11 +697,11 @@ class EntryController extends Controller
} }
if (empty($entry->getDomainName())) { if (empty($entry->getDomainName())) {
$this->get('wallabag_core.content_proxy')->setEntryDomainName($entry); $this->get(ContentProxy::class)->setEntryDomainName($entry);
} }
if (empty($entry->getTitle())) { if (empty($entry->getTitle())) {
$this->get('wallabag_core.content_proxy')->setDefaultEntryTitle($entry); $this->get(ContentProxy::class)->setDefaultEntryTitle($entry);
} }
$this->get('session')->getFlashBag()->add('notice', $message); $this->get('session')->getFlashBag()->add('notice', $message);

View file

@ -7,6 +7,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Helper\EntriesExport;
/** /**
* The try/catch can be removed once all formats will be implemented. * The try/catch can be removed once all formats will be implemented.
@ -29,7 +30,7 @@ class ExportController extends Controller
public function downloadEntryAction(Entry $entry, $format) public function downloadEntryAction(Entry $entry, $format)
{ {
try { try {
return $this->get('wallabag_core.helper.entries_export') return $this->get(EntriesExport::class)
->setEntries($entry) ->setEntries($entry)
->updateTitle('entry') ->updateTitle('entry')
->updateAuthor('entry') ->updateAuthor('entry')
@ -95,7 +96,7 @@ class ExportController extends Controller
} }
try { try {
return $this->get('wallabag_core.helper.entries_export') return $this->get(EntriesExport::class)
->setEntries($entries) ->setEntries($entries)
->updateTitle($title) ->updateTitle($title)
->updateAuthor($method) ->updateAuthor($method)

View file

@ -14,6 +14,7 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Helper\PreparePagerForEntries;
use Wallabag\UserBundle\Entity\User; use Wallabag\UserBundle\Entity\User;
class FeedController extends Controller class FeedController extends Controller
@ -121,7 +122,7 @@ class FeedController extends Controller
$pagerAdapter = new ArrayAdapter($entriesByTag); $pagerAdapter = new ArrayAdapter($entriesByTag);
$entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')->prepare( $entries = $this->get(PreparePagerForEntries::class)->prepare(
$pagerAdapter, $pagerAdapter,
$user $user
); );

View file

@ -6,6 +6,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Wallabag\CoreBundle\Entity\SiteCredential; use Wallabag\CoreBundle\Entity\SiteCredential;
use Wallabag\CoreBundle\Helper\CryptoProxy;
use Wallabag\UserBundle\Entity\User; use Wallabag\UserBundle\Entity\User;
/** /**
@ -48,8 +49,8 @@ class SiteCredentialController extends Controller
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$credential->setUsername($this->get('wallabag_core.helper.crypto_proxy')->crypt($credential->getUsername())); $credential->setUsername($this->get(CryptoProxy::class)->crypt($credential->getUsername()));
$credential->setPassword($this->get('wallabag_core.helper.crypto_proxy')->crypt($credential->getPassword())); $credential->setPassword($this->get(CryptoProxy::class)->crypt($credential->getPassword()));
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$em->persist($credential); $em->persist($credential);
@ -87,8 +88,8 @@ class SiteCredentialController extends Controller
$editForm->handleRequest($request); $editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) { if ($editForm->isSubmitted() && $editForm->isValid()) {
$siteCredential->setUsername($this->get('wallabag_core.helper.crypto_proxy')->crypt($siteCredential->getUsername())); $siteCredential->setUsername($this->get(CryptoProxy::class)->crypt($siteCredential->getUsername()));
$siteCredential->setPassword($this->get('wallabag_core.helper.crypto_proxy')->crypt($siteCredential->getPassword())); $siteCredential->setPassword($this->get(CryptoProxy::class)->crypt($siteCredential->getPassword()));
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$em->persist($siteCredential); $em->persist($siteCredential);

View file

@ -13,6 +13,9 @@ use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Form\Type\NewTagType; use Wallabag\CoreBundle\Form\Type\NewTagType;
use Wallabag\CoreBundle\Form\Type\RenameTagType; use Wallabag\CoreBundle\Form\Type\RenameTagType;
use Wallabag\CoreBundle\Helper\PreparePagerForEntries;
use Wallabag\CoreBundle\Helper\Redirect;
use Wallabag\CoreBundle\Helper\TagsAssigner;
class TagController extends Controller class TagController extends Controller
{ {
@ -27,7 +30,7 @@ class TagController extends Controller
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$this->get('wallabag_core.tags_assigner')->assignTagsToEntry( $this->get(TagsAssigner::class)->assignTagsToEntry(
$entry, $entry,
$form->get('label')->getData() $form->get('label')->getData()
); );
@ -69,7 +72,7 @@ class TagController extends Controller
$em->flush(); $em->flush();
} }
$redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'), '', true); $redirectUrl = $this->get(Redirect::class)->to($request->headers->get('referer'), '', true);
return $this->redirect($redirectUrl); return $this->redirect($redirectUrl);
} }
@ -117,7 +120,7 @@ class TagController extends Controller
$pagerAdapter = new ArrayAdapter($entriesByTag); $pagerAdapter = new ArrayAdapter($entriesByTag);
$entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')->prepare($pagerAdapter); $entries = $this->get(PreparePagerForEntries::class)->prepare($pagerAdapter);
try { try {
$entries->setCurrentPage($page); $entries->setCurrentPage($page);
@ -152,7 +155,7 @@ class TagController extends Controller
$form = $this->createForm(RenameTagType::class, new Tag()); $form = $this->createForm(RenameTagType::class, new Tag());
$form->handleRequest($request); $form->handleRequest($request);
$redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'), '', true); $redirectUrl = $this->get(Redirect::class)->to($request->headers->get('referer'), '', true);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$newTag = new Tag(); $newTag = new Tag();
@ -173,7 +176,7 @@ class TagController extends Controller
$tag->getId() $tag->getId()
); );
foreach ($entries as $entry) { foreach ($entries as $entry) {
$this->get('wallabag_core.tags_assigner')->assignTagsToEntry( $this->get(TagsAssigner::class)->assignTagsToEntry(
$entry, $entry,
$newTag->getLabel(), $newTag->getLabel(),
[$newTag] [$newTag]
@ -210,7 +213,7 @@ class TagController extends Controller
$entries = $qb->getQuery()->getResult(); $entries = $qb->getQuery()->getResult();
foreach ($entries as $entry) { foreach ($entries as $entry) {
$this->get('wallabag_core.tags_assigner')->assignTagsToEntry( $this->get(TagsAssigner::class)->assignTagsToEntry(
$entry, $entry,
$filter $filter
); );
@ -220,7 +223,7 @@ class TagController extends Controller
$em->flush(); $em->flush();
return $this->redirect($this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'), '', true)); return $this->redirect($this->get(Redirect::class)->to($request->headers->get('referer'), '', true));
} }
/** /**
@ -244,7 +247,7 @@ class TagController extends Controller
$em->flush(); $em->flush();
} }
$redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'), '', true); $redirectUrl = $this->get(Redirect::class)->to($request->headers->get('referer'), '', true);
return $this->redirect($redirectUrl); return $this->redirect($redirectUrl);
} }

View file

@ -8,6 +8,7 @@ use Doctrine\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Wallabag\CoreBundle\Entity\SiteCredential; use Wallabag\CoreBundle\Entity\SiteCredential;
use Wallabag\CoreBundle\Helper\CryptoProxy;
use Wallabag\UserBundle\DataFixtures\UserFixtures; use Wallabag\UserBundle\DataFixtures\UserFixtures;
class SiteCredentialFixtures extends Fixture implements DependentFixtureInterface, ContainerAwareInterface class SiteCredentialFixtures extends Fixture implements DependentFixtureInterface, ContainerAwareInterface
@ -29,15 +30,15 @@ class SiteCredentialFixtures extends Fixture implements DependentFixtureInterfac
{ {
$credential = new SiteCredential($this->getReference('admin-user')); $credential = new SiteCredential($this->getReference('admin-user'));
$credential->setHost('.super.com'); $credential->setHost('.super.com');
$credential->setUsername($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('.super')); $credential->setUsername($this->container->get(CryptoProxy::class)->crypt('.super'));
$credential->setPassword($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('bar')); $credential->setPassword($this->container->get(CryptoProxy::class)->crypt('bar'));
$manager->persist($credential); $manager->persist($credential);
$credential = new SiteCredential($this->getReference('admin-user')); $credential = new SiteCredential($this->getReference('admin-user'));
$credential->setHost('paywall.example.com'); $credential->setHost('paywall.example.com');
$credential->setUsername($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('paywall.example')); $credential->setUsername($this->container->get(CryptoProxy::class)->crypt('paywall.example'));
$credential->setPassword($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('bar')); $credential->setPassword($this->container->get(CryptoProxy::class)->crypt('bar'));
$manager->persist($credential); $manager->persist($credential);

View file

@ -72,38 +72,38 @@ services:
bd_guzzle_site_authenticator.site_config_builder: bd_guzzle_site_authenticator.site_config_builder:
alias: wallabag_core.guzzle_authenticator.config_builder alias: wallabag_core.guzzle_authenticator.config_builder
wallabag_core.http_client_factory: Wallabag\CoreBundle\Helper\HttpClientFactory:
class: Wallabag\CoreBundle\Helper\HttpClientFactory class: Wallabag\CoreBundle\Helper\HttpClientFactory
arguments: arguments:
- "@wallabag_core.guzzle.cookie_jar" - '@Wallabag\CoreBundle\Helper\FileCookieJar'
- '@=service(''craue_config'').get(''restricted_access'')' - '@=service(''craue_config'').get(''restricted_access'')'
- '@logger' - '@logger'
calls: calls:
- ["addSubscriber", ["@bd_guzzle_site_authenticator.authenticator_subscriber"]] - ["addSubscriber", ["@bd_guzzle_site_authenticator.authenticator_subscriber"]]
wallabag_core.guzzle.cookie_jar: Wallabag\CoreBundle\Helper\FileCookieJar:
class: Wallabag\CoreBundle\Helper\FileCookieJar class: Wallabag\CoreBundle\Helper\FileCookieJar
arguments: arguments:
- "@logger" - "@logger"
- "%kernel.cache_dir%/cookiejar.json" - "%kernel.cache_dir%/cookiejar.json"
wallabag_core.content_proxy: Wallabag\CoreBundle\Helper\ContentProxy:
class: Wallabag\CoreBundle\Helper\ContentProxy class: Wallabag\CoreBundle\Helper\ContentProxy
arguments: arguments:
- '@Graby\Graby' - '@Graby\Graby'
- "@wallabag_core.rule_based_tagger" - '@Wallabag\CoreBundle\Helper\RuleBasedTagger'
- "@wallabag_core.rule_based_ignore_origin_processor" - '@Wallabag\CoreBundle\Helper\RuleBasedIgnoreOriginProcessor'
- "@validator" - "@validator"
- "@logger" - "@logger"
- '%wallabag_core.fetching_error_message%' - '%wallabag_core.fetching_error_message%'
- '@=service(''craue_config'').get(''store_article_headers'')' - '@=service(''craue_config'').get(''store_article_headers'')'
wallabag_core.tags_assigner: Wallabag\CoreBundle\Helper\TagsAssigner:
class: Wallabag\CoreBundle\Helper\TagsAssigner class: Wallabag\CoreBundle\Helper\TagsAssigner
arguments: arguments:
- "@wallabag_core.tag_repository" - "@wallabag_core.tag_repository"
wallabag_core.rule_based_tagger: Wallabag\CoreBundle\Helper\RuleBasedTagger:
class: Wallabag\CoreBundle\Helper\RuleBasedTagger class: Wallabag\CoreBundle\Helper\RuleBasedTagger
arguments: arguments:
- "@rulerz" - "@rulerz"
@ -111,7 +111,7 @@ services:
- "@wallabag_core.entry_repository" - "@wallabag_core.entry_repository"
- "@logger" - "@logger"
wallabag_core.rule_based_ignore_origin_processor: Wallabag\CoreBundle\Helper\RuleBasedIgnoreOriginProcessor:
class: Wallabag\CoreBundle\Helper\RuleBasedIgnoreOriginProcessor class: Wallabag\CoreBundle\Helper\RuleBasedIgnoreOriginProcessor
arguments: arguments:
- "@rulerz" - "@rulerz"
@ -137,7 +137,7 @@ services:
arguments: arguments:
- WallabagCoreBundle:SiteCredential - WallabagCoreBundle:SiteCredential
calls: calls:
- [ setCrypto, [ "@wallabag_core.helper.crypto_proxy" ] ] - [ setCrypto, [ '@Wallabag\CoreBundle\Helper\CryptoProxy' ] ]
wallabag_core.ignore_origin_instance_rule_repository: wallabag_core.ignore_origin_instance_rule_repository:
class: Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository class: Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository
@ -145,7 +145,7 @@ services:
arguments: arguments:
- WallabagCoreBundle:IgnoreOriginInstanceRule - WallabagCoreBundle:IgnoreOriginInstanceRule
wallabag_core.helper.entries_export: Wallabag\CoreBundle\Helper\EntriesExport:
class: Wallabag\CoreBundle\Helper\EntriesExport class: Wallabag\CoreBundle\Helper\EntriesExport
arguments: arguments:
- "@translator" - "@translator"
@ -178,13 +178,13 @@ services:
tags: tags:
- { name: rulerz.operator, target: native, operator: "~" } - { name: rulerz.operator, target: native, operator: "~" }
wallabag_core.helper.redirect: Wallabag\CoreBundle\Helper\Redirect:
class: Wallabag\CoreBundle\Helper\Redirect class: Wallabag\CoreBundle\Helper\Redirect
arguments: arguments:
- "@router" - "@router"
- "@security.token_storage" - "@security.token_storage"
wallabag_core.helper.prepare_pager_for_entries: Wallabag\CoreBundle\Helper\PreparePagerForEntries:
class: Wallabag\CoreBundle\Helper\PreparePagerForEntries class: Wallabag\CoreBundle\Helper\PreparePagerForEntries
arguments: arguments:
- "@security.token_storage" - "@security.token_storage"
@ -218,13 +218,13 @@ services:
class: Wallabag\CoreBundle\Event\Subscriber\DownloadImagesSubscriber class: Wallabag\CoreBundle\Event\Subscriber\DownloadImagesSubscriber
arguments: arguments:
- "@doctrine.orm.default_entity_manager" - "@doctrine.orm.default_entity_manager"
- "@wallabag_core.entry.download_images" - '@Wallabag\CoreBundle\Helper\DownloadImages'
- '@=service(''craue_config'').get(''download_images_enabled'')' - '@=service(''craue_config'').get(''download_images_enabled'')'
- "@logger" - "@logger"
tags: tags:
- { name: kernel.event_subscriber } - { name: kernel.event_subscriber }
wallabag_core.entry.download_images: Wallabag\CoreBundle\Helper\DownloadImages:
class: Wallabag\CoreBundle\Helper\DownloadImages class: Wallabag\CoreBundle\Helper\DownloadImages
arguments: arguments:
- "@wallabag_core.entry.download_images.client" - "@wallabag_core.entry.download_images.client"
@ -235,7 +235,7 @@ services:
wallabag_core.entry.download_images.client: wallabag_core.entry.download_images.client:
alias: 'httplug.client.wallabag_core.entry.download_images' alias: 'httplug.client.wallabag_core.entry.download_images'
wallabag_core.helper.crypto_proxy: Wallabag\CoreBundle\Helper\CryptoProxy:
class: Wallabag\CoreBundle\Helper\CryptoProxy class: Wallabag\CoreBundle\Helper\CryptoProxy
arguments: arguments:
- "%wallabag_core.site_credentials.encryption_key_path%" - "%wallabag_core.site_credentials.encryption_key_path%"

View file

@ -13,8 +13,8 @@ services:
class: Wallabag\ImportBundle\Import\PocketImport class: Wallabag\ImportBundle\Import\PocketImport
arguments: arguments:
- "@doctrine.orm.entity_manager" - "@doctrine.orm.entity_manager"
- "@wallabag_core.content_proxy" - '@Wallabag\CoreBundle\Helper\ContentProxy'
- "@wallabag_core.tags_assigner" - '@Wallabag\CoreBundle\Helper\TagsAssigner'
- "@event_dispatcher" - "@event_dispatcher"
calls: calls:
- [ setClient, [ "@wallabag_import.pocket.client" ] ] - [ setClient, [ "@wallabag_import.pocket.client" ] ]
@ -26,8 +26,8 @@ services:
class: Wallabag\ImportBundle\Import\WallabagV1Import class: Wallabag\ImportBundle\Import\WallabagV1Import
arguments: arguments:
- "@doctrine.orm.entity_manager" - "@doctrine.orm.entity_manager"
- "@wallabag_core.content_proxy" - '@Wallabag\CoreBundle\Helper\ContentProxy'
- "@wallabag_core.tags_assigner" - '@Wallabag\CoreBundle\Helper\TagsAssigner'
- "@event_dispatcher" - "@event_dispatcher"
- "%wallabag_core.fetching_error_message_title%" - "%wallabag_core.fetching_error_message_title%"
- "%wallabag_core.fetching_error_message%" - "%wallabag_core.fetching_error_message%"
@ -40,8 +40,8 @@ services:
class: Wallabag\ImportBundle\Import\WallabagV2Import class: Wallabag\ImportBundle\Import\WallabagV2Import
arguments: arguments:
- "@doctrine.orm.entity_manager" - "@doctrine.orm.entity_manager"
- "@wallabag_core.content_proxy" - '@Wallabag\CoreBundle\Helper\ContentProxy'
- "@wallabag_core.tags_assigner" - '@Wallabag\CoreBundle\Helper\TagsAssigner'
- "@event_dispatcher" - "@event_dispatcher"
calls: calls:
- [ setLogger, [ "@logger" ]] - [ setLogger, [ "@logger" ]]
@ -52,8 +52,8 @@ services:
class: Wallabag\ImportBundle\Import\ElcuratorImport class: Wallabag\ImportBundle\Import\ElcuratorImport
arguments: arguments:
- "@doctrine.orm.entity_manager" - "@doctrine.orm.entity_manager"
- "@wallabag_core.content_proxy" - '@Wallabag\CoreBundle\Helper\ContentProxy'
- "@wallabag_core.tags_assigner" - '@Wallabag\CoreBundle\Helper\TagsAssigner'
- "@event_dispatcher" - "@event_dispatcher"
calls: calls:
- [ setLogger, [ "@logger" ]] - [ setLogger, [ "@logger" ]]
@ -64,8 +64,8 @@ services:
class: Wallabag\ImportBundle\Import\ReadabilityImport class: Wallabag\ImportBundle\Import\ReadabilityImport
arguments: arguments:
- "@doctrine.orm.entity_manager" - "@doctrine.orm.entity_manager"
- "@wallabag_core.content_proxy" - '@Wallabag\CoreBundle\Helper\ContentProxy'
- "@wallabag_core.tags_assigner" - '@Wallabag\CoreBundle\Helper\TagsAssigner'
- "@event_dispatcher" - "@event_dispatcher"
calls: calls:
- [ setLogger, [ "@logger" ]] - [ setLogger, [ "@logger" ]]
@ -76,8 +76,8 @@ services:
class: Wallabag\ImportBundle\Import\InstapaperImport class: Wallabag\ImportBundle\Import\InstapaperImport
arguments: arguments:
- "@doctrine.orm.entity_manager" - "@doctrine.orm.entity_manager"
- "@wallabag_core.content_proxy" - '@Wallabag\CoreBundle\Helper\ContentProxy'
- "@wallabag_core.tags_assigner" - '@Wallabag\CoreBundle\Helper\TagsAssigner'
- "@event_dispatcher" - "@event_dispatcher"
calls: calls:
- [ setLogger, [ "@logger" ]] - [ setLogger, [ "@logger" ]]
@ -88,8 +88,8 @@ services:
class: Wallabag\ImportBundle\Import\PinboardImport class: Wallabag\ImportBundle\Import\PinboardImport
arguments: arguments:
- "@doctrine.orm.entity_manager" - "@doctrine.orm.entity_manager"
- "@wallabag_core.content_proxy" - '@Wallabag\CoreBundle\Helper\ContentProxy'
- "@wallabag_core.tags_assigner" - '@Wallabag\CoreBundle\Helper\TagsAssigner'
- "@event_dispatcher" - "@event_dispatcher"
calls: calls:
- [ setLogger, [ "@logger" ]] - [ setLogger, [ "@logger" ]]
@ -100,8 +100,8 @@ services:
class: Wallabag\ImportBundle\Import\DeliciousImport class: Wallabag\ImportBundle\Import\DeliciousImport
arguments: arguments:
- "@doctrine.orm.entity_manager" - "@doctrine.orm.entity_manager"
- "@wallabag_core.content_proxy" - '@Wallabag\CoreBundle\Helper\ContentProxy'
- "@wallabag_core.tags_assigner" - '@Wallabag\CoreBundle\Helper\TagsAssigner'
- "@event_dispatcher" - "@event_dispatcher"
calls: calls:
- [ setLogger, [ "@logger" ]] - [ setLogger, [ "@logger" ]]
@ -112,8 +112,8 @@ services:
class: Wallabag\ImportBundle\Import\FirefoxImport class: Wallabag\ImportBundle\Import\FirefoxImport
arguments: arguments:
- "@doctrine.orm.entity_manager" - "@doctrine.orm.entity_manager"
- "@wallabag_core.content_proxy" - '@Wallabag\CoreBundle\Helper\ContentProxy'
- "@wallabag_core.tags_assigner" - '@Wallabag\CoreBundle\Helper\TagsAssigner'
- "@event_dispatcher" - "@event_dispatcher"
calls: calls:
- [ setLogger, [ "@logger" ]] - [ setLogger, [ "@logger" ]]
@ -124,8 +124,8 @@ services:
class: Wallabag\ImportBundle\Import\ChromeImport class: Wallabag\ImportBundle\Import\ChromeImport
arguments: arguments:
- "@doctrine.orm.entity_manager" - "@doctrine.orm.entity_manager"
- "@wallabag_core.content_proxy" - '@Wallabag\CoreBundle\Helper\ContentProxy'
- "@wallabag_core.tags_assigner" - '@Wallabag\CoreBundle\Helper\TagsAssigner'
- "@event_dispatcher" - "@event_dispatcher"
calls: calls:
- [ setLogger, [ "@logger" ]] - [ setLogger, [ "@logger" ]]

View file

@ -564,7 +564,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
$contentProxy->expects($this->any()) $contentProxy->expects($this->any())
->method('updateEntry') ->method('updateEntry')
->willThrowException(new \Exception('Test Fetch content fails')); ->willThrowException(new \Exception('Test Fetch content fails'));
$container->set('wallabag_core.content_proxy', $contentProxy); $container->set(ContentProxy::class, $contentProxy);
try { try {
$this->client->request('POST', '/api/entries.json', [ $this->client->request('POST', '/api/entries.json', [

View file

@ -9,6 +9,7 @@ use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\SiteCredential; use Wallabag\CoreBundle\Entity\SiteCredential;
use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Helper\ContentProxy; use Wallabag\CoreBundle\Helper\ContentProxy;
use Wallabag\CoreBundle\Helper\CryptoProxy;
class EntryControllerTest extends WallabagCoreTestCase class EntryControllerTest extends WallabagCoreTestCase
{ {
@ -1553,8 +1554,8 @@ class EntryControllerTest extends WallabagCoreTestCase
$user = $client->getContainer()->get('security.token_storage')->getToken()->getUser(); $user = $client->getContainer()->get('security.token_storage')->getToken()->getUser();
$credential = new SiteCredential($user); $credential = new SiteCredential($user);
$credential->setHost('monde-diplomatique.fr'); $credential->setHost('monde-diplomatique.fr');
$credential->setUsername($client->getContainer()->get('wallabag_core.helper.crypto_proxy')->crypt('foo')); $credential->setUsername($client->getContainer()->get(CryptoProxy::class)->crypt('foo'));
$credential->setPassword($client->getContainer()->get('wallabag_core.helper.crypto_proxy')->crypt('bar')); $credential->setPassword($client->getContainer()->get(CryptoProxy::class)->crypt('bar'));
$em->persist($credential); $em->persist($credential);
$em->flush(); $em->flush();
@ -1621,7 +1622,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$cookie = $client->getCookieJar()->all(); $cookie = $client->getCookieJar()->all();
$client = $this->getNewClient(); $client = $this->getNewClient();
$client->getCookieJar()->set($cookie[0]); $client->getCookieJar()->set($cookie[0]);
$client->getContainer()->set('wallabag_core.content_proxy', $contentProxy); $client->getContainer()->set(ContentProxy::class, $contentProxy);
$client->submit($form, $data); $client->submit($form, $data);
$this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertSame(302, $client->getResponse()->getStatusCode());