-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy path01-entity-setup.php
More file actions
91 lines (76 loc) · 2.38 KB
/
01-entity-setup.php
File metadata and controls
91 lines (76 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* Example 1: Tenant Database Configuration Entity
*
* Every application using this bundle needs an entity that stores
* the connection details for each tenant database.
*
* Use TenantDbConfigTrait for the standard fields, then implement
* TenantDbConfigurationInterface. The trait provides: dbName, driverType,
* dbUserName, dbPassword, dbHost, dbPort, databaseStatus.
*/
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Hakam\MultiTenancyBundle\Enum\DatabaseStatusEnum;
use Hakam\MultiTenancyBundle\Enum\DriverTypeEnum;
use Hakam\MultiTenancyBundle\Services\TenantDbConfigurationInterface;
use Hakam\MultiTenancyBundle\Traits\TenantDbConfigTrait;
#[ORM\Entity]
#[ORM\Table(name: 'tenant_db_config')]
class TenantDbConfig implements TenantDbConfigurationInterface
{
use TenantDbConfigTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
/**
* You can add custom fields specific to your application.
*/
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $companyName = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $plan = null;
public function getId(): ?int
{
return $this->id;
}
/**
* IMPORTANT: PHP method names are case-insensitive.
* The trait defines getDbUserName() and the interface defines getDbUsername().
* These are the SAME method in PHP, so this alias must access
* the property directly to avoid infinite recursion.
*/
public function getDbUsername(): ?string
{
return $this->dbUserName;
}
/**
* Required by TenantDbConfigurationInterface.
* Returns the value used as the tenant identifier (configured via
* tenant_database_identifier in your bundle config).
*/
public function getIdentifierValue(): mixed
{
return $this->id;
}
// Custom getters/setters for your application fields
public function getCompanyName(): ?string
{
return $this->companyName;
}
public function setCompanyName(?string $companyName): self
{
$this->companyName = $companyName;
return $this;
}
public function getPlan(): ?string
{
return $this->plan;
}
public function setPlan(?string $plan): self
{
$this->plan = $plan;
return $this;
}
}