-
Notifications
You must be signed in to change notification settings - Fork 159
Fix: Move plugin functionality into appropriate service #365
Fix: Move plugin functionality into appropriate service #365
Conversation
77a1f60
to
07c5142
Compare
@@ -5,9 +5,12 @@ | |||
|
|||
return [ | |||
'controllers' => [ | |||
'invokables' => [ | |||
'aliases' => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to alias, otherwise the configuration of https://github.com/ZF-Commons/ZfcUser/blob/1.0.0/config/module.config.php#L8-L12 kicks in.
$user = isset($options['user']) ? $options['user'] : false; | ||
|
||
//limit modules to only user modules | ||
if ($user) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I am at it, I would like to remove the options, since there's only one call to this method (YAGNI), but maybe you prefer a separate PR? Still in the mood for cleaning things before moving on to actually implementing new features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@localheinz why not just providing a custom method? Cleaner and more expressive, IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait till I finish my taxes, will follow up with a separate PR!
@localheinz much better :-) |
07c5142
to
3ff7ac6
Compare
Glad you like it! |
Added tests for |
ed6c843
to
b4dd851
Compare
b4dd851
to
4309a1a
Compare
*/ | ||
public function currentUserModules() | ||
{ | ||
$repositories = $this->githubClient->api('current_user')->repos([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't current_user
hitting the modules.zendframework.com
user token's user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd assume, though, that this refers to the currently authenticated user, no?
Edit
See this:
modules.zendframework.com/module/Application/src/Application/Service/RepositoryRetriever.php
Lines 119 to 129 in 9bad766
/** | |
* Return all Repositories from current authenticated GitHub User | |
* | |
* @param array $params | |
* | |
* @return RepositoryCollection | |
*/ | |
public function getAuthenticatedUserRepositories($params = []) | |
{ | |
return $this->githubClient->api('current_user')->repos($params); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and that is very weird: the service keeps a reference to the user in the auth service? (you see where I'm going with this...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jep current_user
will request the user repositorys from the current linked github account of a user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->someService->getUserRepos();
would still need the $user
;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ocramius
one more try 😃
$userRepoInDb = $this->someService->getUserRepos($this->identity());
foreach($userRepoInDb as $repository){
$repoData = $this->repositoryRetreiver->getRepositoryMetaData($identity->getUsername(), $repository->getName());
// do stuff check for etc?
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for your explanation @Ocramius
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
496548d
to
59648ce
Compare
👍 looks good! |
Fix: Move plugin functionality into appropriate service
@localheinz merged, thanks! |
This PR
ZfModule\Mvc\Controller\Plugin\ListModule
controller plugin intoZfModule\Service\Module
as this seems to be the appropriate service (same dependencies as the plugin)User\Controller\UserController
and injects the the aforementioned servicezfcuser
controller so we can actually use a factoryService\Module::listModule()
so we can move on and refactorService\Module::listAllModules()
andService\Module::listUserModules()
fromService\Module::listModule()
, removes the latterFollows #362, especially #362 (comment).
💡 Not sure about renaming methods, but to be honest, I have recently gotten tired of all of this
getFoo()
andsetBar()
stuff, does it make sense?