Skip to content

Commit

Permalink
Merge pull request #271 from thecodingmachine/fix/doctrine-inflector
Browse files Browse the repository at this point in the history
🐛 Inflector::* has been removed in `doctrine/inflector@^2.0`
  • Loading branch information
homersimpsons authored Apr 29, 2022
2 parents 8da64b2 + 60c2c43 commit e606c0e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Utils/PivotTableMethodsDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace TheCodingMachine\TDBM\Utils;

use Doctrine\Common\Inflector\Inflector;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Table;
Expand Down Expand Up @@ -121,7 +120,7 @@ public function getResultIteratorClassName(): string
private function getPluralName() : string
{
if ($this->isAutoPivot()) {
$name = Inflector::pluralize($this->namingStrategy->getAutoPivotEntityName($this->remoteFk, false));
$name = TDBMDaoGenerator::toPlural($this->namingStrategy->getAutoPivotEntityName($this->remoteFk, false));
if ($this->useAlternateName) {
$name .= 'By_'.$this->pivotTable->getName();
}
Expand Down
13 changes: 13 additions & 0 deletions src/Utils/TDBMDaoGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,19 @@ public static function toSingular(string $str): string
return self::$inflector->singularize($str);
}

/**
* Tries to put string to the plural form (if it is singular).
* We assume the string is in english.
*/
public static function toPlural(string $str): string
{
if (self::$inflector === null) {
self::$inflector = InflectorFactory::create()->build();
}

return self::$inflector->pluralize($str);
}

/**
* Put the first letter of the string in lower case.
* Very useful to transform a class name into a variable name.
Expand Down

0 comments on commit e606c0e

Please sign in to comment.