orm icon indicating copy to clipboard operation
orm copied to clipboard

[QUESTION]. Missing DatabasePresenceVerifierInterface In DoctrinePresenceVerifier Class

Open yusrub opened this issue 3 years ago • 2 comments

Please prefix your issue with one of the following: [BUG] [PROPOSAL] [QUESTION].

Laravel Doctrine Version >1.4, Laravel Version 8.12

I am trying to using the Laravel exists function for validating the Doctrine Entity in Laravel 8. I have two different managers in doctrine config one is default and the other is yusrub.

I defined the database connections in config/databse.php with the name of yusrub.

public function rules()
{
  return [
      'incrementId'  => 'required|exists:connection.yusrub.Yusrub\Order\Domain\Entities\Order',
   ];
}

But When I run the code it always picks the default connection, not the yusrub connection.

Expected behaviour

It should pick the yusrub connection, not the default connection.

Actual behaviour

But When I run the code it always picks the default connection, not the yusrub connection.

Steps to reproduce the behaviour

I debug the code and found in laravel 8.12 there is the change in implementation in Class Illuminate\Validation\Validor

public function getPresenceVerifier($connection = null)
    {
        if (! isset($this->presenceVerifier)) {
            throw new RuntimeException('Presence verifier has not been set.');
        }

        if ($this->presenceVerifier instanceof DatabasePresenceVerifierInterface) {
            $this->presenceVerifier->setConnection($connection);
        }

        return $this->presenceVerifier;
    }

Where the Laravel Doctrine PresenseVerifier class LaravelDoctrine\ORM\Validation does not implement the DatabasePresenceVerifierInterface interface that is why it's always picking the default connection.

My Question, are we going to fix this issue?

yusrub avatar Jul 26 '21 11:07 yusrub

Good catch 👍🏻 Looks like you found the correct solution (implement interface). Could you provide a pull request for this? 🙂

eigan avatar Jul 26 '21 13:07 eigan

Sure, Let me Create a PR for It.

yusrub avatar Jul 26 '21 15:07 yusrub