diff options
Diffstat (limited to 'src/Wallabag/CoreBundle')
12 files changed, 51 insertions, 43 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 624576b5..40111af0 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -17,26 +17,35 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache; | |||
17 | class EntryController extends Controller | 17 | class EntryController extends Controller |
18 | { | 18 | { |
19 | /** | 19 | /** |
20 | * @param Entry $entry | 20 | * Fetch content and update entry. |
21 | * In case it fails, entry will return to avod loosing the data. | ||
22 | * | ||
23 | * @param Entry $entry | ||
24 | * @param string $prefixMessage Should be the translation key: entry_saved or entry_reloaded | ||
25 | * | ||
26 | * @return Entry | ||
21 | */ | 27 | */ |
22 | private function updateEntry(Entry $entry) | 28 | private function updateEntry(Entry $entry, $prefixMessage = 'entry_saved') |
23 | { | 29 | { |
30 | // put default title in case of fetching content failed | ||
31 | $entry->setTitle('No title found'); | ||
32 | |||
33 | $message = 'flashes.entry.notice.'.$prefixMessage; | ||
34 | |||
24 | try { | 35 | try { |
25 | $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl()); | 36 | $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl()); |
26 | |||
27 | $em = $this->getDoctrine()->getManager(); | ||
28 | $em->persist($entry); | ||
29 | $em->flush(); | ||
30 | } catch (\Exception $e) { | 37 | } catch (\Exception $e) { |
31 | $this->get('logger')->error('Error while saving an entry', [ | 38 | $this->get('logger')->error('Error while saving an entry', [ |
32 | 'exception' => $e, | 39 | 'exception' => $e, |
33 | 'entry' => $entry, | 40 | 'entry' => $entry, |
34 | ]); | 41 | ]); |
35 | 42 | ||
36 | return false; | 43 | $message = 'flashes.entry.notice.'.$prefixMessage.'_failed'; |
37 | } | 44 | } |
38 | 45 | ||
39 | return true; | 46 | $this->get('session')->getFlashBag()->add('notice', $message); |
47 | |||
48 | return $entry; | ||
40 | } | 49 | } |
41 | 50 | ||
42 | /** | 51 | /** |
@@ -66,12 +75,11 @@ class EntryController extends Controller | |||
66 | return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()])); | 75 | return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()])); |
67 | } | 76 | } |
68 | 77 | ||
69 | $message = 'flashes.entry.notice.entry_saved'; | 78 | $this->updateEntry($entry); |
70 | if (false === $this->updateEntry($entry)) { | ||
71 | $message = 'flashes.entry.notice.entry_saved_failed'; | ||
72 | } | ||
73 | 79 | ||
74 | $this->get('session')->getFlashBag()->add('notice', $message); | 80 | $em = $this->getDoctrine()->getManager(); |
81 | $em->persist($entry); | ||
82 | $em->flush(); | ||
75 | 83 | ||
76 | return $this->redirect($this->generateUrl('homepage')); | 84 | return $this->redirect($this->generateUrl('homepage')); |
77 | } | 85 | } |
@@ -95,6 +103,10 @@ class EntryController extends Controller | |||
95 | 103 | ||
96 | if (false === $this->checkIfEntryAlreadyExists($entry)) { | 104 | if (false === $this->checkIfEntryAlreadyExists($entry)) { |
97 | $this->updateEntry($entry); | 105 | $this->updateEntry($entry); |
106 | |||
107 | $em = $this->getDoctrine()->getManager(); | ||
108 | $em->persist($entry); | ||
109 | $em->flush(); | ||
98 | } | 110 | } |
99 | 111 | ||
100 | return $this->redirect($this->generateUrl('homepage')); | 112 | return $this->redirect($this->generateUrl('homepage')); |
@@ -316,15 +328,11 @@ class EntryController extends Controller | |||
316 | { | 328 | { |
317 | $this->checkUserAction($entry); | 329 | $this->checkUserAction($entry); |
318 | 330 | ||
319 | $message = 'flashes.entry.notice.entry_reloaded'; | 331 | $this->updateEntry($entry, 'entry_reloaded'); |
320 | if (false === $this->updateEntry($entry)) { | ||
321 | $message = 'flashes.entry.notice.entry_reload_failed'; | ||
322 | } | ||
323 | 332 | ||
324 | $this->get('session')->getFlashBag()->add( | 333 | $em = $this->getDoctrine()->getManager(); |
325 | 'notice', | 334 | $em->persist($entry); |
326 | $message | 335 | $em->flush(); |
327 | ); | ||
328 | 336 | ||
329 | return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()])); | 337 | return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()])); |
330 | } | 338 | } |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 0a7c6e8c..9f051edb 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | # entry_already_saved: 'Entry already saved on %date%' | 415 | # entry_already_saved: 'Entry already saved on %date%' |
416 | # entry_saved: 'Entry saved' | 416 | # entry_saved: 'Entry saved' |
417 | # entry_saved_failed: 'Failed to save entry' | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | # entry_updated: 'Entry updated' | 418 | # entry_updated: 'Entry updated' |
419 | # entry_reloaded: 'Entry reloaded' | 419 | # entry_reloaded: 'Entry reloaded' |
420 | # entry_reload_failed: 'Failed to reload entry' | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'Artikel arkiveret' | 421 | entry_archived: 'Artikel arkiveret' |
422 | entry_unarchived: 'Artikel ikke længere arkiveret' | 422 | entry_unarchived: 'Artikel ikke længere arkiveret' |
423 | entry_starred: 'Artikel markeret som favorit' | 423 | entry_starred: 'Artikel markeret som favorit' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index a400686e..cbfacd55 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | entry_already_saved: 'Eintrag bereits am %date% gespeichert' | 415 | entry_already_saved: 'Eintrag bereits am %date% gespeichert' |
416 | entry_saved: 'Eintrag gespeichert' | 416 | entry_saved: 'Eintrag gespeichert' |
417 | # entry_saved_failed: 'Failed to save entry' | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | entry_updated: 'Eintrag aktualisiert' | 418 | entry_updated: 'Eintrag aktualisiert' |
419 | entry_reloaded: 'Eintrag neugeladen' | 419 | entry_reloaded: 'Eintrag neugeladen' |
420 | entry_reload_failed: 'Neuladen des Eintrags fehlgeschlagen' | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'Artikel archiviert' | 421 | entry_archived: 'Artikel archiviert' |
422 | entry_unarchived: 'Artikel dearchiviert' | 422 | entry_unarchived: 'Artikel dearchiviert' |
423 | entry_starred: 'Artikel favorisiert' | 423 | entry_starred: 'Artikel favorisiert' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index 2d097caf..21e2405c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml | |||
@@ -416,10 +416,10 @@ flashes: | |||
416 | notice: | 416 | notice: |
417 | entry_already_saved: 'Entry already saved on %date%' | 417 | entry_already_saved: 'Entry already saved on %date%' |
418 | entry_saved: 'Entry saved' | 418 | entry_saved: 'Entry saved' |
419 | entry_saved_failed: 'Failed to save entry' | 419 | entry_saved_failed: 'Entry saved but fetching content failed' |
420 | entry_updated: 'Entry updated' | 420 | entry_updated: 'Entry updated' |
421 | entry_reloaded: 'Entry reloaded' | 421 | entry_reloaded: 'Entry reloaded' |
422 | entry_reload_failed: 'Failed to reload entry' | 422 | entry_reload_failed: 'Entry reloaded but fetching content failed' |
423 | entry_archived: 'Entry archived' | 423 | entry_archived: 'Entry archived' |
424 | entry_unarchived: 'Entry unarchived' | 424 | entry_unarchived: 'Entry unarchived' |
425 | entry_starred: 'Entry starred' | 425 | entry_starred: 'Entry starred' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 1dbff022..43f376d4 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | entry_already_saved: 'Entrada ya guardada por %fecha%' | 415 | entry_already_saved: 'Entrada ya guardada por %fecha%' |
416 | entry_saved: 'Entrada guardada' | 416 | entry_saved: 'Entrada guardada' |
417 | # entry_saved_failed: 'Failed to save entry' | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | entry_updated: 'Entrada actualizada' | 418 | entry_updated: 'Entrada actualizada' |
419 | entry_reloaded: 'Entrada recargada' | 419 | entry_reloaded: 'Entrada recargada' |
420 | entry_reload_failed: 'Entrada recargada reprobada' | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'Artículo archivado' | 421 | entry_archived: 'Artículo archivado' |
422 | entry_unarchived: 'Artículo desarchivado' | 422 | entry_unarchived: 'Artículo desarchivado' |
423 | entry_starred: 'Artículo guardado en los favoritos' | 423 | entry_starred: 'Artículo guardado en los favoritos' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index ad13c940..56418ef9 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود' | 415 | entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود' |
416 | entry_saved: 'مقاله ذخیره شد' | 416 | entry_saved: 'مقاله ذخیره شد' |
417 | # entry_saved_failed: 'Failed to save entry' | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | entry_updated: 'مقاله بهروز شد' | 418 | entry_updated: 'مقاله بهروز شد' |
419 | entry_reloaded: 'مقاله بهروز شد' | 419 | entry_reloaded: 'مقاله بهروز شد' |
420 | entry_reload_failed: 'بهروزرسانی مقاله شکست خورد' | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'مقاله بایگانی شد' | 421 | entry_archived: 'مقاله بایگانی شد' |
422 | entry_unarchived: 'مقاله از بایگانی درآمد' | 422 | entry_unarchived: 'مقاله از بایگانی درآمد' |
423 | entry_starred: 'مقاله برگزیده شد' | 423 | entry_starred: 'مقاله برگزیده شد' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 35e5c9d0..bde21866 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml | |||
@@ -416,10 +416,10 @@ flashes: | |||
416 | notice: | 416 | notice: |
417 | entry_already_saved: 'Article déjà sauvergardé le %date%' | 417 | entry_already_saved: 'Article déjà sauvergardé le %date%' |
418 | entry_saved: 'Article enregistré' | 418 | entry_saved: 'Article enregistré' |
419 | entry_saved_failed: "L'enregistrement a échoué" | 419 | entry_saved_failed: 'Article enregistré mais impossible de récupérer le contenu' |
420 | entry_updated: 'Article mis à jour' | 420 | entry_updated: 'Article mis à jour' |
421 | entry_reloaded: 'Article rechargé' | 421 | entry_reloaded: 'Article rechargé' |
422 | entry_reload_failed: "Le rechargement de l'article a échoué" | 422 | entry_reload_failed: "Article mis à jour mais impossible de récupérer le contenu" |
423 | entry_archived: 'Article marqué comme lu' | 423 | entry_archived: 'Article marqué comme lu' |
424 | entry_unarchived: 'Article marqué comme non lu' | 424 | entry_unarchived: 'Article marqué comme non lu' |
425 | entry_starred: 'Article ajouté dans les favoris' | 425 | entry_starred: 'Article ajouté dans les favoris' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 5bc896c3..26bb31ba 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml | |||
@@ -413,10 +413,10 @@ flashes: | |||
413 | notice: | 413 | notice: |
414 | entry_already_saved: 'Contenuto già salvato in data %date%' | 414 | entry_already_saved: 'Contenuto già salvato in data %date%' |
415 | entry_saved: 'Contenuto salvato' | 415 | entry_saved: 'Contenuto salvato' |
416 | # entry_saved_failed: 'Failed to save entry' | 416 | # entry_saved_failed: 'Entry saved but fetching content failed' |
417 | entry_updated: 'Contenuto aggiornato' | 417 | entry_updated: 'Contenuto aggiornato' |
418 | entry_reloaded: 'Contenuto ricaricato' | 418 | entry_reloaded: 'Contenuto ricaricato' |
419 | entry_reload_failed: 'Errore nel ricaricamento del contenuto' | 419 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
420 | entry_archived: 'Contenuto archiviato' | 420 | entry_archived: 'Contenuto archiviato' |
421 | entry_unarchived: 'Contenuto dis-archiviato' | 421 | entry_unarchived: 'Contenuto dis-archiviato' |
422 | entry_starred: 'Contenuto segnato come preferito' | 422 | entry_starred: 'Contenuto segnato come preferito' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index b0194c59..2c4df867 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | entry_already_saved: 'Article ja salvargardat lo %date%' | 415 | entry_already_saved: 'Article ja salvargardat lo %date%' |
416 | entry_saved: 'Article enregistrat' | 416 | entry_saved: 'Article enregistrat' |
417 | entry_saved_failed: "Fracàs de l'enregistrament de l'entrada" | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | entry_updated: 'Article mes a jorn' | 418 | entry_updated: 'Article mes a jorn' |
419 | entry_reloaded: 'Article recargat' | 419 | entry_reloaded: 'Article recargat' |
420 | entry_reload_failed: "Fracàs de l'actualizacion de l'article" | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'Article marcat coma legit' | 421 | entry_archived: 'Article marcat coma legit' |
422 | entry_unarchived: 'Article marcat coma pas legit' | 422 | entry_unarchived: 'Article marcat coma pas legit' |
423 | entry_starred: 'Article apondut dins los favorits' | 423 | entry_starred: 'Article apondut dins los favorits' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 6412ad16..fb821966 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | entry_already_saved: 'Wpis już został dodany %date%' | 415 | entry_already_saved: 'Wpis już został dodany %date%' |
416 | entry_saved: 'Wpis zapisany' | 416 | entry_saved: 'Wpis zapisany' |
417 | entry_saved_failed: 'Zapis artykułu się nie powiódł' | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | entry_updated: 'Wpis zaktualizowany' | 418 | entry_updated: 'Wpis zaktualizowany' |
419 | entry_reloaded: 'Wpis ponownie załadowany' | 419 | entry_reloaded: 'Wpis ponownie załadowany' |
420 | entry_reload_failed: 'Błąd ponownego załadowania' | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'Wpis dodany do archiwum' | 421 | entry_archived: 'Wpis dodany do archiwum' |
422 | entry_unarchived: 'Wpis usunięty z archiwum' | 422 | entry_unarchived: 'Wpis usunięty z archiwum' |
423 | entry_starred: 'Wpis oznaczony gwiazdką' | 423 | entry_starred: 'Wpis oznaczony gwiazdką' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 11b744c7..3d22e29d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | # entry_already_saved: 'Entry already saved on %date%' | 415 | # entry_already_saved: 'Entry already saved on %date%' |
416 | # entry_saved: 'Entry saved' | 416 | # entry_saved: 'Entry saved' |
417 | # entry_saved_failed: 'Failed to save entry' | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | # entry_updated: 'Entry updated' | 418 | # entry_updated: 'Entry updated' |
419 | # entry_reloaded: 'Entry reloaded' | 419 | # entry_reloaded: 'Entry reloaded' |
420 | # entry_reload_failed: 'Failed to reload entry' | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'Articol arhivat' | 421 | entry_archived: 'Articol arhivat' |
422 | entry_unarchived: 'Articol dezarhivat' | 422 | entry_unarchived: 'Articol dezarhivat' |
423 | entry_starred: 'Articol adăugat la favorite' | 423 | entry_starred: 'Articol adăugat la favorite' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index d6aaacfe..5099b002 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | entry_already_saved: 'Entry already saved on %date%' | 415 | entry_already_saved: 'Entry already saved on %date%' |
416 | entry_saved: 'Makale kaydedildi' | 416 | entry_saved: 'Makale kaydedildi' |
417 | # entry_saved_failed: 'Failed to save entry' | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | # entry_updated: 'Entry updated' | 418 | # entry_updated: 'Entry updated' |
419 | entry_reloaded: 'Makale içeriği yenilendi' | 419 | entry_reloaded: 'Makale içeriği yenilendi' |
420 | # entry_reload_failed: 'Failed to reload entry' | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'Makale arşivlendi' | 421 | entry_archived: 'Makale arşivlendi' |
422 | entry_unarchived: 'Makale arşivden çıkartıldı' | 422 | entry_unarchived: 'Makale arşivden çıkartıldı' |
423 | entry_starred: 'Makale favorilere eklendi' | 423 | entry_starred: 'Makale favorilere eklendi' |