Migrate getRepository with entities

This commit is contained in:
Yassine Guedidi
2022-08-25 21:37:10 +02:00
parent 50a941d8b4
commit 8b7b4975d6
38 changed files with 226 additions and 202 deletions

View File

@ -19,7 +19,7 @@ class DeveloperController extends Controller
*/
public function indexAction()
{
$clients = $this->getDoctrine()->getRepository('WallabagApiBundle:Client')->findByUser($this->getUser()->getId());
$clients = $this->getDoctrine()->getRepository(Client::class)->findByUser($this->getUser()->getId());
return $this->render('@WallabagCore/themes/common/Developer/index.html.twig', [
'clients' => $clients,

View File

@ -44,7 +44,7 @@ class EntryRestController extends WallabagRestController
public function getEntriesExistsAction(Request $request)
{
$this->validateAuthentication();
$repo = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry');
$repo = $this->getDoctrine()->getRepository(Entry::class);
$returnId = (null === $request->query->get('return_id')) ? false : (bool) $request->query->get('return_id');
@ -753,7 +753,7 @@ class EntryRestController extends WallabagRestController
$label = trim($label);
$tag = $this->getDoctrine()
->getRepository('WallabagCoreBundle:Tag')
->getRepository(Tag::class)
->findOneByLabel($label);
if (false !== $tag) {

View File

@ -22,7 +22,7 @@ class TagRestController extends WallabagRestController
$this->validateAuthentication();
$tags = $this->getDoctrine()
->getRepository('WallabagCoreBundle:Tag')
->getRepository(Tag::class)
->findAllTags($this->getUser()->getId());
$json = $this->get('jms_serializer')->serialize($tags, 'json');
@ -46,7 +46,7 @@ class TagRestController extends WallabagRestController
$this->validateAuthentication();
$label = $request->get('tag', '');
$tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findByLabelsAndUser([$label], $this->getUser()->getId());
$tags = $this->getDoctrine()->getRepository(Tag::class)->findByLabelsAndUser([$label], $this->getUser()->getId());
if (empty($tags)) {
throw $this->createNotFoundException('Tag not found');
@ -55,7 +55,7 @@ class TagRestController extends WallabagRestController
$tag = $tags[0];
$this->getDoctrine()
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->removeTag($this->getUser()->getId(), $tag);
$this->cleanOrphanTag($tag);
@ -82,14 +82,14 @@ class TagRestController extends WallabagRestController
$tagsLabels = $request->get('tags', '');
$tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findByLabelsAndUser(explode(',', $tagsLabels), $this->getUser()->getId());
$tags = $this->getDoctrine()->getRepository(Tag::class)->findByLabelsAndUser(explode(',', $tagsLabels), $this->getUser()->getId());
if (empty($tags)) {
throw $this->createNotFoundException('Tags not found');
}
$this->getDoctrine()
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->removeTags($this->getUser()->getId(), $tags);
$this->cleanOrphanTag($tags);
@ -114,14 +114,14 @@ class TagRestController extends WallabagRestController
{
$this->validateAuthentication();
$tagFromDb = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findByLabelsAndUser([$tag->getLabel()], $this->getUser()->getId());
$tagFromDb = $this->getDoctrine()->getRepository(Tag::class)->findByLabelsAndUser([$tag->getLabel()], $this->getUser()->getId());
if (empty($tagFromDb)) {
throw $this->createNotFoundException('Tag not found');
}
$this->getDoctrine()
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->removeTag($this->getUser()->getId(), $tag);
$this->cleanOrphanTag($tag);