Problem/Motivation

Activity type plugins will provide business logic to the activity entities.

Proposed resolution

- create plugin manager service
- create ActivityTypePluginInterface and add two functions to it
- create abstract base plugin class that provides default implementations for both fucntions (label displays the contents of the label field on the activity entity and display returns an empty render array for now)
- create "Generic" plugin that extends base class and basically reuses it's logic for now
- expose plugin type so Plugin module will be able to discover it (see http://cgit.drupalcode.org/plugin/tree/PLUGIN_TYPES.md)
- add test coverage

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

slashrsm created an issue. See original summary.

thenchev’s picture

Assigned: Unassigned » thenchev
thenchev’s picture

Status: Active » Needs review
FileSize
8.56 KB

Initial patch. Integration with Plugin module is optional so are we creating some tests for that? Asserting that there is admin/structure/plugin/ActivityTypePlugin

thenchev’s picture

Not quite sure what to add to the schema.

slashrsm’s picture

Status: Needs review » Needs work
  1. +++ b/modules/crm_core_activity/config/schema/crm_core_activity.schema.yml
    @@ -16,3 +16,5 @@ crm_core_activity.type.*:
    +
    +plugin.plugin_configuration.ActivityTypePlugin.*:
    

    We actually don't need any schema here for now. Plugin configuration array will be part of the activity bundle and each plugin will need to provide its own schema for it.

  2. +++ b/modules/crm_core_activity/crm_core_activity.plugin_type.yml
    @@ -0,0 +1,5 @@
    +ActivityTypePlugin:
    +  label: ActivityType plugin
    +  description: Plugin for the activity type.
    

    Use snake case. Put label and description strings in quotes. Label should be something like "Activity type"

  3. +++ b/modules/crm_core_activity/src/ActivityTypePluginInterface.php
    @@ -0,0 +1,27 @@
    +namespace Drupal\crm_core_activity;
    +use Drupal\crm_core_activity\Entity\Activity;
    

    Newline.

  4. +++ b/modules/crm_core_activity/src/ActivityTypePluginInterface.php
    @@ -0,0 +1,27 @@
    +   *   The activity entity to get the label from.
    

    ".. to get the label for." or even "...to build the label for."

  5. +++ b/modules/crm_core_activity/src/ActivityTypePluginInterface.php
    @@ -0,0 +1,27 @@
    +  public function label(Activity $entity);
    

    Typehint ActivityInterface.

  6. +++ b/modules/crm_core_activity/src/ActivityTypePluginInterface.php
    @@ -0,0 +1,27 @@
    +  /**
    +   * Returns display.
    +   */
    

    add @return. Will need activity entity too.

thenchev’s picture

Status: Needs work » Needs review
FileSize
8.37 KB
4.32 KB

  • slashrsm committed 51b6f66 on 8.x-1.x authored by Denchev
    Issue #2714233 by Denchev, slashrsm: Create "Activity type" plugin type
    
slashrsm’s picture

Status: Needs review » Fixed

Committed. Thanks!

Status: Fixed » Closed (fixed)

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