Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illuminate\Validation\PresenceVerifierInterface needs implementation of setConnection() method? #12250

Closed
feralc opened this issue Feb 11, 2016 · 3 comments

Comments

@feralc
Copy link

feralc commented Feb 11, 2016

I needed my own implementation of the Illuminate\Validation\PresenceVerifierInterface, but when the framework was executed, an exception was launched.

In my controller I did something like:

$myValidatorInstance->setPresenceVerifier($myVerifierImplementation);

Then I noticed that the PresenceVerifierInterface does not contain the method setConnection(), but this method is called at the instance verifier in Illuminate\Validation\Validator.php in validateUnique () method, which results in an exception.

I believe that the setConnection () method should not be necessarily implemented, since I do not need it, correct me if I'm mistaken.

@GrahamCampbell
Copy link
Member

Sorry, but we do not include setters and getters on our interfaces.

@feralc
Copy link
Author

feralc commented Feb 12, 2016

Yes, this method should not be in the interface, but the problem is that it is called as quoted above.

what happens is that so I am obliged to implement a method that does not need, in this case setConnection(), to solve my problem, had to leave this method unimplemented:

class MyPresenceVerifier implements Illuminate\Validation\PresenceVerifierInterface  {

    public function getCount($collection, $column, $value, $excludeId = null, $idColumn = null, array $extra = []) 
    {
        //Do something here
    }

    public function getMultiCount($collection, $column, array $values, array $extra = [])
    {
        //Do something here
    }

    public function setConnection()
    {
        //That's the problem, without that an exception is thrown
    }

}

@drbyte
Copy link
Contributor

drbyte commented Dec 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants