The Slack module defines one plugin type identified by its annotation "@SlackApi"
Convention in Drupal core is that the plugin manager for this plugin type be named SlackApiManager
and have a service name of plugin.manager.slack_api
. Note the underscore in the service name serves as a word separator, whereas in the annotation name @SlackApi
we use camel case to delimit words. Although services should have an associated interface so they can be overridden, plugin manager services already DO have an associated interface - \Drupal\Component\Plugin\PluginManagerInterface
. Because of this, there is no need to define an additional interface.
In the current 2.0.x branch, this plugin manager service is not named as expected and an empty (and useless and unneeded) interface is defined for the plugin manager service class. Using the expected naming convention makes the code easier to read and understand - identifying these classes properly serves as documentation, while identifying them incorrectly just confuses.
This patch makes changes in the following files to rename the service and remove the extraneous interface:
modified: slack.services.yml
deleted: src/Core/SlackApi/SlackApiManagerInterface.php
Likewise, plugin types usually define a base class to hold common functionality for plugins of that type. In this case we would expect a base class named SlackApiPluginBase
. Additionally, plugin types usually define an interface to specify the required methods found in any implementation of the plugin type. In this case we would expect SlackApiPluginInterface
.
In the current 2.0.x branch, these classes are not named as expected, so this patch makes the following changes:
renamed: src/Core/SlackApi/SlackApiBase.php -> src/Core/SlackApi/SlackApiPluginBase.php
renamed: src/Core/SlackApi/SlackApiBaseInterface.php -> src/Core/SlackApi/SlackApiPluginInterface.php
There are four submodules that provide @SlackApi
plugins - they all have their own base classes which should also follow this pattern, so this patch also makes these changes:
renamed: modules/slack_chatapi/src/Core/ChatApi/ChatApiBase.php -> modules/slack_chatapi/src/Core/ChatApi/ChatApiPluginBase.php
renamed: modules/slack_conversationsapi/src/Core/ConversationsApi/ConversationsApiBase.php -> modules/slack_conversationsapi/src/Core/ConversationsApi/ConversationsApiPluginBase.php
renamed: modules/slack_userapi/src/Core/UserApi/UserApiBase.php -> modules/slack_userapi/src/Core/UserApi/UserApiPluginBase.php
renamed: modules/slack_webapi/src/Core/WebApi/WebApiBase.php -> modules/slack_webapi/src/Core/WebApi/WebApiPluginBase.php
One other change is made: This module defines an empty base class for a second plugin type, but that plugin type remains undefined (no annotation class, no service definition, etc.). Because this base class is empty and unused, it makes sense (to me) to get rid of it as
part of this plugin architecture clean-up issue.
deleted: src/Core/EventsApi/EventsApiBase.php
All other modified files in this patch are to correct "use" statements, documentation, and other references to the old class names.