Problem/Motivation

hook_icon_pack_alter() is entirely undocumented.

Steps to reproduce

-

Proposed resolution

Document it!

Remaining tasks

User interface changes

-

Introduced terminology

-

API changes

-

Data model changes

-

Release notes snippet

Issue fork drupal-3572051

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tstoeckler created an issue. See original summary.

kanchanandhini6’s picture

Hello,
I would like to work on this issue as a first-time contributor.
Please let me know if I can proceed.
Thank you.

tstoeckler’s picture

Hey @kanchanandhini6 that's awesome, sure thing! Feel free to assign the issue to yourself.

Some pointers that hopefully help:

  • Since the Icon API is not part of a module, but part of the core theming system, the hook should be documented in the core.api.php file
  • You can find a few plugin definition alter hooks in there, to model your hook after. hook_validation_constraint_alter() for example. Even though it's a completely different part of core, the hook documentation should look somewhat similar.
  • I don't think this is a hard requirement, so if you're stuck on this just go ahead and push the code without this, but ideally it would be nice to use this hook to document the structure of the icon pack definition array because that does not exist anywhere as far as I can tell. For that you can check out navigation.icons.yml, to see which keys are available. As a reference for how such an array can be documented, take a look at \Drupal\Core\Asset\LibraryDiscoveryParser::parseLibraryInfo(). But again, feel free to ignore this point for now if it's a bit too much or bit too confusing.

Let me know if there's anything else that's unclear or if you need help with the contribution workflow in general.

kanchanandhini6’s picture

Assigned: Unassigned » kanchanandhini6
kanchanandhini6’s picture

I’ve added documentation for hook_icon_pack_alter() in core/core.api.php and pushed the changes to my issue branch (icon-pack-alter-doc).
Please review and let me know if any changes are needed.
Thanks!

tstoeckler’s picture

I don't see any issue branch (or an issue fork where that branch would live, for that matter). Can you point me to where you pushed the code?

kanchanandhini6’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work

I don't see anywhere in core icon_pack_alter is called? And @see core/modules/navigation/navigation.icons.yml not sure how that relates to alter. Sorry putting back into NW.

tstoeckler’s picture

Title: icon_pack_alter() is undocumented » hook_icon_pack_alter() is undocumented

Re #9: See \Drupal\Core\Theme\Icon\Plugin\IconPackManager::__construct(). Through the use of $this->alterInfo() hook_icon_pack_alter() will be called during plugin discovery automatically. Yeah, the @see is a bit unfortunate without further explanation, I agree, so I'd vote to remove that as well, for now.

Will do a detailed code review now.

tstoeckler’s picture

kanchanandhini6’s picture

Status: Needs work » Needs review
tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Awesome, thanks for the quick follow-up @kanchanandhini6! Looks perfect now and PHPCS is happy as well. I think it's good to go.

nicxvan’s picture

Should this be in theme.api.php?

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work

Good question @nicxvan. I totally didn't know theme.api.php exists. I took a look whether that only contains hooks that are actually invoked in themes vs. just being generally theme related, but that's not the case. For example hook_library_info_build() is documented there, which is only for modules. hook_icon_pack_alter() seems similar enough in that it's theme or rendering related. So I would say, yes, let's move it to theme.api.php (that's in core/lib/Drupal/Core/Render, regardless of the outcome of #3572674: Allow themes to call hook_icon_pack_alter().

Marking needs work for that, are you up for moving the documentation over to the other file @kanchanandhini6?

kanchanandhini6’s picture

"I have moved the hook_icon_pack_alter() documentation from core.api.php to core/lib/Drupal/Core/Render/theme.api.php as suggested by @nicxvan and @tstoeckler.

Setting back to Needs review."

kanchanandhini6’s picture

Status: Needs work » Needs review
kanchanandhini6’s picture

"I have moved the hook_icon_pack_alter() documentation to core/lib/Drupal/Core/Render/theme.api.php as requested in comment #15.

I noticed some CI failures in the latest pipeline, but they appear to be environment-related ('Insufficient cpu') rather than issues with the code.

Setting back to Needs review."

tstoeckler’s picture

Status: Needs review » Needs work

@kanchanandhini6 thanks for the quick response, awesome!

One tiny thing: in theme.api.php the new hook is now outside of the "hook" documentation group, so if you could move it up to be inside of that, that would be perfect.

kanchanandhini6’s picture

Status: Needs work » Needs review
tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Awesome, thanks, looks great!

  • alexpott committed 81400d48 on 11.3.x
    docs: #3572051 hook_icon_pack_alter() is undocumented
    
    By: tstoeckler
    By...

  • alexpott committed 3b859e06 on 11.x
    docs: #3572051 hook_icon_pack_alter() is undocumented
    
    By: tstoeckler
    By...

  • alexpott committed 65b0772b on main
    docs: #3572051 hook_icon_pack_alter() is undocumented
    
    By: tstoeckler
    By...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 65b0772 and pushed to main. Thanks!
Committed 3b859e0 and pushed to 11.x. Thanks!
Committed 81400d4 and pushed to 11.3.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.