Compare commits

..

No commits in common. "86205bbdbab45f61666842ea535e06c7a4eefc10" and "53a3f43d75ff6e77f1e0b5de7b681d298fd493e2" have entirely different histories.

19 changed files with 2 additions and 908 deletions

1
.gitignore vendored
View File

@ -8,4 +8,3 @@
/var/ /var/
/vendor/ /vendor/
###< symfony/framework-bundle ### ###< symfony/framework-bundle ###
.idea/

View File

@ -1,6 +1,5 @@
``` ```
symfony server:start symfony server:start
symfony console list make
symfony console make:migration symfony console make:migration
symfony console doctrine:migrations:migrate symfony console doctrine:migrations:migrate
symfony console doctrine:fixtures:load symfony console doctrine:fixtures:load

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220522111615 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)');
$this->addSql('CREATE TABLE toothbrush1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, brand VARCHAR(255) NOT NULL)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE employee1');
$this->addSql('DROP TABLE toothbrush1');
}
}

View File

@ -1,48 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220522115037 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE person2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush2_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL, job VARCHAR(255) DEFAULT NULL)');
$this->addSql('CREATE INDEX IDX_A387B6D5189073D6 ON person2 (toothbrush2_id)');
$this->addSql('CREATE TABLE toothbrush2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, brand VARCHAR(255) NOT NULL)');
$this->addSql('DROP INDEX UNIQ_2250E3BCA25DC38');
$this->addSql('CREATE TEMPORARY TABLE __temp__employee1 AS SELECT id, toothbrush1_id, job, age, name FROM employee1');
$this->addSql('DROP TABLE employee1');
$this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, CONSTRAINT FK_2250E3BCA25DC38 FOREIGN KEY (toothbrush1_id) REFERENCES toothbrush1 (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('INSERT INTO employee1 (id, toothbrush1_id, job, age, name) SELECT id, toothbrush1_id, job, age, name FROM __temp__employee1');
$this->addSql('DROP TABLE __temp__employee1');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE person2');
$this->addSql('DROP TABLE toothbrush2');
$this->addSql('DROP INDEX UNIQ_2250E3BCA25DC38');
$this->addSql('CREATE TEMPORARY TABLE __temp__employee1 AS SELECT id, toothbrush1_id, job, age, name FROM employee1');
$this->addSql('DROP TABLE employee1');
$this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL)');
$this->addSql('INSERT INTO employee1 (id, toothbrush1_id, job, age, name) SELECT id, toothbrush1_id, job, age, name FROM __temp__employee1');
$this->addSql('DROP TABLE __temp__employee1');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)');
}
}

View File

@ -1,64 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220522153147 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE employee3 (id INTEGER NOT NULL, job VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE person3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush3_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_D4808643A02C14B3 ON person3 (toothbrush3_id)');
$this->addSql('CREATE TABLE toothbrush3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, brand VARCHAR(255) NOT NULL)');
$this->addSql('DROP INDEX UNIQ_2250E3BCA25DC38');
$this->addSql('CREATE TEMPORARY TABLE __temp__employee1 AS SELECT id, toothbrush1_id, job, age, name FROM employee1');
$this->addSql('DROP TABLE employee1');
$this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, CONSTRAINT FK_2250E3BCA25DC38 FOREIGN KEY (toothbrush1_id) REFERENCES toothbrush1 (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('INSERT INTO employee1 (id, toothbrush1_id, job, age, name) SELECT id, toothbrush1_id, job, age, name FROM __temp__employee1');
$this->addSql('DROP TABLE __temp__employee1');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)');
$this->addSql('DROP INDEX IDX_A387B6D5189073D6');
$this->addSql('CREATE TEMPORARY TABLE __temp__person2 AS SELECT id, toothbrush2_id, age, name, discr, job FROM person2');
$this->addSql('DROP TABLE person2');
$this->addSql('CREATE TABLE person2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush2_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL, job VARCHAR(255) DEFAULT NULL, CONSTRAINT FK_A387B6D5189073D6 FOREIGN KEY (toothbrush2_id) REFERENCES toothbrush2 (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('INSERT INTO person2 (id, toothbrush2_id, age, name, discr, job) SELECT id, toothbrush2_id, age, name, discr, job FROM __temp__person2');
$this->addSql('DROP TABLE __temp__person2');
$this->addSql('CREATE INDEX IDX_A387B6D5189073D6 ON person2 (toothbrush2_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE employee3');
$this->addSql('DROP TABLE person3');
$this->addSql('DROP TABLE toothbrush3');
$this->addSql('DROP INDEX UNIQ_2250E3BCA25DC38');
$this->addSql('CREATE TEMPORARY TABLE __temp__employee1 AS SELECT id, toothbrush1_id, job, age, name FROM employee1');
$this->addSql('DROP TABLE employee1');
$this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL)');
$this->addSql('INSERT INTO employee1 (id, toothbrush1_id, job, age, name) SELECT id, toothbrush1_id, job, age, name FROM __temp__employee1');
$this->addSql('DROP TABLE __temp__employee1');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)');
$this->addSql('DROP INDEX IDX_A387B6D5189073D6');
$this->addSql('CREATE TEMPORARY TABLE __temp__person2 AS SELECT id, toothbrush2_id, age, name, discr, job FROM person2');
$this->addSql('DROP TABLE person2');
$this->addSql('CREATE TABLE person2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush2_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL, job VARCHAR(255) DEFAULT NULL)');
$this->addSql('INSERT INTO person2 (id, toothbrush2_id, age, name, discr, job) SELECT id, toothbrush2_id, age, name, discr, job FROM __temp__person2');
$this->addSql('DROP TABLE __temp__person2');
$this->addSql('CREATE INDEX IDX_A387B6D5189073D6 ON person2 (toothbrush2_id)');
}
}

View File

@ -1,81 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220522154942 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX UNIQ_2250E3BCA25DC38');
$this->addSql('CREATE TEMPORARY TABLE __temp__employee1 AS SELECT id, toothbrush1_id, job, age, name FROM employee1');
$this->addSql('DROP TABLE employee1');
$this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, CONSTRAINT FK_2250E3BCA25DC38 FOREIGN KEY (toothbrush1_id) REFERENCES toothbrush1 (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('INSERT INTO employee1 (id, toothbrush1_id, job, age, name) SELECT id, toothbrush1_id, job, age, name FROM __temp__employee1');
$this->addSql('DROP TABLE __temp__employee1');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)');
$this->addSql('CREATE TEMPORARY TABLE __temp__employee3 AS SELECT id, job FROM employee3');
$this->addSql('DROP TABLE employee3');
$this->addSql('CREATE TABLE employee3 (id INTEGER NOT NULL, job VARCHAR(255) NOT NULL, PRIMARY KEY(id), CONSTRAINT FK_CC5E8290BF396750 FOREIGN KEY (id) REFERENCES person3 (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('INSERT INTO employee3 (id, job) SELECT id, job FROM __temp__employee3');
$this->addSql('DROP TABLE __temp__employee3');
$this->addSql('DROP INDEX IDX_A387B6D5189073D6');
$this->addSql('CREATE TEMPORARY TABLE __temp__person2 AS SELECT id, toothbrush2_id, age, name, discr, job FROM person2');
$this->addSql('DROP TABLE person2');
$this->addSql('CREATE TABLE person2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush2_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL, job VARCHAR(255) DEFAULT NULL, CONSTRAINT FK_A387B6D5189073D6 FOREIGN KEY (toothbrush2_id) REFERENCES toothbrush2 (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('INSERT INTO person2 (id, toothbrush2_id, age, name, discr, job) SELECT id, toothbrush2_id, age, name, discr, job FROM __temp__person2');
$this->addSql('DROP TABLE __temp__person2');
$this->addSql('CREATE INDEX IDX_A387B6D5189073D6 ON person2 (toothbrush2_id)');
$this->addSql('DROP INDEX UNIQ_D4808643A02C14B3');
$this->addSql('CREATE TEMPORARY TABLE __temp__person3 AS SELECT id, toothbrush3_id, age, name, discr FROM person3');
$this->addSql('DROP TABLE person3');
$this->addSql('CREATE TABLE person3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush3_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL, CONSTRAINT FK_D4808643A02C14B3 FOREIGN KEY (toothbrush3_id) REFERENCES toothbrush3 (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('INSERT INTO person3 (id, toothbrush3_id, age, name, discr) SELECT id, toothbrush3_id, age, name, discr FROM __temp__person3');
$this->addSql('DROP TABLE __temp__person3');
$this->addSql('CREATE UNIQUE INDEX UNIQ_D4808643A02C14B3 ON person3 (toothbrush3_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX UNIQ_2250E3BCA25DC38');
$this->addSql('CREATE TEMPORARY TABLE __temp__employee1 AS SELECT id, toothbrush1_id, job, age, name FROM employee1');
$this->addSql('DROP TABLE employee1');
$this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL)');
$this->addSql('INSERT INTO employee1 (id, toothbrush1_id, job, age, name) SELECT id, toothbrush1_id, job, age, name FROM __temp__employee1');
$this->addSql('DROP TABLE __temp__employee1');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)');
$this->addSql('CREATE TEMPORARY TABLE __temp__employee3 AS SELECT id, job FROM employee3');
$this->addSql('DROP TABLE employee3');
$this->addSql('CREATE TABLE employee3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, job VARCHAR(255) NOT NULL)');
$this->addSql('INSERT INTO employee3 (id, job) SELECT id, job FROM __temp__employee3');
$this->addSql('DROP TABLE __temp__employee3');
$this->addSql('DROP INDEX IDX_A387B6D5189073D6');
$this->addSql('CREATE TEMPORARY TABLE __temp__person2 AS SELECT id, toothbrush2_id, age, name, discr, job FROM person2');
$this->addSql('DROP TABLE person2');
$this->addSql('CREATE TABLE person2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush2_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL, job VARCHAR(255) DEFAULT NULL)');
$this->addSql('INSERT INTO person2 (id, toothbrush2_id, age, name, discr, job) SELECT id, toothbrush2_id, age, name, discr, job FROM __temp__person2');
$this->addSql('DROP TABLE __temp__person2');
$this->addSql('CREATE INDEX IDX_A387B6D5189073D6 ON person2 (toothbrush2_id)');
$this->addSql('DROP INDEX UNIQ_D4808643A02C14B3');
$this->addSql('CREATE TEMPORARY TABLE __temp__person3 AS SELECT id, toothbrush3_id, age, name, discr FROM person3');
$this->addSql('DROP TABLE person3');
$this->addSql('CREATE TABLE person3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush3_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL)');
$this->addSql('INSERT INTO person3 (id, toothbrush3_id, age, name, discr) SELECT id, toothbrush3_id, age, name, discr FROM __temp__person3');
$this->addSql('DROP TABLE __temp__person3');
$this->addSql('CREATE UNIQUE INDEX UNIQ_D4808643A02C14B3 ON person3 (toothbrush3_id)');
}
}

View File

@ -2,7 +2,6 @@
namespace App\Controller; namespace App\Controller;
use Doctrine\ORM\EntityManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
@ -13,13 +12,11 @@ class IndexController extends AbstractController
#[Route('/', name: 'app_index')] #[Route('/', name: 'app_index')]
public function index(Entity1Repository $repo): Response public function index(Entity1Repository $repo): Response
{ {
$sm = $repo->getSchemaManager();
$entity8 = $repo->findOneByName('entity 8'); $entity8 = $repo->findOneByName('entity 8');
return $this->render('index/index.html.twig', [ return $this->render('index/index.html.twig', [
'controller_name' => 'IndexController', 'controller_name' => 'IndexController',
'entity8' => $entity8, 'entity8' => $entity8
'schemaManager' => $sm
]); ]);
} }
} }

View File

@ -1,26 +0,0 @@
<?php
namespace App\DataFixtures;
use App\Entity\Employee1;
use App\Entity\Toothbrush1;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
class InheritanceFixtures extends Fixture
{
public function load(ObjectManager $manager): void
{
$e1 = new Employee1();
$e1->setJob('peon')->setName('pepito')->setAge(20)->setToothbrush((new Toothbrush1())->setBrand('colgate'));
$manager->persist($e1);
$e1 = new Employee1();
$e1->setJob('jefe')->setName('benganito')->setAge(30)->setToothbrush((new Toothbrush1())->setBrand('signal'));
$manager->persist($e1);
$manager->flush();
}
}
// symfony console doctrine:fixtures:load

View File

@ -1,55 +0,0 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class Employee1 extends Person1
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string')]
private string $job;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
* @return Employee1
*/
public function setId(int $id): Employee1
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getJob(): string
{
return $this->job;
}
/**
* @param string $job
* @return Employee1
*/
public function setJob(string $job): Employee1
{
$this->job = $job;
return $this;
}
}

View File

@ -1,55 +0,0 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class Employee2 extends Person2
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string')]
private string $job;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
* @return Employee2
*/
public function setId(int $id): Employee2
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getJob(): string
{
return $this->job;
}
/**
* @param string $job
* @return Employee2
*/
public function setJob(string $job): Employee2
{
$this->job = $job;
return $this;
}
}

View File

@ -1,55 +0,0 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class Employee3 extends Person3
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string')]
private string $job;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
* @return Employee3
*/
public function setId(int $id): Employee3
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getJob(): string
{
return $this->job;
}
/**
* @param string $job
* @return Employee3
*/
public function setJob(string $job): Employee3
{
$this->job = $job;
return $this;
}
}

View File

@ -1,75 +0,0 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\MappedSuperclass]
class Person1
{
#[ORM\Column(type: 'integer')]
protected int $age;
#[ORM\Column(type: 'string')]
protected string $name;
#[ORM\OneToOne(targetEntity: 'Toothbrush1', cascade: ['persist'])]
#[ORM\JoinColumn(name: 'toothbrush1_id', referencedColumnName: 'id')]
protected Toothbrush1 $toothbrush;
/**
* @return int
*/
public function getAge(): int
{
return $this->age;
}
/**
* @param int $age
* @return Person1
*/
public function setAge(int $age): Person1
{
$this->age = $age;
return $this;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
* @return Person1
*/
public function setName(string $name): Person1
{
$this->name = $name;
return $this;
}
/**
* @return Toothbrush1
*/
public function getToothbrush(): Toothbrush1
{
return $this->toothbrush;
}
/**
* @param Toothbrush1 $toothbrush
* @return Person1
*/
public function setToothbrush(Toothbrush1 $toothbrush): Person1
{
$this->toothbrush = $toothbrush;
return $this;
}
}

View File

@ -1,101 +0,0 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
#[ORM\DiscriminatorMap(['person2' => 'Person2', 'employee2' => 'Employee2'])]
class Person2
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'integer')]
protected int $age;
#[ORM\Column(type: 'string')]
protected string $name;
#[ORM\OneToOne(targetEntity: 'Toothbrush2', cascade: ['persist'])]
#[ORM\JoinColumn(name: 'toothbrush2_id', referencedColumnName: 'id')]
protected Toothbrush2 $toothbrush;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
* @return Person2
*/
public function setId(int $id): Person2
{
$this->id = $id;
return $this;
}
/**
* @return int
*/
public function getAge(): int
{
return $this->age;
}
/**
* @param int $age
* @return Person2
*/
public function setAge(int $age): Person2
{
$this->age = $age;
return $this;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
* @return Person2
*/
public function setName(string $name): Person2
{
$this->name = $name;
return $this;
}
/**
* @return Toothbrush2
*/
public function getToothbrush(): Toothbrush2
{
return $this->toothbrush;
}
/**
* @param Toothbrush2 $toothbrush
* @return Person2
*/
public function setToothbrush(Toothbrush2 $toothbrush): Person2
{
$this->toothbrush = $toothbrush;
return $this;
}
}

View File

