Conditions | 2 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 2.0078 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | 384 | public static function deleteLikes(\Elgg\Event $event) { |
|
23 | |||
24 | 384 | $entity = $event->getObject(); |
|
25 | 384 | if (!$entity instanceof \ElggEntity) { |
|
26 | return; |
||
27 | } |
||
28 | |||
29 | // Let's do a bulk delete of all likes annotations, instead of for each individually |
||
30 | // this will save performance |
||
31 | 384 | $delete = DbDelete::fromTable('annotations'); |
|
32 | 384 | $delete->where($delete->compare('entity_guid', '=', $entity->guid, ELGG_VALUE_GUID)) |
|
33 | 384 | ->andWhere($delete->compare('name', '=', 'likes', ELGG_VALUE_STRING)); |
|
34 | |||
35 | 384 | elgg()->db->deleteData($delete); |
|
36 | 384 | } |
|
38 |