diff options
author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/doctrine/orm/src/Mapping/DefaultNamingStrategy.php | |
parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/doctrine/orm/src/Mapping/DefaultNamingStrategy.php')
-rw-r--r-- | vendor/doctrine/orm/src/Mapping/DefaultNamingStrategy.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Mapping/DefaultNamingStrategy.php b/vendor/doctrine/orm/src/Mapping/DefaultNamingStrategy.php new file mode 100644 index 0000000..15218f9 --- /dev/null +++ b/vendor/doctrine/orm/src/Mapping/DefaultNamingStrategy.php | |||
@@ -0,0 +1,68 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Mapping; | ||
6 | |||
7 | use function str_contains; | ||
8 | use function strrpos; | ||
9 | use function strtolower; | ||
10 | use function substr; | ||
11 | |||
12 | /** | ||
13 | * The default NamingStrategy | ||
14 | * | ||
15 | * @link www.doctrine-project.org | ||
16 | */ | ||
17 | class DefaultNamingStrategy implements NamingStrategy | ||
18 | { | ||
19 | public function classToTableName(string $className): string | ||
20 | { | ||
21 | if (str_contains($className, '\\')) { | ||
22 | return substr($className, strrpos($className, '\\') + 1); | ||
23 | } | ||
24 | |||
25 | return $className; | ||
26 | } | ||
27 | |||
28 | public function propertyToColumnName(string $propertyName, string $className): string | ||
29 | { | ||
30 | return $propertyName; | ||
31 | } | ||
32 | |||
33 | public function embeddedFieldToColumnName( | ||
34 | string $propertyName, | ||
35 | string $embeddedColumnName, | ||
36 | string $className, | ||
37 | string $embeddedClassName, | ||
38 | ): string { | ||
39 | return $propertyName . '_' . $embeddedColumnName; | ||
40 | } | ||
41 | |||
42 | public function referenceColumnName(): string | ||
43 | { | ||
44 | return 'id'; | ||
45 | } | ||
46 | |||
47 | public function joinColumnName(string $propertyName, string $className): string | ||
48 | { | ||
49 | return $propertyName . '_' . $this->referenceColumnName(); | ||
50 | } | ||
51 | |||
52 | public function joinTableName( | ||
53 | string $sourceEntity, | ||
54 | string $targetEntity, | ||
55 | string $propertyName, | ||
56 | ): string { | ||
57 | return strtolower($this->classToTableName($sourceEntity) . '_' . | ||
58 | $this->classToTableName($targetEntity)); | ||
59 | } | ||
60 | |||
61 | public function joinKeyColumnName( | ||
62 | string $entityName, | ||
63 | string|null $referencedColumnName, | ||
64 | ): string { | ||
65 | return strtolower($this->classToTableName($entityName) . '_' . | ||
66 | ($referencedColumnName ?: $this->referenceColumnName())); | ||
67 | } | ||
68 | } | ||