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

Question: function in repository but not in interface #32

Open
dabernathy89 opened this issue Mar 17, 2014 · 1 comment
Open

Question: function in repository but not in interface #32

dabernathy89 opened this issue Mar 17, 2014 · 1 comment

Comments

@dabernathy89
Copy link

So I'm still learning about interfaces and using the repository pattern in Laravel. My question is whether the controller should be calling a method on the repository that is not present on that repository's interface. For example, in the UserTricksController, we call getEditForm on the Trick repository (line 122):

$form  = $this->trick->getEditForm($trick->id);

The getEditForm method is not present on the TrickRepositoryInterface, however, but it is on the TrickRepository.

@dabernathy89 dabernathy89 changed the title Question: functions implemented but not in interface Question: function in repository but not in interface Mar 17, 2014
@matiit
Copy link

matiit commented May 8, 2014

IMO you should not doing that.
The obvious thing is that you can change TrickRepository to for example TrickJsonRepository which would implement TrickRepositoryInterface.

And you will get into troubles because you won't have any hint about needing to implement getEditForm.

You should:
add getEditForm to TrickRepositoryInterface
or delegate it to something else.. Like FormBuilder or whatever

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

2 participants