Skip to content

Commit

Permalink
Merge pull request #700 from snapshotpl/update_to_doctrine_v3
Browse files Browse the repository at this point in the history
Update to doctrine v3
  • Loading branch information
TomHAnderson authored Jun 20, 2020
2 parents 4375dc7 + 352278b commit ade5281
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@
"require": {
"php": "^7.2",
"doctrine/cache": "^1.7",
"doctrine/common": "^2.8",
"doctrine/doctrine-laminas-hydrator": "^2.0.2",
"doctrine/persistence": "^1.3.7",
"doctrine/doctrine-laminas-hydrator": "^2.0.3",
"doctrine/event-manager": "^1.0.0",
"doctrine/inflector": "^2.0",
"doctrine/persistence": "^2.0",
"laminas/laminas-authentication": "^2.5.3",
"laminas/laminas-cache": "^2.7.1",
"laminas/laminas-form": "^2.11",
Expand Down
11 changes: 8 additions & 3 deletions src/DoctrineModule/Authentication/Adapter/ObjectRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace DoctrineModule\Authentication\Adapter;

use Doctrine\Common\Inflector\Inflector;
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;
use DoctrineModule\Options\Authentication as AuthenticationOptions;
use Laminas\Authentication\Adapter\AbstractAdapter;
use Laminas\Authentication\Adapter\Exception;
Expand Down Expand Up @@ -32,14 +33,18 @@ class ObjectRepository extends AbstractAdapter
*/
protected $authenticationResultInfo = null;

/** @var Inflector */
protected $inflector;

/**
* Constructor
*
* @param mixed[]|AuthenticationOptions $options
*/
public function __construct($options = [])
public function __construct($options = [], ?Inflector $inflector = null)
{
$this->setOptions($options);
$this->inflector = $inflector ?? InflectorFactory::create()->build();
}

/**
Expand Down Expand Up @@ -88,7 +93,7 @@ public function authenticate() : AuthenticationResult
protected function validateIdentity(object $identity) : AuthenticationResult
{
$credentialProperty = $this->options->getCredentialProperty();
$getter = 'get' . Inflector::classify($credentialProperty);
$getter = 'get' . $this->inflector->classify($credentialProperty);
$documentCredential = null;

if (method_exists($identity, $getter)) {
Expand Down
15 changes: 12 additions & 3 deletions src/DoctrineModule/Form/Element/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
namespace DoctrineModule\Form\Element;

use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Inflector\Inflector;
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;
use Doctrine\Persistence\ObjectManager;
use DoctrineModule\Persistence\ObjectManagerAwareInterface;
use Laminas\Stdlib\Guard\ArrayOrTraversableGuardTrait;
Expand Down Expand Up @@ -72,6 +73,14 @@ class Proxy implements ObjectManagerAwareInterface
/** @var string|null */
protected $optgroupDefault;

/** @var Inflector */
protected $inflector;

public function __construct(?Inflector $inflector = null)
{
$this->inflector = $inflector ?? InflectorFactory::create()->build();
}

/**
* @param mixed[] $options
*/
Expand Down Expand Up @@ -486,7 +495,7 @@ protected function loadValueOptions() : void
);
}

$getter = 'get' . Inflector::classify($property);
$getter = 'get' . $this->inflector->classify($property);

if (! is_callable([$object, $getter])) {
throw new RuntimeException(
Expand Down Expand Up @@ -546,7 +555,7 @@ protected function loadValueOptions() : void
}

// optgroup_identifier found, handle grouping
$optgroupGetter = 'get' . Inflector::classify($this->getOptgroupIdentifier());
$optgroupGetter = 'get' . $this->inflector->classify($this->getOptgroupIdentifier());

if (! is_callable([$object, $optgroupGetter])) {
throw new RuntimeException(
Expand Down

0 comments on commit ade5281

Please sign in to comment.