simulation model

This commit is contained in:
2022-05-23 15:22:36 +02:00
parent c8545e4cc7
commit f251e6eb0d
32 changed files with 927 additions and 12 deletions

View File

@ -2,6 +2,8 @@
namespace App\Controller;
use App\Entity\MerParaSub;
use App\Repository\MerParaSubRepository;
use Doctrine\ORM\EntityManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
@ -11,11 +13,15 @@ use App\Repository\Entity1Repository;
class IndexController extends AbstractController
{
#[Route('/', name: 'app_index')]
public function index(Entity1Repository $repo): Response
public function index(Entity1Repository $repo, MerParaSubRepository $subRepo): Response
{
$sm = $repo->getSchemaManager();
$entity8 = $repo->findOneByName('entity 8');
$sub = $subRepo->findOneById(1);
dump($sub);
dump($sub->getService());
return $this->render('index/index.html.twig', [
'controller_name' => 'IndexController',
'entity8' => $entity8,

View File

@ -11,7 +11,7 @@ use App\Entity\Toothbrush3;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
class InheritanceFixtures extends Fixture
class InheritanceFixtures //extends Fixture
{
public function load(ObjectManager $manager): void
{

View File

@ -0,0 +1,44 @@
<?php
namespace App\DataFixtures;
use App\Entity\MerBeDM;
use App\Entity\MerParaDM;
use App\Entity\MerParaDT;
use App\Entity\MerParaSub;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
class MerFixtures extends Fixture
{
public function load(ObjectManager $manager): void
{
$tmp = new MerParaDM();
$tmp->setMccMnc(12345)->setOfferId(223)->setProductCode('code2');
$manager->persist($tmp);
$tmp = new MerParaDT();
$tmp->setMccMnc(12345)->setServiceId('ser-vi-ce1')->setApiKey('api1');
$manager->persist($tmp);
$tmp = new MerParaDT();
$tmp->setMccMnc(12341)->setServiceId('ser-vi-ce2')->setApiKey('api2');
$manager->persist($tmp);
$tmp = new MerBeDM();
$tmp->setMccMnc(12341)->setOfferId(112)->setActivationCode('active1');
$manager->persist($tmp);
$tmp = new MerParaDM();
$tmp->setMccMnc(12345)->setOfferId(221)->setProductCode('code1');
$manager->persist($tmp);
$sub = new MerParaSub();
$sub->setService($tmp)->setRedCode('redcode1');
$manager->persist($sub);
$manager->flush();
}
}
// symfony console doctrine:fixtures:load

View File

@ -4,7 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
////#[ORM\Entity]
class Employee1 extends Person1
{
#[ORM\Id]

View File

@ -4,7 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
////#[ORM\Entity]
class Employee2 extends Person2
{
#[ORM\Id]

View File

@ -4,7 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
////#[ORM\Entity]
class Employee3 extends Person3
{
#[ORM\Id]

37
src/Entity/MerBeDM.php Normal file
View File

@ -0,0 +1,37 @@
<?php
namespace App\Entity;
use App\Repository\MerBeDMRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: MerBeDMRepository::class)]
class MerBeDM extends MerService
{
use MerDM;
// #[ORM\Id]
// #[ORM\GeneratedValue]
// #[ORM\Column(type: 'integer')]
// private $id;
#[ORM\Column(type: 'string', length: 255)]
private $activationCode;
// public function getId(): ?int
// {
// return $this->id;
// }
public function getActivationCode(): ?string
{
return $this->activationCode;
}
public function setActivationCode(string $activationCode): self
{
$this->activationCode = $activationCode;
return $this;
}
}

35
src/Entity/MerDM.php Normal file
View File

@ -0,0 +1,35 @@
<?php
namespace App\Entity;
use App\Repository\MerDMRepository;
use Doctrine\ORM\Mapping as ORM;
//#[ORM\Entity(repositoryClass: MerDMRepository::class)]
trait MerDM
{
// #[ORM\Id]
// #[ORM\GeneratedValue]
// #[ORM\Column(type: 'integer')]
// private $id;
#[ORM\Column(type: 'integer')]
private $offerId;
// public function getId(): ?int
// {
// return $this->id;
// }
public function getOfferId(): ?int
{
return $this->offerId;
}
public function setOfferId(int $offerId): self
{
$this->offerId = $offerId;
return $this;
}
}

35
src/Entity/MerDT.php Normal file
View File

@ -0,0 +1,35 @@
<?php
namespace App\Entity;
use App\Repository\MerDTRepository;
use Doctrine\ORM\Mapping as ORM;
//#[ORM\Entity(repositoryClass: MerDTRepository::class)]
trait MerDT
{
// #[ORM\Id]
// #[ORM\GeneratedValue]
// #[ORM\Column(type: 'integer')]
// private $id;
#[ORM\Column(type: 'string', length: 255)]
private $serviceId;
// public function getId(): ?int
// {
// return $this->id;
// }
public function getServiceId(): ?string
{
return $this->serviceId;
}
public function setServiceId(string $serviceId): self
{
$this->serviceId = $serviceId;
return $this;
}
}

37
src/Entity/MerParaDM.php Normal file
View File

@ -0,0 +1,37 @@
<?php
namespace App\Entity;
use App\Repository\MerParaDMRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: MerParaDMRepository::class)]
class MerParaDM extends MerService
{
use MerDM;
// #[ORM\Id]
// #[ORM\GeneratedValue]
// #[ORM\Column(type: 'integer')]
// private $id;
#[ORM\Column(type: 'string', length: 255)]
private $productCode;
// public function getId(): ?int
// {
// return $this->id;
// }
public function getProductCode(): ?string
{
return $this->productCode;
}
public function setProductCode(string $productCode): self
{
$this->productCode = $productCode;
return $this;
}
}

37
src/Entity/MerParaDT.php Normal file
View File

@ -0,0 +1,37 @@
<?php
namespace App\Entity;
use App\Repository\MerParaDTRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: MerParaDTRepository::class)]
class MerParaDT extends MerService
{
use MerDT;
// #[ORM\Id]
// #[ORM\GeneratedValue]
// #[ORM\Column(type: 'integer')]
// private $id;
#[ORM\Column(type: 'string', length: 255)]
private $apiKey;
// public function getId(): ?int
// {
// return $this->id;
// }
public function getApiKey(): ?string
{
return $this->apiKey;
}
public function setApiKey(string $apiKey): self
{
$this->apiKey = $apiKey;
return $this;
}
}

51
src/Entity/MerParaSub.php Normal file
View File

@ -0,0 +1,51 @@
<?php
namespace App\Entity;
use App\Repository\MerParaSubRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: MerParaSubRepository::class)]
class MerParaSub
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $redCode;
#[ORM\ManyToOne(targetEntity: MerService::class)]
#[ORM\JoinColumn(nullable: false)]
private MerService $service;
public function getId(): ?int
{
return $this->id;
}
public function getRedCode(): ?string
{
return $this->redCode;
}
public function setRedCode(?string $redCode): self
{
$this->redCode = $redCode;
return $this;
}
public function getService(): ?MerService
{
return $this->service;
}
public function setService(?MerService $service): self
{
$this->service = $service;
return $this;
}
}

57
src/Entity/MerService.php Normal file
View File

@ -0,0 +1,57 @@
<?php
namespace App\Entity;
use App\Repository\MerServiceRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
#[ORM\DiscriminatorMap([
'para_dm' => MerParaDM::class,
'para_dt' => MerParaDT::class,
'be_dm' => MerBeDM::class
])]
#[ORM\Entity(repositoryClass: MerServiceRepository::class)]
abstract class MerService
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'integer', nullable: true)]
private $mcc_mnc;
#[ORM\Column(type: 'json', nullable: true)]
private $metadata = [];
public function getId(): ?int
{
return $this->id;
}
public function getMccMnc(): ?int
{
return $this->mcc_mnc;
}
public function setMccMnc(?int $mcc_mnc): self
{
$this->mcc_mnc = $mcc_mnc;
return $this;
}
public function getMetadata(): ?array
{
return $this->metadata;
}
public function setMetadata(?array $metadata): self
{
$this->metadata = $metadata;
return $this;
}
}

View File

@ -4,7 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\MappedSuperclass]
////#[ORM\MappedSuperclass]
class Person1
{
#[ORM\Column(type: 'integer')]

View File

@ -4,7 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
////#[ORM\Entity]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
#[ORM\DiscriminatorMap(['person2' => 'Person2', 'employee2' => 'Employee2'])]

View File

@ -4,7 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
////#[ORM\Entity]
#[ORM\InheritanceType('JOINED')]
#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
#[ORM\DiscriminatorMap(['person3' => 'Person3', 'employee3' => 'Employee3'])]

View File

@ -4,7 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
////#[ORM\Entity]
class Toothbrush1
{
#[ORM\Id]

View File

@ -4,7 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
////#[ORM\Entity]
class Toothbrush2
{
#[ORM\Id]

View File

@ -4,7 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
////#[ORM\Entity]
class Toothbrush3
{
#[ORM\Id]

View File

@ -0,0 +1,65 @@
<?php
namespace App\Repository;
use App\Entity\MerBeDM;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<MerBeDM>
* @method MerBeDM|null find($id, $lockMode = null, $lockVersion = null)
* @method MerBeDM|null findOneBy(array $criteria, array $orderBy = null)
* @method MerBeDM[] findAll()
* @method MerBeDM[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class MerBeDMRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, MerBeDM::class);
}
public function add(MerBeDM $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(MerBeDM $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return MerBeDM[] Returns an array of MerBeDM objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('m.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?MerBeDM
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@ -0,0 +1,65 @@
<?php
namespace App\Repository;
use App\Entity\MerDM;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<MerDM>
* @method MerDM|null find($id, $lockMode = null, $lockVersion = null)
* @method MerDM|null findOneBy(array $criteria, array $orderBy = null)
* @method MerDM[] findAll()
* @method MerDM[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class MerDMRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, MerDM::class);
}
public function add(MerDM $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(MerDM $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return MerDM[] Returns an array of MerDM objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('m.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?MerDM
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@ -0,0 +1,65 @@
<?php
namespace App\Repository;
use App\Entity\MerDT;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<MerDT>
* @method MerDT|null find($id, $lockMode = null, $lockVersion = null)
* @method MerDT|null findOneBy(array $criteria, array $orderBy = null)
* @method MerDT[] findAll()
* @method MerDT[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class MerDTRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, MerDT::class);
}
public function add(MerDT $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(MerDT $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return MerDT[] Returns an array of MerDT objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('m.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?MerDT
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@ -0,0 +1,65 @@
<?php
namespace App\Repository;
use App\Entity\MerParaDM;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<MerParaDM>
* @method MerParaDM|null find($id, $lockMode = null, $lockVersion = null)
* @method MerParaDM|null findOneBy(array $criteria, array $orderBy = null)
* @method MerParaDM[] findAll()
* @method MerParaDM[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class MerParaDMRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, MerParaDM::class);
}
public function add(MerParaDM $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(MerParaDM $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return MerParaDM[] Returns an array of MerParaDM objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('m.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?MerParaDM
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@ -0,0 +1,65 @@
<?php
namespace App\Repository;
use App\Entity\MerParaDT;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<MerParaDT>
* @method MerParaDT|null find($id, $lockMode = null, $lockVersion = null)
* @method MerParaDT|null findOneBy(array $criteria, array $orderBy = null)
* @method MerParaDT[] findAll()
* @method MerParaDT[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class MerParaDTRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, MerParaDT::class);
}
public function add(MerParaDT $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(MerParaDT $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return MerParaDT[] Returns an array of MerParaDT objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('m.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?MerParaDT
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Repository;
use App\Entity\MerParaSub;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<MerParaSub>
*
* @method MerParaSub|null find($id, $lockMode = null, $lockVersion = null)
* @method MerParaSub|null findOneBy(array $criteria, array $orderBy = null)
* @method MerParaSub[] findAll()
* @method MerParaSub[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class MerParaSubRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, MerParaSub::class);
}
public function add(MerParaSub $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(MerParaSub $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return MerParaSub[] Returns an array of MerParaSub objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('m.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
public function findOneById(int $id): ?MerParaSub
{
return $this->createQueryBuilder('m')
->andWhere('m.id = :val')
->setParameter('val', $id)
->getQuery()
->getOneOrNullResult()
;
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace App\Repository;
use App\Entity\MerService;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<MerService>
* @method MerService|null find($id, $lockMode = null, $lockVersion = null)
* @method MerService|null findOneBy(array $criteria, array $orderBy = null)
* @method MerService[] findAll()
* @method MerService[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class MerServiceRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, MerService::class);
}
public function add(MerService $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(MerService $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return MerService[] Returns an array of MerService objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('m.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?MerService
// {
// return $this->createQueryBuilder('m')
// ->andWhere('m.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}