]> Raphaël G. Git Repositories - blogbundle/commitdiff
Replace EntityRepository by Repository class
authorRaphaël Gertz <git@rapsys.eu>
Thu, 26 Nov 2026 15:58:31 +0000 (16:58 +0100)
committerRaphaël Gertz <git@rapsys.eu>
Thu, 26 Nov 2026 15:58:31 +0000 (16:58 +0100)
Use manager instead of now private _em attribute
Use datetime_immutable instead of DateTime

Repository/ArticleRepository.php
Repository/KeywordRepository.php
Repository/UserRepository.php

index 9708751067d9b5005e80b699ec3366cfb5b46278..a8ec9dfce35dfe078e4c3da6575c204a7d583d28 100644 (file)
@@ -13,13 +13,15 @@ namespace Rapsys\BlogBundle\Repository;
 
 use Doctrine\ORM\Query\ResultSetMapping;
 
+use Rapsys\BlogBundle\Repository;
+
 /**
  * ArticleRepository
  *
  * This class was generated by the Doctrine ORM. Add your own custom
  * repository methods below.
  */
-class ArticleRepository extends EntityRepository {
+class ArticleRepository extends Repository {
        /**
         * Find article count as int
         *
@@ -46,7 +48,7 @@ SQL;
                $rsm->addScalarResult('count', 'count', 'integer');
 
                //Get result
-               return $this->_em
+               return $this->manager
                        ->createNativeQuery($req, $rsm)
                        ->getSingleScalarResult();
        }
@@ -101,13 +103,13 @@ SQL;
                        ->addScalarResult('k_ids', 'k_ids', 'string')
                        ->addScalarResult('k_slugs', 'k_slugs', 'string')
                        ->addScalarResult('k_titles', 'k_titles', 'string')
-                       ->addScalarResult('created', 'created', 'datetime')
-                       ->addScalarResult('updated', 'updated', 'datetime')
-                       ->addScalarResult('modified', 'modified', 'datetime')
+                       ->addScalarResult('created', 'created', 'datetime_immutable')
+                       ->addScalarResult('updated', 'updated', 'datetime_immutable')
+                       ->addScalarResult('modified', 'modified', 'datetime_immutable')
                        ->addIndexByScalar('id');
 
                //Get result
-               $result = $this->_em
+               $result = $this->manager
                        ->createNativeQuery($req, $rsm)
                        ->setParameter('offset', $page * $count)
                        ->setParameter('count', $count)
@@ -226,12 +228,12 @@ SQL;
                        ->addScalarResult('kat_locales', 'kat_locales', 'string')
                        ->addScalarResult('kat_slugs', 'kat_slugs', 'string')
                        ->addScalarResult('kat_titles', 'kat_titles', 'string')
-                       ->addScalarResult('created', 'created', 'datetime')
-                       ->addScalarResult('updated', 'updated', 'datetime')
-                       ->addScalarResult('modified', 'modified', 'datetime');
+                       ->addScalarResult('created', 'created', 'datetime_immutable')
+                       ->addScalarResult('updated', 'updated', 'datetime_immutable')
+                       ->addScalarResult('modified', 'modified', 'datetime_immutable');
 
                //Get data
-               $data = $this->_em
+               $data = $this->manager
                        ->createNativeQuery($req, $rsm)
                        ->setParameter('id', $id)
                        ->getOneOrNullResult();
index 555f1070f5ad48222f8c99a48c19d11816dd3905..db25c18c4313577732e0b9ff62f63af924702a93 100644 (file)
@@ -13,13 +13,15 @@ namespace Rapsys\BlogBundle\Repository;
 
 use Doctrine\ORM\Query\ResultSetMapping;
 
+use Rapsys\BlogBundle\Repository;
+
 /**
  * KeywordRepository
  *
  * This class was generated by the Doctrine ORM. Add your own custom
  * repository methods below.
  */
-class KeywordRepository extends EntityRepository {
+class KeywordRepository extends Repository {
        /**
         * Find keyword count as int
         *
@@ -46,7 +48,7 @@ SQL;
                $rsm->addScalarResult('count', 'count', 'integer');
 
                //Get result
-               return $this->_em
+               return $this->manager
                        ->createNativeQuery($req, $rsm)
                        ->getSingleScalarResult();
        }
@@ -90,13 +92,13 @@ SQL;
                        ->addScalarResult('description', 'description', 'string')
                        ->addScalarResult('slug', 'slug', 'string')
                        ->addScalarResult('title', 'title', 'string')
-                       ->addScalarResult('created', 'created', 'datetime')
-                       ->addScalarResult('updated', 'updated', 'datetime')
-                       ->addScalarResult('modified', 'modified', 'datetime')
+                       ->addScalarResult('created', 'created', 'datetime_immutable')
+                       ->addScalarResult('updated', 'updated', 'datetime_immutable')
+                       ->addScalarResult('modified', 'modified', 'datetime_immutable')
                        ->addIndexByScalar('id');
 
                //Get result
-               $result = $this->_em
+               $result = $this->manager
                        ->createNativeQuery($req, $rsm)
                        ->setParameter('offset', $page * $count)
                        ->setParameter('count', $count)
@@ -230,12 +232,12 @@ SQL;
                        ->addScalarResult('ckt_locales', 'ckt_locales', 'string')
                        ->addScalarResult('ckt_slugs', 'ckt_slugs', 'string')
                        ->addScalarResult('ckt_titles', 'ckt_titles', 'string')
-                       ->addScalarResult('created', 'created', 'datetime')
-                       ->addScalarResult('updated', 'updated', 'datetime')
-                       ->addScalarResult('modified', 'modified', 'datetime');
+                       ->addScalarResult('created', 'created', 'datetime_immutable')
+                       ->addScalarResult('updated', 'updated', 'datetime_immutable')
+                       ->addScalarResult('modified', 'modified', 'datetime_immutable');
 
                //Get data
-               $data = $this->_em
+               $data = $this->manager
                        ->createNativeQuery($req, $rsm)
                        ->setParameter('id', $id)
                        ->getOneOrNullResult();
index 71b6cd1f9f2c9b08d24d2bce73c2f1ae72c6b169..0a385bf8914a9ae5d8d4c4231c7d33dc14b9ab7c 100644 (file)
@@ -12,6 +12,9 @@
 namespace Rapsys\BlogBundle\Repository;
 
 use Doctrine\ORM\Query\ResultSetMapping;
+
+use Rapsys\BlogBundle\Repository;
+
 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
 use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
@@ -19,7 +22,7 @@ use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
 /**
  * UserRepository
  */
-class UserRepository extends EntityRepository implements PasswordUpgraderInterface {
+class UserRepository extends Repository implements PasswordUpgraderInterface {
        /**
         * Find user count as int
         *
@@ -45,7 +48,7 @@ SQL;
                $rsm->addScalarResult('count', 'count', 'integer');
 
                //Get result
-               return $this->_em
+               return $this->manager
                        ->createNativeQuery($req, $rsm)
                        ->getSingleScalarResult();
        }
@@ -151,9 +154,9 @@ SQL;
                        ->addScalarResult('surname', 'surname', 'string')
                        ->addScalarResult('pseudonym', 'pseudonym', 'string')
                        ->addScalarResult('slug', 'slug', 'string')
-                       ->addScalarResult('created', 'created', 'datetime')
-                       ->addScalarResult('updated', 'updated', 'datetime')
-                       ->addScalarResult('modified', 'modified', 'datetime')
+                       ->addScalarResult('created', 'created', 'datetime_immutable')
+                       ->addScalarResult('updated', 'updated', 'datetime_immutable')
+                       ->addScalarResult('modified', 'modified', 'datetime_immutable')
                        ->addScalarResult('civility', 'civility', 'string')
                        //XXX: is a string because of \n separator
                        ->addScalarResult('g_ids', 'g_ids', 'string')
@@ -175,7 +178,7 @@ SQL;
                        ->addScalarResult('kt_titles', 'kt_titles', 'string');
 
                //Fetch result
-               $res = $this->_em
+               $res = $this->manager
                        ->createNativeQuery($req, $rsm)
                        ->setParameter('offset', $page * $count)
                        ->setParameter('count', $count)
@@ -377,9 +380,9 @@ SQL;
                        ->addScalarResult('surname', 'surname', 'string')
                        ->addScalarResult('pseudonym', 'pseudonym', 'string')
                        ->addScalarResult('slug', 'slug', 'string')
-                       ->addScalarResult('created', 'created', 'datetime')
-                       ->addScalarResult('updated', 'updated', 'datetime')
-                       ->addScalarResult('modified', 'modified', 'datetime')
+                       ->addScalarResult('created', 'created', 'datetime_immutable')
+                       ->addScalarResult('updated', 'updated', 'datetime_immutable')
+                       ->addScalarResult('modified', 'modified', 'datetime_immutable')
                        ->addScalarResult('civility', 'civility', 'string')
                        //XXX: is a string because of \n separator
                        ->addScalarResult('g_ids', 'g_ids', 'string')
@@ -401,7 +404,7 @@ SQL;
                        ->addScalarResult('kt_titles', 'kt_titles', 'string');
 
                //Get data
-               if (($data = $this->_em
+               if (($data = $this->manager
                        ->createNativeQuery($req, $rsm)
                        ->setParameter('id', $id)
                        ->getOneOrNullResult()) === null) {