From 2a5ee7b16bc5145c111d7e5462ef48465b1c3fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20=C3=81lvarez?= Date: Wed, 25 May 2022 12:05:39 +0200 Subject: [PATCH] platform dupped --- ...220524155905.php => Version20220525093052.php} | 5 +++-- src/Controller/IndexController.php | 2 +- src/DataFixtures/MerFixtures.php | 10 +++++----- src/Entity/MerBeDM.php | 15 +++++++++++++++ src/Entity/MerParaDM.php | 15 +++++++++++++++ src/Entity/MerParaDT.php | 15 +++++++++++++++ src/Entity/MerService.php | 15 --------------- src/Repository/MerServiceRepository.php | 4 +++- templates/index/notificationDm.html.twig | 2 +- 9 files changed, 58 insertions(+), 25 deletions(-) rename migrations/{Version20220524155905.php => Version20220525093052.php} (90%) diff --git a/migrations/Version20220524155905.php b/migrations/Version20220525093052.php similarity index 90% rename from migrations/Version20220524155905.php rename to migrations/Version20220525093052.php index 4d0f647..4b02f53 100644 --- a/migrations/Version20220524155905.php +++ b/migrations/Version20220525093052.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20220524155905 extends AbstractMigration +final class Version20220525093052 extends AbstractMigration { public function getDescription(): string { @@ -34,7 +34,8 @@ final class Version20220524155905 extends AbstractMigration )'); $this->addSql('CREATE INDEX IDX_E4F82A3DED5CA9E6 ON mer_para_sub (service_id)'); $this->addSql('CREATE TABLE mer_service (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, mcc_mnc INTEGER DEFAULT NULL, metadata CLOB DEFAULT NULL --(DC2Type:json) - , discr VARCHAR(255) NOT NULL, product_code VARCHAR(255) DEFAULT NULL, api_key VARCHAR(255) DEFAULT NULL, activation_code VARCHAR(255) DEFAULT NULL)'); + , discr VARCHAR(255) NOT NULL, product_code VARCHAR(255) DEFAULT NULL, platform_id INTEGER DEFAULT NULL, api_key VARCHAR(255) DEFAULT NULL, activation_code VARCHAR(255) DEFAULT NULL)'); + $this->addSql('CREATE INDEX IDX_E9ABEA72FFE6496F ON mer_service (platform_id)'); } public function down(Schema $schema): void diff --git a/src/Controller/IndexController.php b/src/Controller/IndexController.php index fe65e83..dde8552 100644 --- a/src/Controller/IndexController.php +++ b/src/Controller/IndexController.php @@ -49,7 +49,7 @@ class IndexController extends AbstractController { return $this->render('index/notificationDm.html.twig', [ 'serviceRepo' => $repo->findByOfferId($request->query->get('offer_id')), - 'beDmRepo' => $repoDm->findByOfferId($request->query->get('offer_id')) + //'beDmRepo' => $repoDm->findByOfferId($request->query->get('offer_id')) ]); } } diff --git a/src/DataFixtures/MerFixtures.php b/src/DataFixtures/MerFixtures.php index d5ca638..e7cb6f7 100644 --- a/src/DataFixtures/MerFixtures.php +++ b/src/DataFixtures/MerFixtures.php @@ -19,27 +19,27 @@ class MerFixtures extends Fixture { $ser1 = new MerParaDM(); $ser1->setMccMnc(12345) - ->setPlatform((new MerDM())->setOfferId(221)->setPlatform($ser1)) + ->setPlatform((new MerDM())->setOfferId(221)) ->setProductCode('code1'); $ser2 = new MerParaDM(); $ser2->setMccMnc(12345) - ->setPlatform((new MerDM())->setOfferId(223)->setPlatform($ser2)) + ->setPlatform((new MerDM())->setOfferId(223)) ->setProductCode('code2'); $ser3 = new MerParaDT(); $ser3->setMccMnc(12345) - ->setPlatform((new MerDT())->setServiceId('ser-vi-ce1')->setPlatform($ser3)) + ->setPlatform((new MerDT())->setServiceId('ser-vi-ce1')) ->setApiKey('api1'); $ser4 = new MerParaDT(); $ser4->setMccMnc(12341) - ->setPlatform((new MerDT())->setServiceId('ser-vi-ce2')->setPlatform($ser4)) + ->setPlatform((new MerDT())->setServiceId('ser-vi-ce2')) ->setApiKey('api2'); $ser5 = new MerBeDM(); $ser5->setMccMnc(12341) - ->setPlatform((new MerDM())->setOfferId(112)->setPlatform($ser5)) + ->setPlatform((new MerDM())->setOfferId(112)) ->setActivationCode('active1'); $sub1 = new MerParaSub(); diff --git a/src/Entity/MerBeDM.php b/src/Entity/MerBeDM.php index c746f0d..b9ab059 100644 --- a/src/Entity/MerBeDM.php +++ b/src/Entity/MerBeDM.php @@ -16,6 +16,9 @@ class MerBeDM extends MerService implements OttInterface #[ORM\Column(type: 'string', length: 255)] private $activation_code; + #[ORM\OneToOne(targetEntity: MerDM::class, cascade: ['persist'])] + private MerDM $platform; + // public function getId(): ?int // { // return $this->id; @@ -32,4 +35,16 @@ class MerBeDM extends MerService implements OttInterface return $this; } + + public function getPlatform(): ?MerDM + { + return $this->platform; + } + + public function setPlatform(?MerDM $platform): self + { + $this->platform = $platform; + + return $this; + } } diff --git a/src/Entity/MerParaDM.php b/src/Entity/MerParaDM.php index 9648293..c16fe87 100644 --- a/src/Entity/MerParaDM.php +++ b/src/Entity/MerParaDM.php @@ -16,6 +16,9 @@ class MerParaDM extends MerService implements OttInterface #[ORM\Column(type: 'string', length: 255)] private $product_code; + #[ORM\OneToOne(targetEntity: MerDM::class, cascade: ['persist'])] + private MerDM $platform; + // public function getId(): ?int // { // return $this->id; @@ -32,4 +35,16 @@ class MerParaDM extends MerService implements OttInterface return $this; } + + public function getPlatform(): ?MerDM + { + return $this->platform; + } + + public function setPlatform(?MerDM $platform): self + { + $this->platform = $platform; + + return $this; + } } diff --git a/src/Entity/MerParaDT.php b/src/Entity/MerParaDT.php index 1487df4..a4005e8 100644 --- a/src/Entity/MerParaDT.php +++ b/src/Entity/MerParaDT.php @@ -16,6 +16,9 @@ class MerParaDT extends MerService implements OttInterface #[ORM\Column(type: 'string', length: 255)] private $api_key; + #[ORM\OneToOne(targetEntity: MerDT::class, cascade: ['persist'])] + private MerDT $platform; + // public function getId(): ?int // { // return $this->id; @@ -32,4 +35,16 @@ class MerParaDT extends MerService implements OttInterface return $this; } + + public function getPlatform(): ?MerDT + { + return $this->platform; + } + + public function setPlatform(?MerDT $platform): self + { + $this->platform = $platform; + + return $this; + } } diff --git a/src/Entity/MerService.php b/src/Entity/MerService.php index eea2e9b..1fcb65f 100644 --- a/src/Entity/MerService.php +++ b/src/Entity/MerService.php @@ -27,9 +27,6 @@ abstract class MerService #[ORM\Column(type: 'json', nullable: true)] private $metadata = []; - #[ORM\OneToOne(targetEntity: Platform::class, cascade: ['persist'], mappedBy: 'ott')] - private Platform $platform; - public function getId(): ?int { return $this->id; @@ -58,16 +55,4 @@ abstract class MerService return $this; } - - public function getPlatform(): ?Platform - { - return $this->platform; - } - - public function setPlatform(?Platform $platform): self - { - $this->platform = $platform; - - return $this; - } } diff --git a/src/Repository/MerServiceRepository.php b/src/Repository/MerServiceRepository.php index e7bbe9c..0daad3f 100644 --- a/src/Repository/MerServiceRepository.php +++ b/src/Repository/MerServiceRepository.php @@ -2,6 +2,7 @@ namespace App\Repository; +use App\Entity\MerDM; use App\Entity\MerService; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\Query; @@ -99,8 +100,9 @@ class MerServiceRepository extends ServiceEntityRepository // return $res; return $this->createQueryBuilder('s') - ->leftJoin('s.platform_id', 'p') + ->innerJoin(MerDM::class, 'p', ) ->andWhere('p.offer_id = :offer_id') + ->andWhere('p.offer_id IS NOT NULL') ->setParameter('offer_id', $offerId) ->getQuery() ->getResult() diff --git a/templates/index/notificationDm.html.twig b/templates/index/notificationDm.html.twig index 161904e..c06d926 100644 --- a/templates/index/notificationDm.html.twig +++ b/templates/index/notificationDm.html.twig @@ -9,5 +9,5 @@ {{ dump(serviceRepo) }}

MerBeDMRepository->findByOfferId

- {{ dump(beDmRepo) }} +{# {{ dump(beDmRepo) }}#} {% endblock %}