From 3bb7706790b4f955cfbc412ee65c4a620c15d5b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:30:03 +0100 Subject: [PATCH 01/16] Fix location user add/remove from inverse side --- Entity/Location.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Entity/Location.php b/Entity/Location.php index 613e462..73b07f7 100644 --- a/Entity/Location.php +++ b/Entity/Location.php @@ -430,7 +430,7 @@ class Location { */ public function addUser(User $user): Location { //Add from owning side - $user->addSubscriber($this); + $user->addLocation($this); $this->users[] = $user; @@ -444,12 +444,12 @@ class Location { * @return bool */ public function removeUser(User $user): bool { - if (!$this->users->contains($user)) { + if (!$this->locations->contains($user)) { return true; } //Remove from owning side - $user->removeSubscriber($this); + $user->removeLocation($this); return $this->users->removeElement($user); } -- 2.41.3 From fbe17cd04f8a37876254f2fdcb90566b05671a47 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:31:02 +0100 Subject: [PATCH 02/16] Set synchronized as not nullable --- Entity/GoogleCalendar.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Entity/GoogleCalendar.php b/Entity/GoogleCalendar.php index 70a1174..940a678 100644 --- a/Entity/GoogleCalendar.php +++ b/Entity/GoogleCalendar.php @@ -37,7 +37,7 @@ class GoogleCalendar { /** * @var \DateTime */ - private ?\DateTime $synchronized; + private \DateTime $synchronized; /** * @var \DateTime @@ -60,9 +60,9 @@ class GoogleCalendar { * @param \Rapsys\AirBundle\Entity\GoogleToken $googleToken The google token * @param string $mail The google calendar id * @param string $summary The google calendar summary - * @param ?\DateTime $synchronized The google calendar last synchronization + * @param \DateTime $synchronized The google calendar last synchronization */ - public function __construct(GoogleToken $googleToken, string $mail, string $summary, ?\DateTime $synchronized = null) { + public function __construct(GoogleToken $googleToken, string $mail, string $summary, \DateTime $synchronized = new \DateTime('now')) { //Set defaults $this->googleToken = $googleToken; $this->mail = $mail; @@ -126,11 +126,11 @@ class GoogleCalendar { /** * Set synchronized * - * @param ?\DateTime $synchronized + * @param \DateTime $synchronized * * @return GoogleCalendar */ - public function setSynchronized(?\DateTime $synchronized = null): GoogleCalendar { + public function setSynchronized(\DateTime $synchronized): GoogleCalendar { $this->synchronized = $synchronized; return $this; @@ -139,9 +139,9 @@ class GoogleCalendar { /** * Get synchronized * - * @return ?\DateTime + * @return \DateTime */ - public function getSynchronized(): ?\DateTime { + public function getSynchronized(): \DateTime { return $this->synchronized; } -- 2.41.3 From a19fbcfc503a73d83e1fb7213a5e566fedfb3454 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:31:55 +0100 Subject: [PATCH 03/16] Fix subscriber user add/remove from inverse side --- Entity/User.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Entity/User.php b/Entity/User.php index 387b196..807fece 100644 --- a/Entity/User.php +++ b/Entity/User.php @@ -347,6 +347,9 @@ class User extends BaseUser { * @return User */ public function addSubscriber(User $subscriber): User { + //Add from owning side + $subscriber->addSubscription($this); + $this->subscribers[] = $subscriber; return $this; @@ -358,6 +361,13 @@ class User extends BaseUser { * @param User $subscriber */ public function removeSubscriber(User $subscriber): bool { + if (!$this->subscriptions->contains($subscriber)) { + return true; + } + + //Remove from owning side + $subscriber->removeSubscription($this); + return $this->subscribers->removeElement($subscriber); } @@ -378,9 +388,6 @@ class User extends BaseUser { * @return User */ public function addSubscription(User $subscription): User { - //Add from owning side - $subscription->addSubscriber($this); - $this->subscriptions[] = $subscription; return $this; @@ -392,13 +399,6 @@ class User extends BaseUser { * @param User $subscription */ public function removeSubscription(User $subscription): bool { - if (!$this->users->contains($user)) { - return true; - } - - //Remove from owning side - $subscription->removeSubscriber($this); - return $this->subscriptions->removeElement($subscription); } -- 2.41.3 From 7314a6dcb9b7cf7ec0c0bdc865514a32a0707118 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:32:22 +0100 Subject: [PATCH 04/16] Inject container and hasher Cleanup --- DataFixtures/AirFixtures.php | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/DataFixtures/AirFixtures.php b/DataFixtures/AirFixtures.php index 7b3e3a3..18fda1b 100644 --- a/DataFixtures/AirFixtures.php +++ b/DataFixtures/AirFixtures.php @@ -4,7 +4,6 @@ namespace Rapsys\AirBundle\DataFixtures; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Persistence\ObjectManager; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; @@ -14,20 +13,11 @@ use Rapsys\AirBundle\Entity\User; use Rapsys\AirBundle\Entity\Location; use Rapsys\AirBundle\Entity\Slot; -class AirFixtures extends Fixture implements ContainerAwareInterface { +class AirFixtures extends Fixture { /** - * @var ContainerInterface + * Air fixtures constructor */ - private $container; - - /** - * @var UserPasswordHasherInterface - */ - private $hasher; - - public function setContainer(ContainerInterface $container = null) { - $this->container = $container; - $this->hasher = $this->container->get('security.password_hasher_factory'); + public function __construct(protected ContainerInterface $container, protected UserPasswordHasherInterface $hasher) { } /** -- 2.41.3 From 0d1506d19bdfd940084aa4dbe132383ddf9ce52b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:33:32 +0100 Subject: [PATCH 05/16] Add google token repository --- Repository/GoogleTokenRepository.php | 118 +++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 Repository/GoogleTokenRepository.php diff --git a/Repository/GoogleTokenRepository.php b/Repository/GoogleTokenRepository.php new file mode 100644 index 0000000..3ddced2 --- /dev/null +++ b/Repository/GoogleTokenRepository.php @@ -0,0 +1,118 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Rapsys\AirBundle\Repository; + +use Doctrine\ORM\AbstractQuery; +use Doctrine\ORM\Query\ResultSetMapping; + +use Rapsys\AirBundle\Repository; + +/** + * GoogleTokenRepository + */ +class GoogleTokenRepository extends Repository { + /** + * Find google tokens indexed by id + * + * @return array The google tokens array + */ + public function findAllIndexed(): array { + //Set the request + $req = <<tableKeys, $this->tableValues, $req); + + //Get result set mapping instance + //XXX: DEBUG: see ../blog.orig/src/Rapsys/BlogBundle/Repository/ArticleRepository.php + $rsm = new ResultSetMapping(); + + //Declare all fields + //XXX: see vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/Types.php + //addScalarResult($sqlColName, $resColName, $type = 'string'); + $rsm + ->addScalarResult('tid', 'tid', 'integer') + ->addScalarResult('gmail', 'gmail', 'string') + ->addScalarResult('uid', 'uid', 'integer') + ->addScalarResult('access', 'access', 'string') + ->addScalarResult('refresh', 'refresh', 'string') + ->addScalarResult('expired', 'expired', 'datetime') + ->addScalarResult('cids', 'cids', 'string') + ->addScalarResult('cmails', 'cmails', 'string') + ->addScalarResult('csummaries', 'csummaries', 'string') + ->addScalarResult('csynchronizeds', 'csynchronizeds', 'string') + ->addIndexByScalar('tid'); + + //Set result array + $result = []; + + //Get tokens + $tokens = $this->_em + ->createNativeQuery($req, $rsm) + ->getArrayResult(); + + //Iterate on tokens + foreach($tokens as $tid => $token) { + //Set cids + $cids = explode("\n", $token['cids']); + + //Set cmails + $cmails = explode("\n", $token['cmails']); + + //Set csummaries + $csummaries = explode("\n", $token['csummaries']); + + //Set csynchronizeds + $csynchronizeds = array_map(function($v){return new \DateTime($v);}, explode("\n", $token['csynchronizeds'])); + + //Set result + $result[$tid] = [ + 'id' => $tid, + 'mail' => $token['gmail'], + 'uid' => $token['uid'], + 'access' => $token['access'], + 'refresh' => $token['refresh'], + 'expired' => $token['expired'], + 'calendars' => [] + ]; + + //Iterate on + foreach($cids as $k => $cid) { + $result[$tid]['calendars'][$cid] = [ + 'id' => $cid, + 'mail' => $cmails[$k], + 'summary' => $csummaries[$k], + 'synchronized' => $csynchronizeds[$k] + ]; + } + } + + //Return result + return $result; + } +} -- 2.41.3 From b87bd55580eff10ddbb3e11c5de8f9634e6950bf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:36:40 +0100 Subject: [PATCH 06/16] Php 8.x constructor style Inverse locale and languages parameters Set current locale from current request --- Factory/RepositoryFactory.php => Factory.php | 69 ++++---------------- 1 file changed, 12 insertions(+), 57 deletions(-) rename Factory/RepositoryFactory.php => Factory.php (67%) diff --git a/Factory/RepositoryFactory.php b/Factory.php similarity index 67% rename from Factory/RepositoryFactory.php rename to Factory.php index f64a4fb..7ab9c2a 100644 --- a/Factory/RepositoryFactory.php +++ b/Factory.php @@ -9,11 +9,12 @@ * file that was distributed with this source code. */ -namespace Rapsys\AirBundle\Factory; +namespace Rapsys\AirBundle; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Repository\RepositoryFactory as RepositoryFactoryInterface; +use Doctrine\ORM\Repository\RepositoryFactory; use Doctrine\Persistence\ObjectRepository; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Routing\RouterInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -22,73 +23,23 @@ use Rapsys\PackBundle\Util\SluggerUtil; /** * This factory is used to create default repository objects for entities at runtime. */ -final class RepositoryFactory implements RepositoryFactoryInterface { +final class Factory implements RepositoryFactory { /** * The list of EntityRepository instances - * - * @var array */ private array $repositoryList = []; - /** - * The list of languages - * - * @var array - */ - private array $languages = []; - - /** - * The current locale - * - * @var string - */ - private string $locale; - - /** - * The RouterInterface instance - * - * @var RouterInterface - */ - private RouterInterface $router; - - /** - * The SluggerUtil instance - * - * @var SluggerUtil - */ - private SluggerUtil $slugger; - - /** - * The TranslatorInterface instance - * - * @var TranslatorInterface - */ - private TranslatorInterface $translator; - /** * Initializes a new RepositoryFactory instance * + * @param RequestStack $request The request stack * @param RouterInterface $router The router instance * @param SluggerUtil $slugger The SluggerUtil instance * @param TranslatorInterface $translator The TranslatorInterface instance - * @param array $languages The languages list * @param string $locale The current locale + * @param array $languages The languages list */ - public function __construct(RouterInterface $router, SluggerUtil $slugger, TranslatorInterface $translator, array $languages, string $locale) { - //Set router - $this->router = $router; - - //Set slugger - $this->slugger = $slugger; - - //Set translator - $this->translator = $translator; - - //Set languages - $this->languages = $languages; - - //Set locale - $this->locale = $locale; + public function __construct(private RequestStack $request, private RouterInterface $router, private SluggerUtil $slugger, private TranslatorInterface $translator, private string $locale, private array $languages) { } /** @@ -121,8 +72,12 @@ final class RepositoryFactory implements RepositoryFactoryInterface { //Get repository class $repositoryClass = $metadata->customRepositoryClassName ?: $entityManager->getConfiguration()->getDefaultRepositoryClassName(); + //Set to current locale + //XXX: current request is not yet populated in constructor + $this->locale = $this->request->getCurrentRequest()->getLocale() ?? $this->locale; + //Return repository class instance //XXX: router, slugger, translator, languages and locale arguments will be ignored by default - return new $repositoryClass($entityManager, $metadata, $this->router, $this->slugger, $this->translator, $this->languages, $this->locale); + return new $repositoryClass($entityManager, $metadata, $this->router, $this->slugger, $this->translator, $this->locale, $this->languages); } } -- 2.41.3 From 9d4b25a60ff36b21f841ad7bf785186f270c91ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:37:31 +0100 Subject: [PATCH 07/16] Add calendar2 command --- Command/Calendar2Command.php | 193 +++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 Command/Calendar2Command.php diff --git a/Command/Calendar2Command.php b/Command/Calendar2Command.php new file mode 100644 index 0000000..86be070 --- /dev/null +++ b/Command/Calendar2Command.php @@ -0,0 +1,193 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Rapsys\AirBundle\Command; + +use Doctrine\Persistence\ManagerRegistry; + +use Google\Client; +use Google\Service\Calendar; +use Google\Service\Oauth2; + +use Symfony\Component\Cache\Adapter\FilesystemAdapter; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Routing\RouterInterface; +use Symfony\Contracts\Translation\TranslatorInterface; + +use Twig\Extra\Markdown\DefaultMarkdown; + +use Rapsys\AirBundle\Entity\Session; +use Rapsys\AirBundle\Entity\GoogleCalendar; +use Rapsys\AirBundle\Entity\GoogleToken; + +use Rapsys\PackBundle\Util\SluggerUtil; + +class Calendar2Command extends Command { + /** + * Set default name + */ + protected static $defaultName = 'rapsysair:calendar2'; + + /** + * Set default description + */ + protected static $defaultDescription = 'Synchronize sessions in users\' calendar'; + + /** + * Set google client scopes + */ + private array $scopes = [ + Calendar::CALENDAR_EVENTS, + Calendar::CALENDAR, + Oauth2::USERINFO_EMAIL + ]; + + /** + * Set google client instance + */ + private Client $client; + + /** + * Set markdown instance + */ + private DefaultMarkdown $markdown; + + /** + * Set date period instance + */ + private \DatePeriod $period; + + /** + * {@inheritdoc} + * + * @param string $project The google project + * @param string $client The google client + * @param string $secret The google secret + */ + public function __construct(ManagerRegistry $doctrine, RouterInterface $router, SluggerUtil $slugger, TranslatorInterface $translator, string $locale, string $project, string $client, string $secret) { + //Call parent constructor + parent::__construct($doctrine, $router, $slugger, $translator, $locale); + + //Set google client + $this->client = new Client( + [ + 'application_name' => $project, + 'client_id' => $client, + 'client_secret' => $secret, + 'redirect_uri' => $this->router->generate('rapsys_air_google_callback', [], UrlGeneratorInterface::ABSOLUTE_URL), + 'scopes' => $this->scopes, + 'access_type' => 'offline', + #'login_hint' => $user->getMail(), + //XXX: see https://stackoverflow.com/questions/10827920/not-receiving-google-oauth-refresh-token + #'approval_prompt' => 'force' + 'prompt' => 'consent' + ] + ); + + //Set Markdown instance + $this->markdown = new DefaultMarkdown; + } + + /** + * Process the attribution + */ + protected function execute(InputInterface $input, OutputInterface $output) { + //Iterate on google tokens + foreach($tokens = $this->doctrine->getRepository(GoogleToken::class)->findAllIndexed() as $tid => $token) { + //Iterate on google calendars + foreach($calendars = $token['calendars'] as $cid => $calendar) { + //Set period + $this->period = new \DatePeriod( + //Start from last week + new \DateTime('-1 week'), + //Iterate on each day + new \DateInterval('P1D'), + //End with next 2 week + new \DateTime('+2 week') + ); + + #$calendar['synchronized'] + var_dump($token); + + //TODO: see if we may be smarter here ? + + //TODO: load all calendar events here ? + + //Iterate on sessions to update + foreach($sessions = $this->doctrine->getRepository(Session::class)->findAllByUserIdSynchronized($token['uid'], $calendar['synchronized'])) { + //TODO: insert/update/delete events here ? + } + + //TODO: delete remaining events here ? + } + } + + //TODO: get user filter ? (users_subscriptions+users_dances) + + //TODO: XXX: or fetch directly the events updated since synchronized + matching rubscriptions and/or dances + + #var_dump($tokens); + exit; + + //Set sql request + $sql =<<doctrine->getRepository(Session::class)->findAllByDanceUserModified($filter['dance'], $filter['user'], $calendar['synchronized']); + //Iterate on google tokens + foreach($tokens as $token) { + //TODO: clear google client cache + //TODO: set google token + //Iterate on google calendars + foreach($calendars as $calendar) { + //Fetch sessions to sync + $sessions = $this->doctrine->getRepository(Session::class)->findAllByDanceUserModified($filter['dance'], $filter['user'], $calendar['synchronized']); + } + } + + //Return success + return self::SUCCESS; + } +} -- 2.41.3 From 0157506456243f8e0ee762b7a7b4a84da0446909 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:38:49 +0100 Subject: [PATCH 08/16] Php 8.x constructor style Add UserSubscription, GoogleCalendar and GoogleToken tables Cleanup --- Repository/Repository.php => Repository.php | 63 +++------------------ 1 file changed, 8 insertions(+), 55 deletions(-) rename Repository/Repository.php => Repository.php (80%) diff --git a/Repository/Repository.php b/Repository.php similarity index 80% rename from Repository/Repository.php rename to Repository.php index fcf7d6a..b2cc650 100644 --- a/Repository/Repository.php +++ b/Repository.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Rapsys\AirBundle\Repository; +namespace Rapsys\AirBundle; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; @@ -25,20 +25,6 @@ use Rapsys\PackBundle\Util\SluggerUtil; * {@inheritdoc} */ class Repository extends EntityRepository { - /** - * The RouterInterface instance - * - * @var RouterInterface - */ - protected RouterInterface $router; - - /** - * The SluggerUtil instance - * - * @var SluggerUtil - */ - protected SluggerUtil $slugger; - /** * The table keys array * @@ -53,27 +39,6 @@ class Repository extends EntityRepository { */ protected array $tableValues; - /** - * The TranslatorInterface instance - * - * @var TranslatorInterface - */ - protected TranslatorInterface $translator; - - /** - * The list of languages - * - * @var string[] - */ - protected array $languages = []; - - /** - * The current locale - * - * @var string - */ - protected string $locale; - /** * Initializes a new LocationRepository instance * @@ -82,31 +47,16 @@ class Repository extends EntityRepository { * @param RouterInterface $router The router instance * @param SluggerUtil $slugger The SluggerUtil instance * @param TranslatorInterface $translator The TranslatorInterface instance - * @param array $languages The languages list * @param string $locale The current locale + * @param array $languages The languages list */ - public function __construct(EntityManagerInterface $manager, ClassMetadata $class, RouterInterface $router, SluggerUtil $slugger, TranslatorInterface $translator, array $languages, string $locale) { + public function __construct(protected EntityManagerInterface $manager, protected ClassMetadata $class, protected RouterInterface $router, protected SluggerUtil $slugger, protected TranslatorInterface $translator, protected string $locale, protected array $languages) { //Call parent constructor parent::__construct($manager, $class); - //Set languages - $this->languages = $languages; - - //Set locale - $this->locale = $locale; - - //Set router - $this->router = $router; - - //Set slugger - $this->slugger = $slugger; - - //Set translator - $this->translator = $translator; - //Get quote strategy - $qs = $manager->getConfiguration()->getQuoteStrategy(); - $dp = $manager->getConnection()->getDatabasePlatform(); + $qs = $this->manager->getConfiguration()->getQuoteStrategy(); + $dp = $this->manager->getConnection()->getDatabasePlatform(); //Set quoted table names //XXX: this allow to make this code table name independent @@ -115,10 +65,13 @@ class Repository extends EntityRepository { 'RapsysAirBundle:UserDance' => $qs->getJoinTableName($manager->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('dances'), $manager->getClassMetadata('RapsysAirBundle:User'), $dp), 'RapsysAirBundle:UserGroup' => $qs->getJoinTableName($manager->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('groups'), $manager->getClassMetadata('RapsysAirBundle:User'), $dp), 'RapsysAirBundle:UserLocation' => $qs->getJoinTableName($manager->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('locations'), $manager->getClassMetadata('RapsysAirBundle:User'), $dp), + 'RapsysAirBundle:UserSubscription' => $qs->getJoinTableName($manager->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('subscriptions'), $manager->getClassMetadata('RapsysAirBundle:User'), $dp), 'RapsysAirBundle:Application' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Application'), $dp), 'RapsysAirBundle:Civility' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Civility'), $dp), 'RapsysAirBundle:Country' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Country'), $dp), 'RapsysAirBundle:Dance' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Dance'), $dp), + 'RapsysAirBundle:GoogleCalendar' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:GoogleCalendar'), $dp), + 'RapsysAirBundle:GoogleToken' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:GoogleToken'), $dp), 'RapsysAirBundle:Group' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Group'), $dp), 'RapsysAirBundle:Location' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Location'), $dp), 'RapsysAirBundle:Session' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Session'), $dp), -- 2.41.3 From 059e66ae24b995fc9071e287647e20c007fc92f8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:40:17 +0100 Subject: [PATCH 09/16] Update execute member function prototype --- Command/AttributeCommand.php | 2 +- Command/CalendarCommand.php | 2 +- Command/RekeyCommand.php | 2 +- Command/WeatherCommand.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Command/AttributeCommand.php b/Command/AttributeCommand.php index 8f26e26..48f5f01 100644 --- a/Command/AttributeCommand.php +++ b/Command/AttributeCommand.php @@ -27,7 +27,7 @@ class AttributeCommand extends DoctrineCommand { } ///Process the attribution - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { //Fetch doctrine $doctrine = $this->getDoctrine(); diff --git a/Command/CalendarCommand.php b/Command/CalendarCommand.php index fb0cd02..2488f51 100644 --- a/Command/CalendarCommand.php +++ b/Command/CalendarCommand.php @@ -112,7 +112,7 @@ class CalendarCommand extends Command { } ///Process the attribution - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { //Compute period $period = new \DatePeriod( //Start from last week diff --git a/Command/RekeyCommand.php b/Command/RekeyCommand.php index 91d7967..630d443 100644 --- a/Command/RekeyCommand.php +++ b/Command/RekeyCommand.php @@ -28,7 +28,7 @@ class RekeyCommand extends DoctrineCommand { } ///Process the attribution - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { //Fetch doctrine $doctrine = $this->getDoctrine(); diff --git a/Command/WeatherCommand.php b/Command/WeatherCommand.php index 3b6c88f..ed7b8be 100644 --- a/Command/WeatherCommand.php +++ b/Command/WeatherCommand.php @@ -99,7 +99,7 @@ class WeatherCommand extends DoctrineCommand { } ///Process the attribution - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { //Kernel object $kernel = $this->getApplication()->getKernel(); -- 2.41.3 From 9b7a4d936d277966c912334d534c3937eb9fcfa9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:40:40 +0100 Subject: [PATCH 10/16] Set synchronized as not nullable --- Resources/config/doctrine/GoogleCalendar.orm.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/Resources/config/doctrine/GoogleCalendar.orm.yml b/Resources/config/doctrine/GoogleCalendar.orm.yml index 73ac000..d8d0fbc 100644 --- a/Resources/config/doctrine/GoogleCalendar.orm.yml +++ b/Resources/config/doctrine/GoogleCalendar.orm.yml @@ -27,7 +27,6 @@ Rapsys\AirBundle\Entity\GoogleCalendar: # length: 32 synchronized: type: datetime - nullable: true created: type: datetime updated: -- 2.41.3 From 86e7b4599dfaf730706abc3407c57ef2d98534fc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:41:02 +0100 Subject: [PATCH 11/16] Add google token repository --- Resources/config/doctrine/GoogleToken.orm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/doctrine/GoogleToken.orm.yml b/Resources/config/doctrine/GoogleToken.orm.yml index 07712e9..a32c963 100644 --- a/Resources/config/doctrine/GoogleToken.orm.yml +++ b/Resources/config/doctrine/GoogleToken.orm.yml @@ -1,6 +1,6 @@ Rapsys\AirBundle\Entity\GoogleToken: type: entity - #repositoryClass: Rapsys\AirBundle\Repository\GoogleTokenRepository + repositoryClass: Rapsys\AirBundle\Repository\GoogleTokenRepository table: google_tokens id: id: -- 2.41.3 From 3ce82b94f5efa2fa21c13eca474553f9a50b862e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:41:35 +0100 Subject: [PATCH 12/16] Add Repository namespace --- Repository/DanceRepository.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Repository/DanceRepository.php b/Repository/DanceRepository.php index e7dd475..6f64e92 100644 --- a/Repository/DanceRepository.php +++ b/Repository/DanceRepository.php @@ -14,6 +14,8 @@ namespace Rapsys\AirBundle\Repository; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\Query\ResultSetMapping; +use Rapsys\AirBundle\Repository; + /** * DanceRepository */ -- 2.41.3 From 76aab3cd09893cd4cc84a12a568bd2faac080400 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:41:48 +0100 Subject: [PATCH 13/16] Add Repository namespace --- Repository/LocationRepository.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Repository/LocationRepository.php b/Repository/LocationRepository.php index de475fb..9a67b9c 100644 --- a/Repository/LocationRepository.php +++ b/Repository/LocationRepository.php @@ -12,9 +12,12 @@ namespace Rapsys\AirBundle\Repository; use Doctrine\ORM\Query\ResultSetMapping; + use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\RouterInterface; +use Rapsys\AirBundle\Repository; + /** * LocationRepository * -- 2.41.3 From 69a888d9341349a25ba800313f9f14bb638e6ca5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:42:27 +0100 Subject: [PATCH 14/16] Add Repository namespace --- Repository/SlotRepository.php | 2 ++ Repository/UserRepository.php | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Repository/SlotRepository.php b/Repository/SlotRepository.php index bd356f7..2b40eba 100644 --- a/Repository/SlotRepository.php +++ b/Repository/SlotRepository.php @@ -13,6 +13,8 @@ namespace Rapsys\AirBundle\Repository; use Doctrine\ORM\Query\ResultSetMapping; +use Rapsys\AirBundle\Repository; + /** * SlotRepository */ diff --git a/Repository/UserRepository.php b/Repository/UserRepository.php index 5f5dd50..9b34057 100644 --- a/Repository/UserRepository.php +++ b/Repository/UserRepository.php @@ -13,8 +13,11 @@ namespace Rapsys\AirBundle\Repository; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\Query\ResultSetMapping; + use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Rapsys\AirBundle\Repository; + /** * UserRepository */ -- 2.41.3 From 4e2dd7b0482d5ac0d7c031afb5b24061da8d1373 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:43:03 +0100 Subject: [PATCH 15/16] Reverse subscriber/subscription owning side --- Resources/config/doctrine/User.orm.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Resources/config/doctrine/User.orm.yml b/Resources/config/doctrine/User.orm.yml index cd5d307..6002651 100644 --- a/Resources/config/doctrine/User.orm.yml +++ b/Resources/config/doctrine/User.orm.yml @@ -43,7 +43,10 @@ Rapsys\AirBundle\Entity\User: name: dance_id subscribers: targetEntity: Rapsys\AirBundle\Entity\User - inversedBy: subscriptions + mappedBy: subscriptions + subscriptions: + targetEntity: Rapsys\AirBundle\Entity\User + inversedBy: subscribers joinTable: name: users_subscriptions joinColumns: @@ -52,9 +55,6 @@ Rapsys\AirBundle\Entity\User: inverseJoinColumns: id: name: subscriber_id - subscriptions: - targetEntity: Rapsys\AirBundle\Entity\User - mappedBy: subscribers locations: targetEntity: Rapsys\AirBundle\Entity\Location inversedBy: users -- 2.41.3 From cb55dba78691e9563c2d72ff70ce3e40833fef7a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 27 Feb 2024 16:43:54 +0100 Subject: [PATCH 16/16] Update configureOptions and reverseTransform member function prototypes --- Form/Extension/Type/HiddenEntityType.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Form/Extension/Type/HiddenEntityType.php b/Form/Extension/Type/HiddenEntityType.php index 7521633..f9b27d1 100644 --- a/Form/Extension/Type/HiddenEntityType.php +++ b/Form/Extension/Type/HiddenEntityType.php @@ -40,7 +40,7 @@ class HiddenEntityType extends HiddenType implements DataTransformerInterface { * * {@inheritdoc} */ - public function configureOptions(OptionsResolver $resolver) { + public function configureOptions(OptionsResolver $resolver): void { //Call parent parent::configureOptions($resolver); @@ -102,24 +102,24 @@ class HiddenEntityType extends HiddenType implements DataTransformerInterface { /** * Reverse transformation from string to data object * - * @param string $data The object id + * @param mixed $value The object id * @return mixed The data object */ - public function reverseTransform($data) { - if (!$data) { + public function reverseTransform(mixed $value): mixed { + if (!$value) { return null; } $res = null; try { $rep = $this->dm->getRepository($this->class); - $res = $rep->findOneById($data); + $res = $rep->findOneById($value); } catch (\Exception $e) { throw new TransformationFailedException($e->getMessage()); } if ($res === null) { - throw new TransformationFailedException(sprintf('A %s with id %s does not exist!', $this->class, $data)); + throw new TransformationFailedException(sprintf('A %s with id %s does not exist!', $this->class, $value)); } return $res; -- 2.41.3