@@ -30,30 +30,30 @@ |
||
30 | 30 | |
31 | 31 | class Server implements IIconSection { |
32 | 32 | |
33 | - /** @var IL10N */ |
|
34 | - private $l; |
|
33 | + /** @var IL10N */ |
|
34 | + private $l; |
|
35 | 35 | |
36 | - /** @var IURLGenerator */ |
|
37 | - private $urlGenerator; |
|
36 | + /** @var IURLGenerator */ |
|
37 | + private $urlGenerator; |
|
38 | 38 | |
39 | - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { |
|
40 | - $this->l = $l; |
|
41 | - $this->urlGenerator = $urlGenerator; |
|
42 | - } |
|
39 | + public function __construct(IL10N $l, IURLGenerator $urlGenerator) { |
|
40 | + $this->l = $l; |
|
41 | + $this->urlGenerator = $urlGenerator; |
|
42 | + } |
|
43 | 43 | |
44 | - public function getIcon(): string { |
|
45 | - return $this->urlGenerator->imagePath('core', 'actions/settings-dark.svg'); |
|
46 | - } |
|
44 | + public function getIcon(): string { |
|
45 | + return $this->urlGenerator->imagePath('core', 'actions/settings-dark.svg'); |
|
46 | + } |
|
47 | 47 | |
48 | - public function getID(): string { |
|
49 | - return 'server'; |
|
50 | - } |
|
48 | + public function getID(): string { |
|
49 | + return 'server'; |
|
50 | + } |
|
51 | 51 | |
52 | - public function getName(): string { |
|
53 | - return $this->l->t('Basic settings'); |
|
54 | - } |
|
52 | + public function getName(): string { |
|
53 | + return $this->l->t('Basic settings'); |
|
54 | + } |
|
55 | 55 | |
56 | - public function getPriority(): int { |
|
57 | - return 1; |
|
58 | - } |
|
56 | + public function getPriority(): int { |
|
57 | + return 1; |
|
58 | + } |
|
59 | 59 | } |
@@ -30,30 +30,30 @@ |
||
30 | 30 | |
31 | 31 | class Overview implements IIconSection { |
32 | 32 | |
33 | - /** @var IL10N */ |
|
34 | - private $l; |
|
33 | + /** @var IL10N */ |
|
34 | + private $l; |
|
35 | 35 | |
36 | - /** @var IURLGenerator */ |
|
37 | - private $urlGenerator; |
|
36 | + /** @var IURLGenerator */ |
|
37 | + private $urlGenerator; |
|
38 | 38 | |
39 | - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { |
|
40 | - $this->l = $l; |
|
41 | - $this->urlGenerator = $urlGenerator; |
|
42 | - } |
|
39 | + public function __construct(IL10N $l, IURLGenerator $urlGenerator) { |
|
40 | + $this->l = $l; |
|
41 | + $this->urlGenerator = $urlGenerator; |
|
42 | + } |
|
43 | 43 | |
44 | - public function getIcon(): string { |
|
45 | - return $this->urlGenerator->imagePath('settings', 'admin.svg'); |
|
46 | - } |
|
44 | + public function getIcon(): string { |
|
45 | + return $this->urlGenerator->imagePath('settings', 'admin.svg'); |
|
46 | + } |
|
47 | 47 | |
48 | - public function getID(): string { |
|
49 | - return 'overview'; |
|
50 | - } |
|
48 | + public function getID(): string { |
|
49 | + return 'overview'; |
|
50 | + } |
|
51 | 51 | |
52 | - public function getName(): string { |
|
53 | - return $this->l->t('Overview'); |
|
54 | - } |
|
52 | + public function getName(): string { |
|
53 | + return $this->l->t('Overview'); |
|
54 | + } |
|
55 | 55 | |
56 | - public function getPriority(): int { |
|
57 | - return 0; |
|
58 | - } |
|
56 | + public function getPriority(): int { |
|
57 | + return 0; |
|
58 | + } |
|
59 | 59 | } |
@@ -30,30 +30,30 @@ |
||
30 | 30 | |
31 | 31 | class SyncClients implements IIconSection { |
32 | 32 | |
33 | - /** @var IL10N */ |
|
34 | - private $l; |
|
33 | + /** @var IL10N */ |
|
34 | + private $l; |
|
35 | 35 | |
36 | - /** @var IURLGenerator */ |
|
37 | - private $urlGenerator; |
|
36 | + /** @var IURLGenerator */ |
|
37 | + private $urlGenerator; |
|
38 | 38 | |
39 | - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { |
|
40 | - $this->l = $l; |
|
41 | - $this->urlGenerator = $urlGenerator; |
|
42 | - } |
|
39 | + public function __construct(IL10N $l, IURLGenerator $urlGenerator) { |
|
40 | + $this->l = $l; |
|
41 | + $this->urlGenerator = $urlGenerator; |
|
42 | + } |
|
43 | 43 | |
44 | - public function getIcon() { |
|
45 | - return $this->urlGenerator->imagePath('core', 'clients/phone.svg'); |
|
46 | - } |
|
44 | + public function getIcon() { |
|
45 | + return $this->urlGenerator->imagePath('core', 'clients/phone.svg'); |
|
46 | + } |
|
47 | 47 | |
48 | - public function getID(): string { |
|
49 | - return 'sync-clients'; |
|
50 | - } |
|
48 | + public function getID(): string { |
|
49 | + return 'sync-clients'; |
|
50 | + } |
|
51 | 51 | |
52 | - public function getName(): string { |
|
53 | - return $this->l->t('Mobile & desktop'); |
|
54 | - } |
|
52 | + public function getName(): string { |
|
53 | + return $this->l->t('Mobile & desktop'); |
|
54 | + } |
|
55 | 55 | |
56 | - public function getPriority(): int { |
|
57 | - return 15; |
|
58 | - } |
|
56 | + public function getPriority(): int { |
|
57 | + return 15; |
|
58 | + } |
|
59 | 59 | } |
@@ -30,30 +30,30 @@ |
||
30 | 30 | |
31 | 31 | class Security implements IIconSection { |
32 | 32 | |
33 | - /** @var IL10N */ |
|
34 | - private $l; |
|
33 | + /** @var IL10N */ |
|
34 | + private $l; |
|
35 | 35 | |
36 | - /** @var IURLGenerator */ |
|
37 | - private $urlGenerator; |
|
36 | + /** @var IURLGenerator */ |
|
37 | + private $urlGenerator; |
|
38 | 38 | |
39 | - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { |
|
40 | - $this->l = $l; |
|
41 | - $this->urlGenerator = $urlGenerator; |
|
42 | - } |
|
39 | + public function __construct(IL10N $l, IURLGenerator $urlGenerator) { |
|
40 | + $this->l = $l; |
|
41 | + $this->urlGenerator = $urlGenerator; |
|
42 | + } |
|
43 | 43 | |
44 | - public function getIcon() { |
|
45 | - return $this->urlGenerator->imagePath('settings', 'password.svg'); |
|
46 | - } |
|
44 | + public function getIcon() { |
|
45 | + return $this->urlGenerator->imagePath('settings', 'password.svg'); |
|
46 | + } |
|
47 | 47 | |
48 | - public function getID(): string { |
|
49 | - return 'security'; |
|
50 | - } |
|
48 | + public function getID(): string { |
|
49 | + return 'security'; |
|
50 | + } |
|
51 | 51 | |
52 | - public function getName(): string { |
|
53 | - return $this->l->t('Security'); |
|
54 | - } |
|
52 | + public function getName(): string { |
|
53 | + return $this->l->t('Security'); |
|
54 | + } |
|
55 | 55 | |
56 | - public function getPriority(): int { |
|
57 | - return 5; |
|
58 | - } |
|
56 | + public function getPriority(): int { |
|
57 | + return 5; |
|
58 | + } |
|
59 | 59 | } |
@@ -30,30 +30,30 @@ |
||
30 | 30 | |
31 | 31 | class PersonalInfo implements IIconSection { |
32 | 32 | |
33 | - /** @var IL10N */ |
|
34 | - private $l; |
|
33 | + /** @var IL10N */ |
|
34 | + private $l; |
|
35 | 35 | |
36 | - /** @var IURLGenerator */ |
|
37 | - private $urlGenerator; |
|
36 | + /** @var IURLGenerator */ |
|
37 | + private $urlGenerator; |
|
38 | 38 | |
39 | - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { |
|
40 | - $this->l = $l; |
|
41 | - $this->urlGenerator = $urlGenerator; |
|
42 | - } |
|
39 | + public function __construct(IL10N $l, IURLGenerator $urlGenerator) { |
|
40 | + $this->l = $l; |
|
41 | + $this->urlGenerator = $urlGenerator; |
|
42 | + } |
|
43 | 43 | |
44 | - public function getIcon() { |
|
45 | - return $this->urlGenerator->imagePath('core', 'actions/user.svg'); |
|
46 | - } |
|
44 | + public function getIcon() { |
|
45 | + return $this->urlGenerator->imagePath('core', 'actions/user.svg'); |
|
46 | + } |
|
47 | 47 | |
48 | - public function getID(): string { |
|
49 | - return 'personal-info'; |
|
50 | - } |
|
48 | + public function getID(): string { |
|
49 | + return 'personal-info'; |
|
50 | + } |
|
51 | 51 | |
52 | - public function getName(): string { |
|
53 | - return $this->l->t('Personal info'); |
|
54 | - } |
|
52 | + public function getName(): string { |
|
53 | + return $this->l->t('Personal info'); |
|
54 | + } |
|
55 | 55 | |
56 | - public function getPriority(): int { |
|
57 | - return 0; |
|
58 | - } |
|
56 | + public function getPriority(): int { |
|
57 | + return 0; |
|
58 | + } |
|
59 | 59 | } |
@@ -106,12 +106,12 @@ |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | return [ |
109 | - 'providers' => array_map(function (IProvidesPersonalSettings $provider) use ($user) { |
|
109 | + 'providers' => array_map(function(IProvidesPersonalSettings $provider) use ($user) { |
|
110 | 110 | return [ |
111 | 111 | 'provider' => $provider, |
112 | 112 | 'settings' => $provider->getPersonalSettings($user) |
113 | 113 | ]; |
114 | - }, array_filter($this->providerLoader->getProviders($user), function (IProvider $provider) { |
|
114 | + }, array_filter($this->providerLoader->getProviders($user), function(IProvider $provider) { |
|
115 | 115 | return $provider instanceof IProvidesPersonalSettings; |
116 | 116 | })) |
117 | 117 | ]; |
@@ -42,95 +42,95 @@ |
||
42 | 42 | |
43 | 43 | class TwoFactor implements ISettings { |
44 | 44 | |
45 | - /** @var ProviderLoader */ |
|
46 | - private $providerLoader; |
|
47 | - |
|
48 | - /** @var MandatoryTwoFactor */ |
|
49 | - private $mandatoryTwoFactor; |
|
50 | - |
|
51 | - /** @var IUserSession */ |
|
52 | - private $userSession; |
|
53 | - |
|
54 | - /** @var string|null */ |
|
55 | - private $uid; |
|
56 | - |
|
57 | - /** @var IConfig */ |
|
58 | - private $config; |
|
59 | - |
|
60 | - public function __construct(ProviderLoader $providerLoader, |
|
61 | - MandatoryTwoFactor $mandatoryTwoFactor, |
|
62 | - IUserSession $userSession, |
|
63 | - IConfig $config, |
|
64 | - ?string $UserId) { |
|
65 | - $this->providerLoader = $providerLoader; |
|
66 | - $this->mandatoryTwoFactor = $mandatoryTwoFactor; |
|
67 | - $this->userSession = $userSession; |
|
68 | - $this->uid = $UserId; |
|
69 | - $this->config = $config; |
|
70 | - } |
|
71 | - |
|
72 | - public function getForm(): TemplateResponse { |
|
73 | - return new TemplateResponse('settings', 'settings/personal/security/twofactor', [ |
|
74 | - 'twoFactorProviderData' => $this->getTwoFactorProviderData(), |
|
75 | - ]); |
|
76 | - } |
|
77 | - |
|
78 | - public function getSection(): ?string { |
|
79 | - if (!$this->shouldShow()) { |
|
80 | - return null; |
|
81 | - } |
|
82 | - return 'security'; |
|
83 | - } |
|
84 | - |
|
85 | - public function getPriority(): int { |
|
86 | - return 15; |
|
87 | - } |
|
88 | - |
|
89 | - private function shouldShow(): bool { |
|
90 | - $user = $this->userSession->getUser(); |
|
91 | - if (is_null($user)) { |
|
92 | - // Actually impossible, but still … |
|
93 | - return false; |
|
94 | - } |
|
95 | - |
|
96 | - // Anyone who's supposed to use 2FA should see 2FA settings |
|
97 | - if ($this->mandatoryTwoFactor->isEnforcedFor($user)) { |
|
98 | - return true; |
|
99 | - } |
|
100 | - |
|
101 | - // If there is at least one provider with personal settings but it's not |
|
102 | - // the backup codes provider, then these settings should show. |
|
103 | - try { |
|
104 | - $providers = $this->providerLoader->getProviders($user); |
|
105 | - } catch (Exception $e) { |
|
106 | - // Let's hope for the best |
|
107 | - return true; |
|
108 | - } |
|
109 | - foreach ($providers as $provider) { |
|
110 | - if ($provider instanceof IProvidesPersonalSettings |
|
111 | - && !($provider instanceof BackupCodesProvider)) { |
|
112 | - return true; |
|
113 | - } |
|
114 | - } |
|
115 | - return false; |
|
116 | - } |
|
117 | - |
|
118 | - private function getTwoFactorProviderData(): array { |
|
119 | - $user = $this->userSession->getUser(); |
|
120 | - if (is_null($user)) { |
|
121 | - // Actually impossible, but still … |
|
122 | - return []; |
|
123 | - } |
|
124 | - |
|
125 | - return [ |
|
126 | - 'providers' => array_map(function (IProvidesPersonalSettings $provider) use ($user) { |
|
127 | - return [ |
|
128 | - 'provider' => $provider, |
|
129 | - 'settings' => $provider->getPersonalSettings($user) |
|
130 | - ]; |
|
131 | - }, array_filter($this->providerLoader->getProviders($user), function (IProvider $provider) { |
|
132 | - return $provider instanceof IProvidesPersonalSettings; |
|
133 | - })) |
|
134 | - ]; |
|
135 | - } |
|
45 | + /** @var ProviderLoader */ |
|
46 | + private $providerLoader; |
|
47 | + |
|
48 | + /** @var MandatoryTwoFactor */ |
|
49 | + private $mandatoryTwoFactor; |
|
50 | + |
|
51 | + /** @var IUserSession */ |
|
52 | + private $userSession; |
|
53 | + |
|
54 | + /** @var string|null */ |
|
55 | + private $uid; |
|
56 | + |
|
57 | + /** @var IConfig */ |
|
58 | + private $config; |
|
59 | + |
|
60 | + public function __construct(ProviderLoader $providerLoader, |
|
61 | + MandatoryTwoFactor $mandatoryTwoFactor, |
|
62 | + IUserSession $userSession, |
|
63 | + IConfig $config, |
|
64 | + ?string $UserId) { |
|
65 | + $this->providerLoader = $providerLoader; |
|
66 | + $this->mandatoryTwoFactor = $mandatoryTwoFactor; |
|
67 | + $this->userSession = $userSession; |
|
68 | + $this->uid = $UserId; |
|
69 | + $this->config = $config; |
|
70 | + } |
|
71 | + |
|
72 | + public function getForm(): TemplateResponse { |
|
73 | + return new TemplateResponse('settings', 'settings/personal/security/twofactor', [ |
|
74 | + 'twoFactorProviderData' => $this->getTwoFactorProviderData(), |
|
75 | + ]); |
|
76 | + } |
|
77 | + |
|
78 | + public function getSection(): ?string { |
|
79 | + if (!$this->shouldShow()) { |
|
80 | + return null; |
|
81 | + } |
|
82 | + return 'security'; |
|
83 | + } |
|
84 | + |
|
85 | + public function getPriority(): int { |
|
86 | + return 15; |
|
87 | + } |
|
88 | + |
|
89 | + private function shouldShow(): bool { |
|
90 | + $user = $this->userSession->getUser(); |
|
91 | + if (is_null($user)) { |
|
92 | + // Actually impossible, but still … |
|
93 | + return false; |
|
94 | + } |
|
95 | + |
|
96 | + // Anyone who's supposed to use 2FA should see 2FA settings |
|
97 | + if ($this->mandatoryTwoFactor->isEnforcedFor($user)) { |
|
98 | + return true; |
|
99 | + } |
|
100 | + |
|
101 | + // If there is at least one provider with personal settings but it's not |
|
102 | + // the backup codes provider, then these settings should show. |
|
103 | + try { |
|
104 | + $providers = $this->providerLoader->getProviders($user); |
|
105 | + } catch (Exception $e) { |
|
106 | + // Let's hope for the best |
|
107 | + return true; |
|
108 | + } |
|
109 | + foreach ($providers as $provider) { |
|
110 | + if ($provider instanceof IProvidesPersonalSettings |
|
111 | + && !($provider instanceof BackupCodesProvider)) { |
|
112 | + return true; |
|
113 | + } |
|
114 | + } |
|
115 | + return false; |
|
116 | + } |
|
117 | + |
|
118 | + private function getTwoFactorProviderData(): array { |
|
119 | + $user = $this->userSession->getUser(); |
|
120 | + if (is_null($user)) { |
|
121 | + // Actually impossible, but still … |
|
122 | + return []; |
|
123 | + } |
|
124 | + |
|
125 | + return [ |
|
126 | + 'providers' => array_map(function (IProvidesPersonalSettings $provider) use ($user) { |
|
127 | + return [ |
|
128 | + 'provider' => $provider, |
|
129 | + 'settings' => $provider->getPersonalSettings($user) |
|
130 | + ]; |
|
131 | + }, array_filter($this->providerLoader->getProviders($user), function (IProvider $provider) { |
|
132 | + return $provider instanceof IProvidesPersonalSettings; |
|
133 | + })) |
|
134 | + ]; |
|
135 | + } |
|
136 | 136 | } |
@@ -34,35 +34,35 @@ |
||
34 | 34 | |
35 | 35 | class Password implements ISettings { |
36 | 36 | |
37 | - /** @var IUserManager */ |
|
38 | - private $userManager; |
|
37 | + /** @var IUserManager */ |
|
38 | + private $userManager; |
|
39 | 39 | |
40 | - /** @var string|null */ |
|
41 | - private $uid; |
|
40 | + /** @var string|null */ |
|
41 | + private $uid; |
|
42 | 42 | |
43 | - public function __construct(IUserManager $userManager, |
|
44 | - ?string $UserId) { |
|
45 | - $this->userManager = $userManager; |
|
46 | - $this->uid = $UserId; |
|
47 | - } |
|
43 | + public function __construct(IUserManager $userManager, |
|
44 | + ?string $UserId) { |
|
45 | + $this->userManager = $userManager; |
|
46 | + $this->uid = $UserId; |
|
47 | + } |
|
48 | 48 | |
49 | - public function getForm(): TemplateResponse { |
|
50 | - $user = $this->userManager->get($this->uid); |
|
51 | - $passwordChangeSupported = false; |
|
52 | - if ($user !== null) { |
|
53 | - $passwordChangeSupported = $user->canChangePassword(); |
|
54 | - } |
|
49 | + public function getForm(): TemplateResponse { |
|
50 | + $user = $this->userManager->get($this->uid); |
|
51 | + $passwordChangeSupported = false; |
|
52 | + if ($user !== null) { |
|
53 | + $passwordChangeSupported = $user->canChangePassword(); |
|
54 | + } |
|
55 | 55 | |
56 | - return new TemplateResponse('settings', 'settings/personal/security/password', [ |
|
57 | - 'passwordChangeSupported' => $passwordChangeSupported, |
|
58 | - ]); |
|
59 | - } |
|
56 | + return new TemplateResponse('settings', 'settings/personal/security/password', [ |
|
57 | + 'passwordChangeSupported' => $passwordChangeSupported, |
|
58 | + ]); |
|
59 | + } |
|
60 | 60 | |
61 | - public function getSection(): string { |
|
62 | - return 'security'; |
|
63 | - } |
|
61 | + public function getSection(): string { |
|
62 | + return 'security'; |
|
63 | + } |
|
64 | 64 | |
65 | - public function getPriority(): int { |
|
66 | - return 10; |
|
67 | - } |
|
65 | + public function getPriority(): int { |
|
66 | + return 10; |
|
67 | + } |
|
68 | 68 | } |
@@ -57,17 +57,17 @@ |
||
57 | 57 | |
58 | 58 | try { |
59 | 59 | $jobStartTime = time(); |
60 | - $logger->debug('Run ' . get_class($this) . ' job with ID ' . $this->getId(), ['app' => 'cron']); |
|
60 | + $logger->debug('Run '.get_class($this).' job with ID '.$this->getId(), ['app' => 'cron']); |
|
61 | 61 | $this->run($this->argument); |
62 | 62 | $timeTaken = time() - $jobStartTime; |
63 | 63 | |
64 | - $logger->debug('Finished ' . get_class($this) . ' job with ID ' . $this->getId() . ' in ' . $timeTaken . ' seconds', ['app' => 'cron']); |
|
64 | + $logger->debug('Finished '.get_class($this).' job with ID '.$this->getId().' in '.$timeTaken.' seconds', ['app' => 'cron']); |
|
65 | 65 | $jobList->setExecutionTime($this, $timeTaken); |
66 | 66 | } catch (\Throwable $e) { |
67 | 67 | if ($logger) { |
68 | 68 | $logger->logException($e, [ |
69 | 69 | 'app' => 'core', |
70 | - 'message' => 'Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')' |
|
70 | + 'message' => 'Error while running background job (class: '.get_class($this).', arguments: '.print_r($this->argument, true).')' |
|
71 | 71 | ]); |
72 | 72 | } |
73 | 73 | } |
@@ -33,66 +33,66 @@ |
||
33 | 33 | * @deprecated internal class, use \OCP\BackgroundJob\Job |
34 | 34 | */ |
35 | 35 | abstract class Job implements IJob { |
36 | - /** @var int */ |
|
37 | - protected $id; |
|
36 | + /** @var int */ |
|
37 | + protected $id; |
|
38 | 38 | |
39 | - /** @var int */ |
|
40 | - protected $lastRun; |
|
39 | + /** @var int */ |
|
40 | + protected $lastRun; |
|
41 | 41 | |
42 | - /** @var mixed */ |
|
43 | - protected $argument; |
|
42 | + /** @var mixed */ |
|
43 | + protected $argument; |
|
44 | 44 | |
45 | - public function execute(IJobList $jobList, ILogger $logger = null) { |
|
46 | - $jobList->setLastRun($this); |
|
47 | - if ($logger === null) { |
|
48 | - $logger = \OC::$server->getLogger(); |
|
49 | - } |
|
45 | + public function execute(IJobList $jobList, ILogger $logger = null) { |
|
46 | + $jobList->setLastRun($this); |
|
47 | + if ($logger === null) { |
|
48 | + $logger = \OC::$server->getLogger(); |
|
49 | + } |
|
50 | 50 | |
51 | - try { |
|
52 | - $jobStartTime = time(); |
|
53 | - $logger->debug('Run ' . get_class($this) . ' job with ID ' . $this->getId(), ['app' => 'cron']); |
|
54 | - $this->run($this->argument); |
|
55 | - $timeTaken = time() - $jobStartTime; |
|
51 | + try { |
|
52 | + $jobStartTime = time(); |
|
53 | + $logger->debug('Run ' . get_class($this) . ' job with ID ' . $this->getId(), ['app' => 'cron']); |
|
54 | + $this->run($this->argument); |
|
55 | + $timeTaken = time() - $jobStartTime; |
|
56 | 56 | |
57 | - $logger->debug('Finished ' . get_class($this) . ' job with ID ' . $this->getId() . ' in ' . $timeTaken . ' seconds', ['app' => 'cron']); |
|
58 | - $jobList->setExecutionTime($this, $timeTaken); |
|
59 | - } catch (\Throwable $e) { |
|
60 | - if ($logger) { |
|
61 | - $logger->logException($e, [ |
|
62 | - 'app' => 'core', |
|
63 | - 'message' => 'Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')' |
|
64 | - ]); |
|
65 | - } |
|
66 | - } |
|
67 | - } |
|
57 | + $logger->debug('Finished ' . get_class($this) . ' job with ID ' . $this->getId() . ' in ' . $timeTaken . ' seconds', ['app' => 'cron']); |
|
58 | + $jobList->setExecutionTime($this, $timeTaken); |
|
59 | + } catch (\Throwable $e) { |
|
60 | + if ($logger) { |
|
61 | + $logger->logException($e, [ |
|
62 | + 'app' => 'core', |
|
63 | + 'message' => 'Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')' |
|
64 | + ]); |
|
65 | + } |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | - public function start(IJobList $jobList): void { |
|
70 | - $this->execute($jobList); |
|
71 | - } |
|
69 | + public function start(IJobList $jobList): void { |
|
70 | + $this->execute($jobList); |
|
71 | + } |
|
72 | 72 | |
73 | - abstract protected function run($argument); |
|
73 | + abstract protected function run($argument); |
|
74 | 74 | |
75 | - public function setId(int $id) { |
|
76 | - $this->id = $id; |
|
77 | - } |
|
75 | + public function setId(int $id) { |
|
76 | + $this->id = $id; |
|
77 | + } |
|
78 | 78 | |
79 | - public function setLastRun(int $lastRun) { |
|
80 | - $this->lastRun = $lastRun; |
|
81 | - } |
|
79 | + public function setLastRun(int $lastRun) { |
|
80 | + $this->lastRun = $lastRun; |
|
81 | + } |
|
82 | 82 | |
83 | - public function setArgument($argument) { |
|
84 | - $this->argument = $argument; |
|
85 | - } |
|
83 | + public function setArgument($argument) { |
|
84 | + $this->argument = $argument; |
|
85 | + } |
|
86 | 86 | |
87 | - public function getId() { |
|
88 | - return $this->id; |
|
89 | - } |
|
87 | + public function getId() { |
|
88 | + return $this->id; |
|
89 | + } |
|
90 | 90 | |
91 | - public function getLastRun() { |
|
92 | - return $this->lastRun; |
|
93 | - } |
|
91 | + public function getLastRun() { |
|
92 | + return $this->lastRun; |
|
93 | + } |
|
94 | 94 | |
95 | - public function getArgument() { |
|
96 | - return $this->argument; |
|
97 | - } |
|
95 | + public function getArgument() { |
|
96 | + return $this->argument; |
|
97 | + } |
|
98 | 98 | } |
@@ -32,15 +32,15 @@ |
||
32 | 32 | use Doctrine\DBAL\TransactionIsolationLevel; |
33 | 33 | |
34 | 34 | class SetTransactionIsolationLevel implements EventSubscriber { |
35 | - /** |
|
36 | - * @param ConnectionEventArgs $args |
|
37 | - * @return void |
|
38 | - */ |
|
39 | - public function postConnect(ConnectionEventArgs $args) { |
|
40 | - $args->getConnection()->setTransactionIsolation(TransactionIsolationLevel::READ_COMMITTED); |
|
41 | - } |
|
35 | + /** |
|
36 | + * @param ConnectionEventArgs $args |
|
37 | + * @return void |
|
38 | + */ |
|
39 | + public function postConnect(ConnectionEventArgs $args) { |
|
40 | + $args->getConnection()->setTransactionIsolation(TransactionIsolationLevel::READ_COMMITTED); |
|
41 | + } |
|
42 | 42 | |
43 | - public function getSubscribedEvents() { |
|
44 | - return [Events::postConnect]; |
|
45 | - } |
|
43 | + public function getSubscribedEvents() { |
|
44 | + return [Events::postConnect]; |
|
45 | + } |
|
46 | 46 | } |