Commit 6282740d authored by RoSk0's avatar RoSk0

CRM systems should try to prevent data loss in all possible ways.

Core prevents bundle with content been deleted from UI. We shouldn't get
in way of programmatic data manipulation in any way.
parent 878136b1
......@@ -112,33 +112,6 @@ class IndividualType extends ConfigEntityBundleBase implements ContactTypeInterf
* {@inheritdoc}
* @todo This does not scale.
* Deleting a individual type with thousands of individual records associated
* will run into execution timeout.
public static function preDelete(EntityStorageInterface $storage, array $entities) {
parent::preDelete($storage, $entities);
$ids = array_map(function(EntityInterface $entity) {
return $entity->id();
}, $entities);
// Delete all instances of the given type.
$results = \Drupal::entityQuery('crm_core_individual')
->condition('type', $ids, 'IN')
if (!empty($results)) {
$individuals = Individual::loadMultiple($results);
\Drupal::logger('crm_core_individual')->info('Delete @count individual due to deletion of individual type.', ['@count' => count($results)]);
* {@inheritdoc}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment