Skip to content

Commit

Permalink
[Activities] Cleanup after customer is deleted - fixes #19
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-moser committed Oct 16, 2017
1 parent 5e2b084 commit aeb4818
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/ActivityStore/MariaDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ public function deleteEntry(ActivityStoreEntryInterface $entry)
*/
public function deleteCustomer(CustomerInterface $customer)
{
$db = Db::get();
$db->exec(
sprintf('delete from %s where customerId = %d', self::ACTIVITIES_TABLE, $customer->getId())
);
}

/**
Expand Down
7 changes: 7 additions & 0 deletions src/CustomerSaveManager/DefaultCustomerSaveManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace CustomerManagementFrameworkBundle\CustomerSaveManager;

use CustomerManagementFrameworkBundle\ActivityStore\ActivityStoreInterface;
use CustomerManagementFrameworkBundle\CustomerProvider\CustomerProviderInterface;
use CustomerManagementFrameworkBundle\CustomerSaveHandler\CustomerSaveHandlerInterface;
use CustomerManagementFrameworkBundle\CustomerSaveValidator\CustomerSaveValidatorInterface;
Expand Down Expand Up @@ -204,6 +205,12 @@ public function postDelete(CustomerInterface $customer)
*/
$duplicatesIndex = \Pimcore::getContainer()->get(DuplicatesIndexInterface::class);
$duplicatesIndex->deleteCustomerFromDuplicateIndex($customer);

/**
* @var ActivityStoreInterface $activityStore
*/
$activityStore = \Pimcore::getContainer()->get(ActivityStoreInterface::class);
$activityStore->deleteCustomer($customer);
}

public function validateOnSave(CustomerInterface $customer, $withDuplicatesCheck = true)
Expand Down
9 changes: 7 additions & 2 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,16 @@ services:
class: CustomerManagementFrameworkBundle\ActivityView\DefaultActivityView
arguments: ['@cmf.view_formatter']

cmf.activity_store:
CustomerManagementFrameworkBundle\ActivityStore\ActivityStoreInterface:
class: CustomerManagementFrameworkBundle\ActivityStore\MariaDb

cmf.activity_manager:
cmf.activity_store:
alias: CustomerManagementFrameworkBundle\ActivityStore\ActivityStoreInterface

CustomerManagementFrameworkBundle\ActivityStore\ActivityManagerInterface:
class: CustomerManagementFrameworkBundle\ActivityManager\DefaultActivityManager
cmf.activity_manager:
alias: CustomerManagementFrameworkBundle\ActivityStore\ActivityManagerInterface

cmf.activity_store_entry:
class: CustomerManagementFrameworkBundle\Model\ActivityStoreEntry\DefaultActivityStoreEntry
Expand Down

0 comments on commit aeb4818

Please sign in to comment.