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

Added invokeAll() method to defaultStyleguide::items() #24

Open
wants to merge 5 commits into
base: 8.x-1.x
Choose a base branch
from

Conversation

jamesquinton
Copy link

Hi - thanks for the work on a great and useful module!

I noticed that hook_styleguide_alter was not being invoked, which I need to be able to edit the items in the styleguide.

I may be on the wrong track here, but I have invoked the hook in defaultStyleguide:items().


/**
* @} End of "addtogroup hooks".
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add line break

@jamesquinton
Copy link
Author

Thanks for the comments Andy, I'm still getting to grips with D8 so much appreciated. I've implemented your suggestions in my latest commit.

@@ -759,8 +759,7 @@ public function items() {
);

// Invoke hook_styleguide_alter()
$items = \Drupal::service('module_handler')->invokeAll('styleguide_alter', array($items));
//$items->merge($new_items);
\Drupal::service('module_handler')->alter('styleguide', $items);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already added to the class as dependency injection. So better to use $this->moduleHandler

@jamesquinton
Copy link
Author

@Shdulin - good catch!

@Stolexiy
Copy link
Owner

Stolexiy commented May 5, 2016

Thanks for your work, James!
I have totally forgotten that we already have such alter https://github.com/Shdulin/styleguide/blob/8.x-1.x/src/StyleguidePluginManager.php#L25. Just need to rename it from "styleguide_info" to "styleguide" and update API docs.

@jamesquinton
Copy link
Author

Hi,

Thanks - I've updated alterInfo(), and it is invoking the hook. However, I can't work out how to pass the items through to hook_styleguide_alter(&$items).

Any idea's?

@andypost
Copy link
Contributor

andypost commented May 6, 2016

I suggest to use plugins to extend styleguide, alter only allows to change existing plugins defaults or swap plugin with own class

@jamesquinton
Copy link
Author

@andypost - in that case, should we even have hooks?

@andypost
Copy link
Contributor

andypost commented May 6, 2016

@jamesquinton that does not help because you needba plugin class to render something

@jamesquinton
Copy link
Author

Thanks @andypost - took me a while to make sense of this, but got it working now.

I have my own custom module, where I use hook_styleguide_alter to swap out the default plugin for my own, which is working very nicely!

@andypost
Copy link
Contributor

@jamesquinton that's great, could you update example in api definition to make that more clear how to use that?

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

Successfully merging this pull request may close these issues.

3 participants