]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #1584 from wallabag/v2-cleanup
authorJeremy Benoist <j0k3r@users.noreply.github.com>
Fri, 15 Jan 2016 15:29:06 +0000 (16:29 +0100)
committerJeremy Benoist <j0k3r@users.noreply.github.com>
Fri, 15 Jan 2016 15:29:06 +0000 (16:29 +0100)
some cleanup

13 files changed:
app/config/config.yml
src/Wallabag/CoreBundle/Controller/EntryController.php
src/Wallabag/CoreBundle/Repository/EntryRepository.php
src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Static/about.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Static/about.html.twig
src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php
src/Wallabag/ImportBundle/Import/PocketImport.php
src/Wallabag/ImportBundle/Import/WallabagV1Import.php
src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php
src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php

index 19e7155dd40464d56afcc12b66e1395c8fa6476f..2326246911d61c3e51f238bba0151ed82b37afc5 100644 (file)
@@ -60,7 +60,6 @@ twig:
         twofactor_auth: %twofactor_auth%
         warning_message: %warning_message%
         paypal_url: "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9UBA65LG3FX9Y&lc=gb"
-        flattr_url: "https://flattr.com/thing/1265480"
     form_themes:
         - "LexikFormFilterBundle:Form:form_div_layout.html.twig"
 
index aa70307b15e29b930ef47726d2daad262892eaa5..9dd904f1a5e2efd97d6bca17dc866e08724c6c25 100644 (file)
@@ -49,8 +49,7 @@ class EntryController extends Controller
 
         if ($form->isValid()) {
             // check for existing entry, if it exists, redirect to it with a message
-            $existingEntry = $this->get('wallabag_core.entry_repository')
-                ->existByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
+            $existingEntry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
 
             if (false !== $existingEntry) {
                 $this->get('session')->getFlashBag()->add(
index a16be9e01924d4cefb89b6a37db999fb341ef704..82eb947462ea1db1e7653d9ffc725313c04ab127 100644 (file)
@@ -235,10 +235,9 @@ class EntryRepository extends EntityRepository
      *
      * @return array|bool
      */
-    public function existByUrlAndUserId($url, $userId)
+    public function findByUrlAndUserId($url, $userId)
     {
         $res = $this->createQueryBuilder('e')
-            ->select('e.id, e.createdAt')
             ->where('e.url = :url')->setParameter('url', $url)
             ->andWhere('e.user = :user_id')->setParameter('user_id', $userId)
             ->getQuery()
index b981882708160541ca55ab0974f880fdee559fba..8b75594c982d67edc17e8e354b371cbd04be23e2 100644 (file)
@@ -93,7 +93,6 @@ or: "oder"
 "by contributing to the project:": "indem du zu dem Projekt beiträgst:"
 an issue lists all our needs: "ein Issue listet alle unsere Bedürfnisse:"
 via Paypal: "via PayPal"
-via Flattr: "via Flattr"
 
 # Howto
 Form: Formular
index 941237bf5777e08a43c285af1120968d77c1d2a5..20f4352b0aee68242269a95732137eaf3f1567b3 100644 (file)
@@ -94,7 +94,6 @@ or: "ou"
 "by contributing to the project:": "en contribuant au projet :"
 an issue lists all our needs: "un ticket recense tous nos besoins"
 via Paypal: "via Paypal"
-via Flattr: "via Flattr"
 
 # Howto
 Form: "Formulaire"
@@ -163,4 +162,4 @@ Support: "Support"
 If you need some help, we are here for you.: "Parce que vous avez peut-être besoin de nous poser une question, nous sommes disponibles pour vous."
 On GitHub: "Sur GitHub"
 By email: "Par email"
-On Gitter: "Sur Gitter"
\ No newline at end of file
+On Gitter: "Sur Gitter"
index 311b5067a21ad72d9839a07a09a3d86f4f8bcd4f..38f08da6b0da2bd9a902f01253290fe4c9bcf90f 100755 (executable)
@@ -41,7 +41,5 @@
         <dt>{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}</dt>
         <dd>by contributing to the project: <a href="https://github.com/wallabag/wallabag/issues/1254">an issue lists all our needs</a></dd>
         <dd><a href="{{ paypal_url }}">{% trans %}via Paypal{% endtrans %}</a></dd>
-
-        <dd><a href="{{ flattr_url }}">{% trans %}via Flattr{% endtrans %}</a></dd>
     </dl>
 {% endblock %}
index ef1fe916330fc5d4378c1bcac8e9bc90a72518b8..d6b8e28a29f8c6f93621772d9ba6bc1fade82cd4 100755 (executable)
@@ -46,8 +46,6 @@
                             <dt>{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}</dt>
                             <dd>{% trans %}by contributing to the project:{% endtrans %} <a href="https://github.com/wallabag/wallabag/issues/1254">{% trans %}an issue lists all our needs{% endtrans %}</a></dd>
                             <dd><a href="{{ paypal_url }}">{% trans %}via Paypal{% endtrans %}</a></dd>
-
-                            <dd><a href="{{ flattr_url }}">{% trans %}via Flattr{% endtrans %}</a></dd>
                         </dl>
                     </div>
 
index 3a77518245e068bbb985ff6cba5adbb20a2a2107..1d1620dc268bb434c50a83fc57a5a22d9ab04982 100644 (file)
@@ -38,7 +38,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $form = $crawler->filter('button[type=submit]')->form();
 
         $data = array(
-            'entry[url]' => 'https://www.wallabag.org/blog/2016/01/08/wallabag-alpha1-v2',
+            'entry[url]' => $this->url,
         );
 
         $client->submit($form, $data);
@@ -82,7 +82,7 @@ class EntryControllerTest extends WallabagCoreTestCase
             ->get('doctrine.orm.entity_manager');
         $entry = $em
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUrl($this->url);
+            ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
         $em->remove($entry);
         $em->flush();
     }
@@ -202,7 +202,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUrl($this->url);
+            ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
 
         $client->request('GET', '/view/'.$content->getId());
 
@@ -223,7 +223,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUrl($this->url);
+            ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
 
         // empty content
         $content->setContent('');
@@ -237,7 +237,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUrl($this->url);
+            ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
 
         $this->assertNotEmpty($content->getContent());
     }
@@ -250,7 +250,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUrl($this->url);
+            ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
 
         $crawler = $client->request('GET', '/edit/'.$content->getId());
 
@@ -268,7 +268,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUrl($this->url);
+            ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
 
         $crawler = $client->request('GET', '/edit/'.$content->getId());
 
@@ -298,7 +298,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUrl($this->url);
+            ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
 
         $client->request('GET', '/archive/'.$content->getId());
 
@@ -320,7 +320,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUrl($this->url);
+            ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
 
         $client->request('GET', '/star/'.$content->getId());
 
@@ -342,7 +342,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUrl($this->url);
+            ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
 
         $client->request('GET', '/delete/'.$content->getId());
 
index ce3cabe8d36af3f82d8c782a7d7855c1eb0245c1..c4905478b27552e4304b23908e0069fff65e2389 100644 (file)
@@ -31,4 +31,21 @@ abstract class WallabagCoreTestCase extends WebTestCase
 
         $this->client->submit($form, $data);
     }
+
+    /**
+     * Return the user id of the logged in user.
+     * You should be sure that you called `logInAs` before.
+     *
+     * @return int
+     */
+    public function getLoggedInUserId()
+    {
+        $token = static::$kernel->getContainer()->get('security.token_storage')->getToken();
+
+        if (null !== $token) {
+            return $token->getUser()->getId();
+        }
+
+        throw new \RuntimeException('No logged in User.');
+    }
 }
