-
Notifications
You must be signed in to change notification settings - Fork 282
/
Copy pathCardDescriptionActivity.php
52 lines (43 loc) · 1.25 KB
/
CardDescriptionActivity.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Deck\Cron;
use OCA\Deck\Activity\ActivityManager;
use OCA\Deck\Db\CardMapper;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\Job;
class CardDescriptionActivity extends Job {
/** @var ActivityManager */
private $activityManager;
/** @var CardMapper */
private $cardMapper;
public function __construct(ITimeFactory $time, ActivityManager $activityManager, CardMapper $cardMapper) {
parent::__construct($time);
$this->activityManager = $activityManager;
$this->cardMapper = $cardMapper;
}
/**
* @param $argument
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function run($argument) {
$cards = $this->cardMapper->findUnexposedDescriptionChances();
foreach ($cards as $card) {
$this->activityManager->triggerEvent(
ActivityManager::DECK_OBJECT_CARD,
$card,
ActivityManager::SUBJECT_CARD_UPDATE_DESCRIPTION,
[
'before' => $card->getDescriptionPrev(),
'after' => $card->getDescription()
],
$card->getLastEditor()
);
$card->setDescriptionPrev(null);
$card->setLastEditor(null);
$this->cardMapper->update($card, false);
}
}
}