Skip to content

Commit 0293de7

Browse files
authored
Merge pull request #339 from dotkernel/issue-336
Implemented doctrine enums
2 parents 3938f68 + 34140c0 commit 0293de7

File tree

66 files changed

+635
-324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+635
-324
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
"Admin\\Admin\\": "src/Admin/src/",
7474
"Admin\\Page\\": "src/Page/src/",
7575
"Admin\\Dashboard\\": "src/Dashboard/src/",
76-
"Admin\\Setting\\": "src/Setting/src/"
76+
"Admin\\Setting\\": "src/Setting/src/",
77+
"Admin\\Fixtures\\": "data/doctrine/fixtures"
7778
}
7879
},
7980
"autoload-dev": {

config/autoload/authentication.global.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
'doctrine' => [
99
'authentication' => [
1010
'orm_default' => [
11-
'object_manager' => 'doctrine.entitymanager.orm_default',
11+
'object_manager' => 'doctrine.entity_manager.orm_default',
1212
'identity_class' => Admin::class,
1313
'identity_property' => 'identity',
1414
'credential_property' => 'password',

config/cli-config.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,4 @@
1313

1414
$entityManager = $container->get(EntityManager::class);
1515

16-
// register enum type for doctrine
17-
$entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
18-
1916
return DependencyFactory::fromEntityManager($config, new ExistingEntityManager($entityManager));

data/doctrine/fixtures/AdminLoader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Admin\Admin\Entity\Admin;
88
use Admin\Admin\Entity\AdminRole;
9+
use Admin\Admin\Enum\AdminRoleEnum;
910
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
1011
use Doctrine\Common\DataFixtures\FixtureInterface;
1112
use Doctrine\Persistence\ObjectManager;
@@ -24,7 +25,7 @@ public function load(ObjectManager $manager): void
2425
->setFirstName('Dotkernel')
2526
->setLastName('Admin')
2627
->addRole(
27-
$manager->getRepository(AdminRole::class)->findOneBy(['name' => AdminRole::ROLE_SUPERUSER])
28+
$manager->getRepository(AdminRole::class)->findOneBy(['name' => AdminRoleEnum::Superuser])
2829
);
2930

3031
$manager->persist($admin);

data/doctrine/fixtures/AdminRoleLoader.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Admin\Fixtures;
66

77
use Admin\Admin\Entity\AdminRole;
8+
use Admin\Admin\Enum\AdminRoleEnum;
89
use Doctrine\Common\DataFixtures\FixtureInterface;
910
use Doctrine\Persistence\ObjectManager;
1011

@@ -13,10 +14,10 @@ class AdminRoleLoader implements FixtureInterface
1314
public function load(ObjectManager $manager): void
1415
{
1516
$manager->persist(
16-
(new AdminRole())->setName(AdminRole::ROLE_SUPERUSER)
17+
(new AdminRole())->setName(AdminRoleEnum::Superuser)
1718
);
1819
$manager->persist(
19-
(new AdminRole())->setName(AdminRole::ROLE_ADMIN)
20+
(new AdminRole())->setName(AdminRoleEnum::Admin)
2021
);
2122

2223
$manager->flush();

data/doctrine/migrations/Version20240627134952.php renamed to data/doctrine/migrations/Version20250310084727.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* Auto-generated Migration: Please modify to your needs!
1212
*/
13-
final class Version20240627134952 extends AbstractMigration
13+
final class Version20250310084727 extends AbstractMigration
1414
{
1515
public function getDescription(): string
1616
{
@@ -20,11 +20,11 @@ public function getDescription(): string
2020
public function up(Schema $schema): void
2121
{
2222
// this up() migration is auto-generated, please modify it to your needs
23-
$this->addSql('CREATE TABLE admin (uuid BINARY(16) NOT NULL, identity VARCHAR(100) NOT NULL, firstName VARCHAR(255) DEFAULT NULL, lastName VARCHAR(255) DEFAULT NULL, password VARCHAR(100) NOT NULL, status ENUM(\'pending\', \'active\'), created DATETIME NOT NULL, updated DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_880E0D766A95E9C4 (identity), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4');
23+
$this->addSql('CREATE TABLE admin (uuid BINARY(16) NOT NULL, identity VARCHAR(100) NOT NULL, firstName VARCHAR(255) DEFAULT NULL, lastName VARCHAR(255) DEFAULT NULL, password VARCHAR(100) NOT NULL, status ENUM(\'active\', \'inactive\') DEFAULT \'active\' NOT NULL, created DATETIME NOT NULL, updated DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_880E0D766A95E9C4 (identity), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4');
2424
$this->addSql('CREATE TABLE admin_roles (userUuid BINARY(16) NOT NULL, roleUuid BINARY(16) NOT NULL, INDEX IDX_1614D53DD73087E9 (userUuid), INDEX IDX_1614D53D88446210 (roleUuid), PRIMARY KEY(userUuid, roleUuid)) DEFAULT CHARACTER SET utf8mb4');
25-
$this->addSql('CREATE TABLE admin_login (uuid BINARY(16) NOT NULL, adminIp VARCHAR(50) DEFAULT NULL, country VARCHAR(50) DEFAULT NULL, continent VARCHAR(50) DEFAULT NULL, organization VARCHAR(50) DEFAULT NULL, deviceType VARCHAR(20) DEFAULT NULL, deviceBrand VARCHAR(20) DEFAULT NULL, deviceModel VARCHAR(40) DEFAULT NULL, isMobile ENUM(\'yes\', \'no\'), osName VARCHAR(20) DEFAULT NULL, osVersion VARCHAR(20) DEFAULT NULL, osPlatform VARCHAR(20) DEFAULT NULL, clientType VARCHAR(20) DEFAULT NULL, clientName VARCHAR(40) DEFAULT NULL, clientEngine VARCHAR(20) DEFAULT NULL, clientVersion VARCHAR(20) DEFAULT NULL, loginStatus ENUM(\'success\', \'fail\'), identity VARCHAR(100) DEFAULT NULL, created DATETIME NOT NULL, updated DATETIME DEFAULT NULL, PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4');
26-
$this->addSql('CREATE TABLE admin_role (uuid BINARY(16) NOT NULL, name VARCHAR(30) NOT NULL, created DATETIME NOT NULL, updated DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_7770088A5E237E06 (name), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4');
27-
$this->addSql('CREATE TABLE settings (uuid BINARY(16) NOT NULL, identifier VARCHAR(50) NOT NULL, value LONGTEXT NOT NULL, created DATETIME NOT NULL, updated DATETIME DEFAULT NULL, admin_uuid BINARY(16) DEFAULT NULL, INDEX IDX_E545A0C5F166D246 (admin_uuid), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4');
25+
$this->addSql('CREATE TABLE admin_login (uuid BINARY(16) NOT NULL, adminIp VARCHAR(50) DEFAULT NULL, country VARCHAR(50) DEFAULT NULL, continent VARCHAR(50) DEFAULT NULL, organization VARCHAR(50) DEFAULT NULL, deviceType VARCHAR(20) DEFAULT NULL, deviceBrand VARCHAR(20) DEFAULT NULL, deviceModel VARCHAR(40) DEFAULT NULL, isMobile ENUM(\'yes\', \'no\') DEFAULT NULL, osName VARCHAR(20) DEFAULT NULL, osVersion VARCHAR(20) DEFAULT NULL, osPlatform VARCHAR(20) DEFAULT NULL, clientType VARCHAR(20) DEFAULT NULL, clientName VARCHAR(40) DEFAULT NULL, clientEngine VARCHAR(20) DEFAULT NULL, clientVersion VARCHAR(20) DEFAULT NULL, loginStatus ENUM(\'success\', \'fail\') DEFAULT NULL, identity VARCHAR(100) DEFAULT NULL, created DATETIME NOT NULL, updated DATETIME DEFAULT NULL, PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4');
26+
$this->addSql('CREATE TABLE admin_role (uuid BINARY(16) NOT NULL, name ENUM(\'admin\', \'superuser\') DEFAULT \'admin\', created DATETIME NOT NULL, updated DATETIME DEFAULT NULL, PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4');
27+
$this->addSql('CREATE TABLE settings (uuid BINARY(16) NOT NULL, identifier ENUM(\'table_admin_list_selected_columns\', \'table_admin_list_logins_selected_columns\') NOT NULL, value LONGTEXT NOT NULL, created DATETIME NOT NULL, updated DATETIME DEFAULT NULL, admin_uuid BINARY(16) DEFAULT NULL, INDEX IDX_E545A0C5F166D246 (admin_uuid), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4');
2828
$this->addSql('ALTER TABLE admin_roles ADD CONSTRAINT FK_1614D53DD73087E9 FOREIGN KEY (userUuid) REFERENCES admin (uuid)');
2929
$this->addSql('ALTER TABLE admin_roles ADD CONSTRAINT FK_1614D53D88446210 FOREIGN KEY (roleUuid) REFERENCES admin_role (uuid)');
3030
$this->addSql('ALTER TABLE settings ADD CONSTRAINT FK_E545A0C5F166D246 FOREIGN KEY (admin_uuid) REFERENCES admin (uuid)');

public/images/loading-sm.gif

-2.61 KB
Loading

public/images/loading.gif

-847 Bytes
Loading

public/js/app.js

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/table_settings.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)