3
3
4
4
namespace TheCodingMachine \TDBM \Utils ;
5
5
6
+ use Doctrine \Common \Inflector \Inflector ;
6
7
use Doctrine \DBAL \Schema \Column ;
7
8
use Doctrine \DBAL \Schema \ForeignKeyConstraint ;
8
9
use Doctrine \DBAL \Schema \Table ;
@@ -114,7 +115,10 @@ public function getBeanClassName(): string
114
115
private function getPluralName () : string
115
116
{
116
117
if ($ this ->isAutoPivot ()) {
117
- $ name = $ this ->remoteFk ->getForeignTableName ().'By_ ' .$ this ->pivotTable ->getName ().'Via_ ' .implode ('And_ ' , $ this ->localFk ->getUnquotedLocalColumns ());
118
+ $ name = Inflector::pluralize ($ this ->namingStrategy ->getAutopivotEntityNameFrom ($ this ->remoteFk , false ));
119
+ if ($ this ->useAlternateName ) {
120
+ $ name .= 'By_ ' .$ this ->pivotTable ->getName ();
121
+ }
118
122
} elseif (!$ this ->useAlternateName ) {
119
123
$ name = $ this ->remoteFk ->getForeignTableName ();
120
124
} else {
@@ -131,8 +135,11 @@ private function getPluralName() : string
131
135
private function getSingularName () : string
132
136
{
133
137
if ($ this ->isAutoPivot ()) {
134
- $ name = TDBMDaoGenerator::toSingular ($ this ->remoteFk ->getForeignTableName ()).'By_ ' .$ this ->pivotTable ->getName ().'Via_ ' .implode ('And_ ' , $ this ->localFk ->getUnquotedLocalColumns ());
135
- } elseif (!$ this ->useAlternateName ) {
138
+ $ name = $ this ->namingStrategy ->getAutopivotEntityNameFrom ($ this ->remoteFk , false );
139
+ if ($ this ->useAlternateName ) {
140
+ $ name .= 'By_ ' .$ this ->pivotTable ->getName ();
141
+ }
142
+ } else if (!$ this ->useAlternateName ) {
136
143
$ name = TDBMDaoGenerator::toSingular ($ this ->remoteFk ->getForeignTableName ());
137
144
} else {
138
145
$ name = TDBMDaoGenerator::toSingular ($ this ->remoteFk ->getForeignTableName ()).'By_ ' .$ this ->pivotTable ->getName ();
0 commit comments