forked from wallabag/wallabag
Migrate getRepository with entities
This commit is contained in:
@ -7,6 +7,7 @@ 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 Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\CoreBundle\Helper\UrlHasher;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
@ -40,7 +41,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
$users = $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findAll();
|
||||
$users = $this->getDoctrine()->getRepository(User::class)->findAll();
|
||||
|
||||
$output->writeln(sprintf('Generating hashed urls for "%d" users', \count($users)));
|
||||
|
||||
@ -57,7 +58,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
|
||||
private function generateHashedUrls(User $user)
|
||||
{
|
||||
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$repo = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry');
|
||||
$repo = $this->getDoctrine()->getRepository(Entry::class);
|
||||
|
||||
$entries = $repo->findByEmptyHashedUrlAndUserId($user->getId());
|
||||
|
||||
@ -86,7 +87,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
|
||||
*/
|
||||
private function getUser($username)
|
||||
{
|
||||
return $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findOneByUserName($username);
|
||||
return $this->getDoctrine()->getRepository(User::class)->findOneByUserName($username);
|
||||
}
|
||||
|
||||
private function getDoctrine()
|
||||
|
||||
@ -13,6 +13,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
|
||||
use Wallabag\AnnotationBundle\Entity\Annotation;
|
||||
use Wallabag\CoreBundle\Entity\Config;
|
||||
use Wallabag\CoreBundle\Entity\IgnoreOriginUserRule;
|
||||
use Wallabag\CoreBundle\Entity\RuleInterface;
|
||||
@ -132,7 +133,7 @@ class ConfigController extends Controller
|
||||
|
||||
if ($request->query->has('tagging-rule')) {
|
||||
$taggingRule = $this->getDoctrine()
|
||||
->getRepository('WallabagCoreBundle:TaggingRule')
|
||||
->getRepository(TaggingRule::class)
|
||||
->find($request->query->get('tagging-rule'));
|
||||
|
||||
if ($this->getUser()->getId() !== $taggingRule->getConfig()->getUser()->getId()) {
|
||||
@ -195,7 +196,7 @@ class ConfigController extends Controller
|
||||
|
||||
if ($request->query->has('ignore-origin-user-rule')) {
|
||||
$ignoreOriginUserRule = $this->getDoctrine()
|
||||
->getRepository('WallabagCoreBundle:IgnoreOriginUserRule')
|
||||
->getRepository(IgnoreOriginUserRule::class)
|
||||
->find($request->query->get('ignore-origin-user-rule'));
|
||||
|
||||
if ($this->getUser()->getId() !== $ignoreOriginUserRule->getConfig()->getUser()->getId()) {
|
||||
@ -548,7 +549,7 @@ class ConfigController extends Controller
|
||||
switch ($type) {
|
||||
case 'annotations':
|
||||
$this->getDoctrine()
|
||||
->getRepository('WallabagAnnotationBundle:Annotation')
|
||||
->getRepository(Annotation::class)
|
||||
->removeAllByUserId($this->getUser()->getId());
|
||||
break;
|
||||
case 'tags':
|
||||
@ -558,7 +559,7 @@ class ConfigController extends Controller
|
||||
// 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) {
|
||||
$this->getDoctrine()->getRepository('WallabagAnnotationBundle:Annotation')->removeAllByUserId($this->getUser()->getId());
|
||||
$this->getDoctrine()->getRepository(Annotation::class)->removeAllByUserId($this->getUser()->getId());
|
||||
}
|
||||
|
||||
// manually remove tags to avoid orphan tag
|
||||
@ -735,7 +736,7 @@ class ConfigController extends Controller
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$archivedEntriesAnnotations = $this->getDoctrine()
|
||||
->getRepository('WallabagAnnotationBundle:Annotation')
|
||||
->getRepository(Annotation::class)
|
||||
->findAllArchivedEntriesByUser($userId);
|
||||
|
||||
foreach ($archivedEntriesAnnotations as $archivedEntriesAnnotation) {
|
||||
@ -764,7 +765,7 @@ class ConfigController extends Controller
|
||||
private function getConfig()
|
||||
{
|
||||
$config = $this->getDoctrine()
|
||||
->getRepository('WallabagCoreBundle:Config')
|
||||
->getRepository(Config::class)
|
||||
->findOneByUser($this->getUser());
|
||||
|
||||
// should NEVER HAPPEN ...
|
||||
|
||||
Reference in New Issue
Block a user