Problem/Motivation

When we add label() functionality to the activity plugin type we need to use that logic in Activity::label() function.

Proposed resolution

- Rely on label() on the activity type plugin to display a label. Base plugin implementation will return contents of the activity title, which is exactly the same as what we have at the moment.
- Add test coverage

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

slashrsm created an issue. See original summary.

CTaPByK’s picture

Assigned: Unassigned » CTaPByK
Status: Active » Needs review
FileSize
2.96 KB

Initial patch.

thenchev’s picture

Status: Needs review » Reviewed & tested by the community

Looks ok to me.

slashrsm’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/modules/crm_core_activity/src/Entity/Activity.php
    @@ -214,4 +214,16 @@ class Activity extends RevisionableContentEntityBase implements ActivityInterfac
    +    /** @var \Drupal\crm_core_activity\ActivityTypeInterface $activity_type */
    +    $activity_type = $this->entityTypeManager()
    +      ->getStorage('crm_core_activity_type')
    +      ->load($this->bundle());
    +
    +    return $activity_type->getPlugin()->label($this);
    

    No need to load the activity type. Field/Entity can do it for you.

  2. +++ b/modules/crm_core_activity/tests/src/Kernel/ActivityTypePluginTest.php
    @@ -53,6 +53,21 @@ class ActivityTypePluginTest extends KernelTestBase {
    +    $activity_type->save();
    

    You can assign a plugin in as part of the create().

CTaPByK’s picture

Status: Needs work » Needs review
FileSize
1.48 KB
2.7 KB

Fix points from #4

slashrsm’s picture

Status: Needs review » Fixed

Committed.

  • slashrsm committed 9e84ca1 on 8.x-1.x authored by CTaPByK
    Issue #2714271 by CTaPByK, slashrsm, Denchev: Update Activity::label()...

  • slashrsm committed 9e84ca1 on 8.x-2.x authored by CTaPByK
    Issue #2714271 by CTaPByK, slashrsm, Denchev: Update Activity::label()...

Status: Fixed » Closed (fixed)

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