|
1 | 1 | <?php |
2 | 2 |
|
| 3 | +declare(strict_types=1); |
| 4 | + |
3 | 5 | /** |
4 | 6 | * Nextcloud - maps |
5 | 7 | * |
|
9 | 11 | * @author Julien Veyssier |
10 | 12 | * @copyright Julien Veyssier 2019 |
11 | 13 | */ |
12 | | - |
13 | 14 | namespace OCA\Maps\BackgroundJob; |
14 | 15 |
|
15 | 16 | use OCA\Maps\Service\PhotofilesService; |
16 | 17 | use OCA\Maps\Service\TracksService; |
17 | 18 | use OCP\AppFramework\Utility\ITimeFactory; |
18 | 19 | use OCP\BackgroundJob\IJobList; |
19 | 20 | use OCP\BackgroundJob\QueuedJob; |
20 | | - |
21 | 21 | use OCP\IConfig; |
| 22 | + |
22 | 23 | use OCP\IUserManager; |
| 24 | +use OCP\Server; |
23 | 25 | use Psr\Log\LoggerInterface; |
24 | 26 |
|
25 | 27 | class UserInstallScanJob extends QueuedJob { |
26 | 28 |
|
27 | | - private IJobList $jobList; |
28 | | - private IConfig $config; |
29 | | - private IUserManager $userManager; |
30 | | - private PhotofilesService $photofilesService; |
31 | | - private TracksService $tracksService; |
| 29 | + private readonly IConfig $config; |
| 30 | + |
32 | 31 |
|
33 | 32 | /** |
34 | 33 | * UserInstallScanJob constructor. |
35 | 34 | * |
36 | 35 | * A QueuedJob to scan user storage for photos and tracks |
37 | | - * |
38 | | - * @param IJobList $jobList |
39 | 36 | */ |
40 | | - public function __construct(ITimeFactory $timeFactory, IJobList $jobList, |
| 37 | + public function __construct( |
| 38 | + ITimeFactory $timeFactory, |
| 39 | + IJobList $jobList, |
41 | 40 | IUserManager $userManager, |
42 | 41 | IConfig $config, |
43 | | - PhotofilesService $photofilesService, |
44 | | - TracksService $tracksService) { |
| 42 | + private readonly PhotofilesService $photofilesService, |
| 43 | + private readonly TracksService $tracksService, |
| 44 | + ) { |
45 | 45 | parent::__construct($timeFactory); |
46 | 46 | $this->config = $config; |
47 | | - $this->jobList = $jobList; |
48 | | - $this->userManager = $userManager; |
49 | | - $this->photofilesService = $photofilesService; |
50 | | - $this->tracksService = $tracksService; |
51 | 47 | } |
52 | 48 |
|
53 | | - public function run($argument) { |
| 49 | + public function run($argument): void { |
54 | 50 | $userId = $argument['userId']; |
55 | | - \OCP\Server::get(LoggerInterface::class)->debug('Launch user install scan job for ' . $userId . ' cronjob executed'); |
| 51 | + Server::get(LoggerInterface::class)->debug('Launch user install scan job for ' . $userId . ' cronjob executed'); |
56 | 52 | // scan photos and tracks for given user |
57 | 53 | $this->rescanUserPhotos($userId); |
58 | 54 | $this->rescanUserTracks($userId); |
59 | 55 | $this->config->setUserValue($userId, 'maps', 'installScanDone', 'yes'); |
60 | 56 | } |
61 | 57 |
|
62 | | - private function rescanUserPhotos($userId) { |
| 58 | + private function rescanUserPhotos($userId): void { |
63 | 59 | //$this->output->info('======== User '.$userId.' ========'."\n"); |
64 | 60 | $c = 1; |
65 | 61 | foreach ($this->photofilesService->rescan($userId) as $path) { |
66 | 62 | //$this->output->info('['.$c.'] Photo "'.$path.'" added'."\n"); |
67 | | - $c++; |
| 63 | + ++$c; |
68 | 64 | } |
69 | 65 | } |
70 | 66 |
|
71 | | - private function rescanUserTracks($userId) { |
| 67 | + private function rescanUserTracks($userId): void { |
72 | 68 | //$this->output->info('======== User '.$userId.' ========'."\n"); |
73 | 69 | $c = 1; |
74 | 70 | foreach ($this->tracksService->rescan($userId) as $path) { |
75 | 71 | //$this->output->info('['.$c.'] Track "'.$path.'" added'."\n"); |
76 | | - $c++; |
| 72 | + ++$c; |
77 | 73 | } |
78 | 74 | } |
79 | 75 |
|
|
0 commit comments