@ -1,101 +0,0 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[ORM\InheritanceType('JOINED')]
#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
#[ORM\DiscriminatorMap(['person3' => 'Person3', 'employee3' => 'Employee3'])]
class Person3
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'integer')]
protected int $age;
#[ORM\Column(type: 'string')]
protected string $name;
#[ORM\OneToOne(targetEntity: 'Toothbrush3', cascade: ['persist'])]
#[ORM\JoinColumn(name: 'toothbrush3_id', referencedColumnName: 'id')]
protected Toothbrush3 $toothbrush;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
* @return Person3
*/
public function setId(int $id): Person3
{
$this->id = $id;
return $this;
}
/**
* @return int
*/
public function getAge(): int
{
return $this->age;
}
/**
* @param int $age
* @return Person3
*/
public function setAge(int $age): Person3
{
$this->age = $age;
return $this;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
* @return Person3
*/
public function setName(string $name): Person3
{
$this->name = $name;
return $this;
}
/**
* @return Toothbrush3
*/
public function getToothbrush(): Toothbrush3
{
return $this->toothbrush;
}
/**
* @param Toothbrush3 $toothbrush
* @return Person3
*/
public function setToothbrush(Toothbrush3 $toothbrush): Person3
{
$this->toothbrush = $toothbrush;
return $this;
}
}

View File

@ -1,54 +0,0 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class Toothbrush1
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string')]
private string $brand;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
* @return Toothbrush1
*/
public function setId(int $id): Toothbrush1
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getBrand(): string
{
return $this->brand;
}
/**
* @param string $brand
* @return Toothbrush1
*/
public function setBrand(string $brand): Toothbrush1
{
$this->brand = $brand;
return $this;
}
}

View File

@ -1,54 +0,0 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class Toothbrush2
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string')]
private string $brand;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
* @return Toothbrush2
*/
public function setId(int $id): Toothbrush2
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getBrand(): string
{
return $this->brand;
}
/**
* @param string $brand
* @return Toothbrush2
*/
public function setBrand(string $brand): Toothbrush2
{
$this->brand = $brand;
return $this;
}
}

View File

@ -1,54 +0,0 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class Toothbrush3
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string')]
private string $brand;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
* @return Toothbrush3
*/
public function setId(int $id): Toothbrush3
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getBrand(): string
{
return $this->brand;
}
/**
* @param string $brand
* @return Toothbrush3
*/
public function setBrand(string $brand): Toothbrush3
{
$this->brand = $brand;
return $this;
}
}

View File

@ -63,15 +63,4 @@ class Entity1Repository extends ServiceEntityRepository
->getOneOrNullResult() ->getOneOrNullResult()
; ;
} }
/**
* https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/schema-manager.html
*
* @return \Doctrine\DBAL\Schema\AbstractSchemaManager|null
* @throws \Doctrine\DBAL\Exception
*/
public function getSchemaManager()
{
return $this->getEntityManager()->getConnection()->getSchemaManager();
}
} }

View File

@ -4,11 +4,6 @@
{% block body %} {% block body %}
<style> <style>
body {
background-color: black;
color: white;
font-family: monospace;
}
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; } .example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; } .example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style> </style>
@ -23,33 +18,5 @@
</ul> </ul>
</div> </div>
<ul> <p>entity8: {{ entity8.id }}</p>
{% for table in schemaManager.listTables %}
<li>
{{ table.name }}
<ul>
{% for column in schemaManager.listTableColumns(table.name) %}
<li>{{ column.name }} ({{ column.type.name }})</li>
{% endfor %}
<li>FK
<ul>
{% for fk in schemaManager.listTableForeignKeys(table.name) %}
<li>{{ fk.name ?? '??' }} ({{ fk.columns|join }}) -&gt; {{ fk.getForeignTableName() }}({{ fk.getForeignColumns()|join }})</li>
{% endfor %}
</ul>
</li>
<li>IX
<ul>
{% for fk in schemaManager.listTableIndexes(table.name) %}
<li>{{ fk.name }} ({{ fk.columns|join }})</li>
{% endfor %}
</ul>
</li>
</ul>
</li>
{% endfor %}
</ul>
{% endblock %} {% endblock %}