]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverter.php
php-cs-fixer
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / ParamConverter / UsernameRssTokenConverter.php
index ea2bda1750db3584d9973df1037cd11f74d20499..4a2fcab5ffc9428b35d7fd8a0d55188d29a00007 100644 (file)
@@ -2,12 +2,12 @@
 
 namespace Wallabag\CoreBundle\ParamConverter;
 
-use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
 use Doctrine\Common\Persistence\ManagerRegistry;
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
+use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-use Wallabag\CoreBundle\Entity\User;
+use Wallabag\UserBundle\Entity\User;
 
 /**
  * ParamConverter used in the RSS controller to retrieve the right user according to
@@ -36,7 +36,7 @@ class UsernameRssTokenConverter implements ParamConverterInterface
     {
         // If there is no manager, this means that only Doctrine DBAL is configured
         // In this case we can do nothing and just return
-        if (null === $this->registry || !count($this->registry->getManagers())) {
+        if (null === $this->registry || !\count($this->registry->getManagers())) {
             return false;
         }
 
@@ -49,7 +49,7 @@ class UsernameRssTokenConverter implements ParamConverterInterface
         $em = $this->registry->getManagerForClass($configuration->getClass());
 
         // Check, if class name is what we need
-        if ('Wallabag\CoreBundle\Entity\User' !== $em->getClassMetadata($configuration->getClass())->getName()) {
+        if (null !== $em && 'Wallabag\UserBundle\Entity\User' !== $em->getClassMetadata($configuration->getClass())->getName()) {
             return false;
         }
 
@@ -67,11 +67,10 @@ class UsernameRssTokenConverter implements ParamConverterInterface
     public function apply(Request $request, ParamConverter $configuration)
     {
         $username = $request->attributes->get('username');
-        $rssToken  = $request->attributes->get('token');
+        $rssToken = $request->attributes->get('token');
 
-        // Check, if route attributes exists
-        if (null === $username || null === $rssToken) {
-            throw new \InvalidArgumentException('Route attribute is missing');
+        if (!$request->attributes->has('username') || !$request->attributes->has('token')) {
+            return false;
         }
 
         // Get actual entity manager for class