Problem/Motivation

The current Slick skins are implemented using the old hook_hook_info which will be deprecated anytime: #2233261: Deprecate hook_hook_info groups, mark hook_hook_info() for deletion

Quoted from SlickSkinInterface, dated back to 1/16/16 here:

* The hook_hook_info() is deprecated, and no resolution by 1/16/16:
 *   #2233261: Deprecate hook_hook_info()
 *     Postponed till D9

I could not make it a plugin for few reasons at that time: lacking of plugin system knowledge, lacking of time, and was hesitant to make use of plugins as obviously it will add more classes.

Proposed resolution

Use the plugin system, deprecate old hook, and remove it at slick:8.x-3.0 or slick:9.x-1.0 at the latest.
Old skins such as y/ours or Slick Example should still work for BC during depreciation till finally removed.

If any issue with the new feature, you can always revert to the stable branch 8.x-2.0, at least this branch has 0 bug report as of this writing. It was fully released to avoid lengthy development with more features, and can be used as a restore point if any issue is discovered with this new feature. Aside from the fact that hook_hook_info() is not officially deprecated, just yet.

During transition, a new option is provided which can be toggled at Slick UI:

  • Disable deprecated skins

Depending on your needs. Leave it unchecked if things are broken, or (y/our) sub-modules are not updated with the new plugin system, yet. If you are sure things are not broken, or never register a skin nor using Slick examples, you can check this to reduce extra join. At any rate, skins are permanently cached once, so should not impact much.

Remaining tasks

Create a patch. Review. Tests.

This can be done anytime, no rushes.

User interface changes

None.

API changes

Yes, should be updated after commit:
https://git.drupalcode.org/project/slick/blob/8.x-2.x/slick.api.php#L341

slick:7.x-3.0 - 8.x-2.0 (Before) slick:8.x-2.1+ (After)
To register a skin:
  • implement hook_slick_skins_info() in a module file,
  • and defines skins at the registered class which implements SlickSkinInterface.

The class must implement \Drupal\slick\SlickSkinInterface, and it has 3 supported methods: ::skins(), ::dots(), ::arrows() to have skin options for main/thumbnail/overlay/nested displays, dots, and arrows skins respectively.

To register a skin:
  • copy \Drupal\slick\Plugin\slick\SlickSkin into your module /src/Plugin/slick directory.
  • Adjust everything accordingly: rename the file, change SlickSkin ID and label, change class name and its namespace, define skin name, and its CSS and JS assets.

The SlickSkin object has 3 supported methods: ::setSkins(), ::setDots(), ::setArrows() to have skin options for main/thumbnail/overlay displays, dots, and arrows skins respectively.

The method bodies (the array structure of skin definitions) are similar to previous ones, no changes.

Change records:
https://www.drupal.org/node/3105648

Data model changes

(Database or configuration data changes that would make stored data on an existing site incompatible with the site's updated codebase, including changes to hook_schema(), configuration schema or keys, or the expected format of stored data, etc.)
None.

Release notes snippet

(Major and critical issues should have a snippet that can be pulled into the release notes when a release is created that includes the fix)
Might be Major, but none of this change is critical, BC should be maintained.

Comments

gausarts created an issue. See original summary.

gausarts’s picture

Issue summary: View changes
gausarts’s picture

Status: Active » Needs review
StatusFileSize
new6.34 KB

Anytime has come. As I didn't test it locally, I would be very much assisted with some failures.

The following new files are added:

  1. src/Annotation/SlickSkin.php
  2. src/Plugin/slick/SlickSkin.php
  3. src/SlickSkinManager.php
  4. src/SlickSkinManagerInterface.php
  5. src/SlickSkinPluginBase.php
  6. src/SlickSkinPluginInterface.php

Also updated slick.api.php, and few more related files.
The relevant depreciation notices are provided.

I will get back to this tomorrow or so regardless test results. Reviews are very much welcome. Thanks!

gausarts’s picture

StatusFileSize
new46.26 KB

Wrong file, sorry.

gausarts’s picture

StatusFileSize
new47.31 KB

Fixed for coding standards.

gausarts’s picture

Issue summary: View changes
gausarts’s picture

Issue summary: View changes
gausarts’s picture

Issue summary: View changes
gausarts’s picture

Issue summary: View changes
gausarts’s picture

Issue summary: View changes
gausarts’s picture

StatusFileSize
new47.83 KB

Added hook_update to clear skins cache.

gausarts’s picture

Issue summary: View changes

  • gausarts committed 5405f78 on 8.x-2.x
    Issue #3105670 by gausarts: hook_hook_info is to be deprecated, consider...
gausarts’s picture

Status: Needs review » Fixed

Committed for wider feedback. Any improvement is very much welcome, and correction may follow as always. Thanks!

Status: Fixed » Closed (fixed)

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