Skip to content
This repository has been archived by the owner on Jan 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #625 from TomHAnderson/hotfix/inflector
Browse files Browse the repository at this point in the history
Hotfix/inflector
  • Loading branch information
TomHAnderson committed Mar 30, 2018
2 parents 85c2c32 + 979a6f9 commit 027026a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/DoctrineModule/Stdlib/Hydrator/DoctrineObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ protected function toMany($object, $collectionName, $target, $values)
foreach ($identifier as $field) {
switch (gettype($value)) {
case 'object':
$getter = 'get' . ucfirst($field);
$getter = 'get' . Inflector::classify($field);

if (is_callable([$value, $getter])) {
$find[$field] = $value->$getter();
} elseif (property_exists($value, $field)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
namespace DoctrineModule\Stdlib\Hydrator\Strategy;

use InvalidArgumentException;
use Zend\Hydrator\Strategy\StrategyInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
use Zend\Hydrator\Strategy\StrategyInterface;
use Doctrine\Common\Util\Inflector;

/**
* @license MIT
Expand Down Expand Up @@ -124,7 +125,7 @@ public function extract($value)
protected function getCollectionFromObjectByValue()
{
$object = $this->getObject();
$getter = 'get' . ucfirst($this->getCollectionName());
$getter = 'get' . Inflector::classify($this->getCollectionName());

if (! method_exists($object, $getter)) {
throw new InvalidArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace DoctrineModule\Stdlib\Hydrator\Strategy;

use Doctrine\Common\Collections\Collection;
use LogicException;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Util\Inflector;

/**
* When this strategy is used for Collections, if the new collection does not contain elements that are present in
Expand All @@ -27,8 +28,8 @@ class AllowRemoveByValue extends AbstractCollectionStrategy
public function hydrate($value)
{
// AllowRemove strategy need "adder" and "remover"
$adder = 'add' . ucfirst($this->collectionName);
$remover = 'remove' . ucfirst($this->collectionName);
$adder = 'add' . Inflector::classify($this->collectionName);
$remover = 'remove' . Inflector::classify($this->collectionName);

if (! method_exists($this->object, $adder) || ! method_exists($this->object, $remover)) {
throw new LogicException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace DoctrineModule\Stdlib\Hydrator\Strategy;

use Doctrine\Common\Collections\Collection;
use LogicException;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Util\Inflector;

/**
* When this strategy is used for Collections, if the new collection does not contain elements that are present in
Expand All @@ -27,7 +28,7 @@ class DisallowRemoveByValue extends AbstractCollectionStrategy
public function hydrate($value)
{
// AllowRemove strategy need "adder"
$adder = 'add' . ucfirst($this->collectionName);
$adder = 'add' . Inflector::classify($this->collectionName);

if (! method_exists($this->object, $adder)) {
throw new LogicException(
Expand Down

0 comments on commit 027026a

Please sign in to comment.