From: Raphaƫl Gertz Date: Thu, 3 Dec 2026 03:03:51 +0000 (+0100) Subject: Replace _em now private with manager member variable X-Git-Tag: 0.6.0~4 X-Git-Url: https://git.rapsys.eu/airbundle/commitdiff_plain/bda45c555c96461e7a0e9533360c2d79fa805438?ds=inline Replace _em now private with manager member variable Replace datetime by datetime_immutable --- diff --git a/Repository/DanceRepository.php b/Repository/DanceRepository.php index f7986d1..1902822 100644 --- a/Repository/DanceRepository.php +++ b/Repository/DanceRepository.php @@ -54,7 +54,7 @@ SQL; ->addIndexByColumn('d', 'id'); //Return return - return $this->_em + return $this->manager ->createNativeQuery($req, $rsm) ->getResult(); } @@ -92,7 +92,7 @@ SQL; ->addIndexByScalar('name'); //Get result - $result = $this->_em + $result = $this->manager ->createNativeQuery($req, $rsm) ->getArrayResult(); @@ -153,7 +153,7 @@ SQL; $rsm->addScalarResult('id', 'id', 'integer'); //Return result - return $this->_em + return $this->manager ->createNativeQuery($req, $rsm) ->setParameter('nametype', $nametype) //XXX: instead of array_column on the result @@ -191,11 +191,11 @@ SQL; $rsm->addScalarResult('id', 'id', 'integer') ->addScalarResult('name', 'name', 'string') ->addScalarResult('type', 'type', 'string') - ->addScalarResult('modified', 'modified', 'datetime') + ->addScalarResult('modified', 'modified', 'datetime_immutable') ->addIndexByScalar('id'); //Get result - $result = $this->_em + $result = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('id', $id) ->getOneOrNullResult(); @@ -297,11 +297,11 @@ SQL; $rsm->addScalarResult('name', 'name', 'string') ->addScalarResult('ids', 'ids', 'string') ->addScalarResult('types', 'types', 'string') - ->addScalarResult('modified', 'modified', 'datetime') + ->addScalarResult('modified', 'modified', 'datetime_immutable') ->addIndexByScalar('name'); //Get result - $result = $this->_em + $result = $this->manager ->createNativeQuery($req, $rsm) ->getArrayResult(); @@ -374,7 +374,7 @@ WHERE ud.user_id = :uid'; $rsm->addFieldResult('d', 'type', 'type'); //Send result - return $this->_em + return $this->manager ->createNativeQuery($req, $rsm) ->setParameter('uid', $userId) ->getResult(); diff --git a/Repository/GoogleTokenRepository.php b/Repository/GoogleTokenRepository.php index 29b96d2..4aecf6c 100644 --- a/Repository/GoogleTokenRepository.php +++ b/Repository/GoogleTokenRepository.php @@ -95,8 +95,8 @@ SQL; ->addScalarResult('uid', 'uid', 'integer') ->addScalarResult('access', 'access', 'string') ->addScalarResult('refresh', 'refresh', 'string') - ->addScalarResult('created', 'created', 'datetime') - ->addScalarResult('expired', 'expired', 'datetime') + ->addScalarResult('created', 'created', 'datetime_immutable') + ->addScalarResult('expired', 'expired', 'datetime_immutable') ->addScalarResult('cids', 'cids', 'string') ->addScalarResult('cmails', 'cmails', 'string') ->addScalarResult('csummaries', 'csummaries', 'string') @@ -109,7 +109,7 @@ SQL; $result = []; //Get tokens - $tokens = $this->_em + $tokens = $this->manager ->createNativeQuery($req, $rsm) ->getArrayResult(); diff --git a/Repository/LocationRepository.php b/Repository/LocationRepository.php index 9b621ef..55ac403 100644 --- a/Repository/LocationRepository.php +++ b/Repository/LocationRepository.php @@ -73,10 +73,10 @@ SQL; ->addScalarResult('longitude', 'longitude', 'float') ->addScalarResult('indoor', 'indoor', 'boolean') ->addScalarResult('count', 'count', 'integer') - ->addScalarResult('updated', 'updated', 'datetime'); + ->addScalarResult('updated', 'updated', 'datetime_immutable'); //Get result - $result = $this->_em + $result = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('begin', $period->getStartDate()) ->setParameter('end', $period->getEndDate()) @@ -174,11 +174,11 @@ SQL; ->addScalarResult('indoors', 'indoors', 'string') //XXX: is a string because of \n separator ->addScalarResult('counts', 'counts', 'string') - ->addScalarResult('modified', 'modified', 'datetime') + ->addScalarResult('modified', 'modified', 'datetime_immutable') ->addIndexByScalar('city'); //Get result - $result = $this->_em + $result = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('begin', $period->getStartDate()) ->setParameter('end', $period->getEndDate()) @@ -291,11 +291,11 @@ SQL; ->addScalarResult('city', 'city', 'string') ->addScalarResult('latitude', 'latitude', 'float') ->addScalarResult('longitude', 'longitude', 'float') - ->addScalarResult('updated', 'updated', 'datetime') + ->addScalarResult('updated', 'updated', 'datetime_immutable') ->addIndexByScalar('city'); //Get result - $result = $this->_em + $result = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('latitude', $latitude) ->setParameter('longitude', $longitude) @@ -396,13 +396,13 @@ SQL; ->addScalarResult('title', 'title', 'string') ->addScalarResult('latitude', 'latitude', 'float') ->addScalarResult('longitude', 'longitude', 'float') - ->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('count', 'count', 'integer'); //Get result - $result = $this->_em + $result = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('begin', $period->getStartDate()) ->setParameter('end', $period->getEndDate()) @@ -529,14 +529,14 @@ SQL; ->addScalarResult('city', 'city', 'string') ->addScalarResult('latitude', 'latitude', 'float') ->addScalarResult('longitude', 'longitude', 'float') - ->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('pcount', 'pcount', 'integer') ->addScalarResult('tcount', 'tcount', 'integer'); //Get result - $result = $this->_em + $result = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('begin', $period->getStartDate()) ->setParameter('end', $period->getEndDate()) @@ -624,14 +624,14 @@ SQL; ->addScalarResult('longitude', 'longitude', 'float') ->addScalarResult('indoor', 'indoor', 'boolean') ->addScalarResult('zipcode', 'zipcode', 'string') - ->addScalarResult('modified', 'modified', 'datetime') + ->addScalarResult('modified', 'modified', 'datetime_immutable') ->addScalarResult('city_id', 'city_id', 'integer') ->addScalarResult('city_latitude', 'city_latitude', 'float') ->addScalarResult('city_longitude', 'city_longitude', 'float') ->addIndexByScalar('id'); //Get result - $result = $this->_em + $result = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('id', $id) ->getOneOrNullResult(); @@ -753,7 +753,7 @@ WHERE ul.user_id = :id'; ->addFieldResult('l', 'title', 'title'); //Send result - return $this->_em + return $this->manager ->createNativeQuery($req, $rsm) ->setParameter('id', $userId) ->getResult(); diff --git a/Repository/SessionRepository.php b/Repository/SessionRepository.php index c310b54..030dd35 100644 --- a/Repository/SessionRepository.php +++ b/Repository/SessionRepository.php @@ -141,9 +141,9 @@ SQL; $rsm->addScalarResult('id', 'id', 'integer') ->addScalarResult('date', 'date', 'date') ->addScalarResult('begin', 'begin', 'time') - ->addScalarResult('start', 'start', 'datetime') + ->addScalarResult('start', 'start', 'datetime_immutable') ->addScalarResult('length', 'length', 'time') - ->addScalarResult('stop', 'stop', 'datetime') + ->addScalarResult('stop', 'stop', 'datetime_immutable') ->addScalarResult('rainfall', 'rainfall', 'float') ->addScalarResult('rainrisk', 'rainrisk', 'float') ->addScalarResult('realfeel', 'realfeel', 'float') @@ -152,9 +152,9 @@ SQL; ->addScalarResult('temperature', 'temperature', 'float') ->addScalarResult('temperaturemin', 'temperaturemin', 'float') ->addScalarResult('temperaturemax', 'temperaturemax', 'float') - ->addScalarResult('locked', 'locked', 'datetime') - ->addScalarResult('created', 'created', 'datetime') - ->addScalarResult('updated', 'updated', 'datetime') + ->addScalarResult('locked', 'locked', 'datetime_immutable') + ->addScalarResult('created', 'created', 'datetime_immutable') + ->addScalarResult('updated', 'updated', 'datetime_immutable') ->addScalarResult('l_id', 'l_id', 'integer') ->addScalarResult('l_title', 'l_title', 'string') ->addScalarResult('l_description', 'l_description', 'string') @@ -164,11 +164,11 @@ SQL; ->addScalarResult('l_latitude', 'l_latitude', 'float') ->addScalarResult('l_longitude', 'l_longitude', 'float') ->addScalarResult('l_indoor', 'l_indoor', 'boolean') - ->addScalarResult('l_updated', 'l_updated', 'datetime') + ->addScalarResult('l_updated', 'l_updated', 'datetime_immutable') ->addScalarResult('t_id', 't_id', 'integer') ->addScalarResult('t_title', 't_title', 'string') ->addScalarResult('a_id', 'a_id', 'integer') - ->addScalarResult('a_canceled', 'a_canceled', 'datetime') + ->addScalarResult('a_canceled', 'a_canceled', 'datetime_immutable') ->addScalarResult('ad_id', 'ad_id', 'integer') ->addScalarResult('ad_name', 'ad_name', 'string') ->addScalarResult('ad_type', 'ad_type', 'string') @@ -183,7 +183,7 @@ SQL; ->addScalarResult('p_profile', 'p_profile', 'text') ->addScalarResult('p_rate', 'p_rate', 'integer') ->addScalarResult('p_hat', 'p_hat', 'boolean') - ->addScalarResult('modified', 'modified', 'datetime') + ->addScalarResult('modified', 'modified', 'datetime_immutable') //XXX: is a string because of \n separator ->addScalarResult('sa_id', 'sa_id', 'string') //XXX: is a string because of \n separator @@ -201,7 +201,7 @@ SQL; ->addIndexByScalar('id'); //Set result - $result = $this->_em + $result = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('id', $id) ->getOneOrNullResult(); @@ -461,7 +461,7 @@ SQL; //XXX: check that latitude and longitude have not be swapped !!! //XXX: latitude ~= 48.x longitude ~= 2.x $locationIds = array_keys( - $this->_em + $this->manager ->createNativeQuery($req, $rsm) ->setParameter('latitude', $latitude) ->setParameter('longitude', $longitude) @@ -507,7 +507,7 @@ SQL; //Set location ids $locationIds = array_keys( - $this->_em + $this->manager ->createNativeQuery($req, $rsm) ->setParameter('id', $userId) ->getArrayResult() @@ -590,10 +590,10 @@ SQL; ->addScalarResult('rainfall', 'rainfall', 'float') ->addScalarResult('realfeel', 'realfeel', 'float') ->addScalarResult('temperature', 'temperature', 'float') - ->addScalarResult('locked', 'locked', 'datetime') - ->addScalarResult('start', 'start', 'datetime') - ->addScalarResult('stop', 'stop', 'datetime') - ->addScalarResult('modified', 'modified', 'datetime') + ->addScalarResult('locked', 'locked', 'datetime_immutable') + ->addScalarResult('start', 'start', 'datetime_immutable') + ->addScalarResult('stop', 'stop', 'datetime_immutable') + ->addScalarResult('modified', 'modified', 'datetime_immutable') ->addScalarResult('t_id', 't_id', 'integer') ->addScalarResult('t_title', 't_title', 'string') ->addScalarResult('l_id', 'l_id', 'integer') @@ -605,7 +605,7 @@ SQL; ->addScalarResult('l_longitude', 'l_longitude', 'float') ->addScalarResult('l_indoor', 'l_indoor', 'boolean') ->addScalarResult('a_id', 'a_id', 'integer') - ->addScalarResult('a_canceled', 'a_canceled', 'datetime') + ->addScalarResult('a_canceled', 'a_canceled', 'datetime_immutable') ->addScalarResult('ad_id', 'ad_id', 'string') ->addScalarResult('ad_name', 'ad_name', 'string') ->addScalarResult('ad_type', 'ad_type', 'string') @@ -627,7 +627,7 @@ SQL; ->addIndexByScalar('id'); //Fetch result - $res = $this->_em + $res = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('begin', $period->getStartDate()) ->setParameter('end', $period->getEndDate()); @@ -965,7 +965,7 @@ SQL; //With user dance if ( - $userDances = $this->_em + $userDances = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('uid', $userId) ->getResult(AbstractQuery::HYDRATE_SCALAR_COLUMN) @@ -995,7 +995,7 @@ SQL; //With user subscription if ( - $userSubscriptions = $this->_em + $userSubscriptions = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('uid', $userId) ->getResult(AbstractQuery::HYDRATE_SCALAR_COLUMN) @@ -1059,10 +1059,10 @@ SQL; $rsm ->addScalarResult('id', 'id', 'integer') ->addScalarResult('date', 'date', 'date') - ->addScalarResult('locked', 'locked', 'datetime') - ->addScalarResult('modified', 'modified', 'datetime') - ->addScalarResult('start', 'start', 'datetime') - ->addScalarResult('stop', 'stop', 'datetime') + ->addScalarResult('locked', 'locked', 'datetime_immutable') + ->addScalarResult('modified', 'modified', 'datetime_immutable') + ->addScalarResult('start', 'start', 'datetime_immutable') + ->addScalarResult('stop', 'stop', 'datetime_immutable') ->addScalarResult('l_id', 'l_id', 'integer') ->addScalarResult('l_address', 'l_address', 'string') ->addScalarResult('l_zipcode', 'l_zipcode', 'string') @@ -1074,7 +1074,7 @@ SQL; ->addScalarResult('t_id', 't_id', 'integer') ->addScalarResult('t_title', 't_title', 'string') ->addScalarResult('a_id', 'a_id', 'integer') - ->addScalarResult('a_canceled', 'a_canceled', 'datetime') + ->addScalarResult('a_canceled', 'a_canceled', 'datetime_immutable') ->addScalarResult('ad_name', 'ad_name', 'string') ->addScalarResult('ad_type', 'ad_type', 'string') ->addScalarResult('au_id', 'au_id', 'integer') @@ -1094,7 +1094,7 @@ SQL; //Return sessions //TODO: XXX: finish here - return $this->_em + return $this->manager ->createNativeQuery($req, $rsm) ->setParameter('dids', $userDances) ->setParameter('uids', $userSubscriptions) @@ -1186,10 +1186,10 @@ SQL; //addScalarResult($sqlColName, $resColName, $type = 'string'); $rsm->addScalarResult('id', 'id', 'integer') ->addScalarResult('date', 'date', 'date') - ->addScalarResult('locked', 'locked', 'datetime') - ->addScalarResult('updated', 'updated', 'datetime') - ->addScalarResult('start', 'start', 'datetime') - ->addScalarResult('stop', 'stop', 'datetime') + ->addScalarResult('locked', 'locked', 'datetime_immutable') + ->addScalarResult('updated', 'updated', 'datetime_immutable') + ->addScalarResult('start', 'start', 'datetime_immutable') + ->addScalarResult('stop', 'stop', 'datetime_immutable') ->addScalarResult('l_id', 'l_id', 'integer') ->addScalarResult('l_address', 'l_address', 'string') ->addScalarResult('l_zipcode', 'l_zipcode', 'string') @@ -1201,7 +1201,7 @@ SQL; ->addScalarResult('t_id', 't_id', 'integer') ->addScalarResult('t_title', 't_title', 'string') ->addScalarResult('a_id', 'a_id', 'integer') - ->addScalarResult('a_canceled', 'a_canceled', 'datetime') + ->addScalarResult('a_canceled', 'a_canceled', 'datetime_immutable') ->addScalarResult('ad_name', 'ad_name', 'string') ->addScalarResult('ad_type', 'ad_type', 'string') ->addScalarResult('au_id', 'au_id', 'integer') @@ -1220,7 +1220,7 @@ SQL; ->addIndexByScalar('id'); //Fetch result - $res = $this->_em + $res = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('begin', $period->getStartDate()) ->setParameter('end', $period->getEndDate()); @@ -1273,7 +1273,7 @@ SQL; ->addIndexBy('s', 'id'); //Send result - return $this->_em + return $this->manager ->createNativeQuery($req, $rsm) ->getResult(); } @@ -1322,7 +1322,7 @@ SQL; ->addIndexBy('s', 'id'); //Send result - return $this->_em + return $this->manager ->createNativeQuery($req, $rsm) ->getResult(); } @@ -1364,7 +1364,7 @@ SQL; ->addIndexBy('s', 'id'); //Send result - return $this->_em + return $this->manager ->createNativeQuery($req, $rsm) ->getResult(); } @@ -1518,7 +1518,7 @@ SQL; //Get result //XXX: setting limit in subqueries is required to prevent mariadb optimisation - $applications = $this->_em + $applications = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('sid', $id) ->getResult(); @@ -1536,7 +1536,7 @@ SQL; //Update application updated field //XXX: updated field is not modified for user with bad behaviour as application is not retrieved until delay is reached - $this->_em->getConnection()->executeUpdate($upreq, ['id' => $application->getId(), 'score' => $application->getScore()], ['id' => Types::INTEGER, 'score' => Types::FLOAT]); + $this->manager->getConnection()->executeUpdate($upreq, ['id' => $application->getId(), 'score' => $application->getScore()], ['id' => Types::INTEGER, 'score' => Types::FLOAT]); } //Return best ranked application @@ -1550,7 +1550,7 @@ SQL; */ function rekey(): bool { //Get connection - $cnx = $this->_em->getConnection(); + $cnx = $this->manager->getConnection(); //Set the request $req = <<addIndexByScalar('id'); //Fetch result - $rnq = $this->_em->createNativeQuery($req, $rsm); + $rnq = $this->manager->createNativeQuery($req, $rsm); //Get result set $res = $rnq->getResult(); diff --git a/Repository/SlotRepository.php b/Repository/SlotRepository.php index d2b6eb3..590f6c0 100644 --- a/Repository/SlotRepository.php +++ b/Repository/SlotRepository.php @@ -44,7 +44,7 @@ class SlotRepository extends Repository { ->addIndexByScalar('id'); //Fetch result - $res = $this->_em + $res = $this->manager ->createNativeQuery($req, $rsm) ->getResult(); diff --git a/Repository/SnippetRepository.php b/Repository/SnippetRepository.php index 3d53487..c070333 100644 --- a/Repository/SnippetRepository.php +++ b/Repository/SnippetRepository.php @@ -11,10 +11,12 @@ namespace Rapsys\AirBundle\Repository; +use Rapsys\AirBundle\Repository; + /** * SnippetRepository */ -class SnippetRepository extends \Doctrine\ORM\EntityRepository { +class SnippetRepository extends Repository { /** * Find snippets by user id, locale and index by location id * @@ -24,7 +26,7 @@ class SnippetRepository extends \Doctrine\ORM\EntityRepository { */ public function findByUserIdLocaleIndexByLocationId(int $userId, string $locale): array { //Fetch snippets - $ret = $this->_em + $ret = $this->manager ->createQuery('SELECT s FROM Rapsys\AirBundle\Entity\Snippet s INDEX BY s.location WHERE s.locale = :locale and s.user = :user') ->setParameter('user', $userId) ->setParameter('locale', $locale) diff --git a/Repository/UserRepository.php b/Repository/UserRepository.php index 725e3ed..403e8ab 100644 --- a/Repository/UserRepository.php +++ b/Repository/UserRepository.php @@ -69,7 +69,7 @@ SQL; ->addIndexByScalar('id'); //Fetch result - $res = $this->_em + $res = $this->manager ->createNativeQuery($req, $rsm) ->getResult(); @@ -139,7 +139,7 @@ SQL; $rsm->addScalarResult('id', 'id', 'integer'); //Return result - return $this->_em + return $this->manager ->createNativeQuery($req, $rsm) ->setParameter('pseudonym', $pseudonym) //XXX: instead of array_column on the result @@ -175,7 +175,7 @@ SQL; ->addIndexByScalar('pseudonym'); //Get result - $result = $this->_em + $result = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('id', $sessionId) ->getArrayResult(); @@ -246,13 +246,13 @@ SQL; ->addScalarResult('phone', 'phone', 'string') ->addScalarResult('pseudonym', 'pseudonym', 'string') ->addScalarResult('surname', 'surname', 'string') - ->addScalarResult('updated', 'updated', 'datetime') + ->addScalarResult('updated', 'updated', 'datetime_immutable') ->addScalarResult('zipcode', 'zipcode', 'string') ->addScalarResult('c_id', 'c_id', 'integer') ->addScalarResult('c_title', 'c_title', 'string') ->addScalarResult('o_id', 'o_id', 'integer') ->addScalarResult('o_title', 'o_title', 'string') - ->addScalarResult('modified', 'modified', 'datetime') + ->addScalarResult('modified', 'modified', 'datetime_immutable') //XXX: is a string because of \n separator ->addScalarResult('ids', 'ids', 'string') //XXX: is a string because of \n separator @@ -260,7 +260,7 @@ SQL; ->addIndexByScalar('id'); //Get result - $result = $this->_em + $result = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('id', $id) ->getOneOrNullResult(); @@ -444,7 +444,7 @@ SQL; ->addScalarResult('d_types', 'd_types', 'string'); //Fetch result - $res = $this->_em + $res = $this->manager ->createNativeQuery($req, $rsm) ->getResult();