index cdcec1e283b279badc2eacbf662ef56272238d93..72b9047c8fdc3acc39267b67a4af11adc31f2634 100644 (file)
@@ -214,7 +214,7 @@ class PocketImport implements ImportInterface
 
             $existingEntry = $this->em
                 ->getRepository('WallabagCoreBundle:Entry')
-                ->existByUrlAndUserId($url, $this->user->getId());
+                ->findByUrlAndUserId($url, $this->user->getId());
 
             if (false !== $existingEntry) {
                 ++$this->skippedEntries;
index 393089d63f1e6f6c4ad3ff9d305ad44b575498a0..6f8feaf36b2924c0bc2ea717103bfa59689ef5d7 100644 (file)
@@ -127,7 +127,7 @@ class WallabagV1Import implements ImportInterface
         foreach ($entries as $importedEntry) {
             $existingEntry = $this->em
                 ->getRepository('WallabagCoreBundle:Entry')
-                ->existByUrlAndUserId($importedEntry['url'], $this->user->getId());
+                ->findByUrlAndUserId($importedEntry['url'], $this->user->getId());
 
             if (false !== $existingEntry) {
                 ++$this->skippedEntries;
index 043b2114e802711e46666c8e6df42fa4e0333921..76225fe4f21be2b119f7b17b9c247a7e5f3d1dc4 100644 (file)
@@ -248,7 +248,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
             ->getMock();
 
         $entryRepo->expects($this->exactly(2))
-            ->method('existByUrlAndUserId')
+            ->method('findByUrlAndUserId')
             ->will($this->onConsecutiveCalls(false, true));
 
         $tag = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Tag')
index d5b41777caf041f0f6b46b5571bf2f2eb21fd1e9..90483480816d5c212d52f100dd4a75a69b4687c1 100644 (file)
@@ -53,7 +53,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
             ->getMock();
 
         $entryRepo->expects($this->exactly(3))
-            ->method('existByUrlAndUserId')
+            ->method('findByUrlAndUserId')
             ->will($this->onConsecutiveCalls(false, true, false));
 
         $this->em