@@ -29,45 +29,45 @@ |
||
29 | 29 | use OCP\Settings\IIconSection; |
30 | 30 | |
31 | 31 | class Section implements IIconSection { |
32 | - /** @var IL10N */ |
|
33 | - private $l; |
|
34 | - /** @var IURLGenerator */ |
|
35 | - private $url; |
|
32 | + /** @var IL10N */ |
|
33 | + private $l; |
|
34 | + /** @var IURLGenerator */ |
|
35 | + private $url; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @param IURLGenerator $url |
|
39 | - * @param IL10N $l |
|
40 | - */ |
|
41 | - public function __construct(IURLGenerator $url, IL10N $l) { |
|
42 | - $this->url = $url; |
|
43 | - $this->l = $l; |
|
44 | - } |
|
37 | + /** |
|
38 | + * @param IURLGenerator $url |
|
39 | + * @param IL10N $l |
|
40 | + */ |
|
41 | + public function __construct(IURLGenerator $url, IL10N $l) { |
|
42 | + $this->url = $url; |
|
43 | + $this->l = $l; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * {@inheritdoc} |
|
48 | - */ |
|
49 | - public function getID() { |
|
50 | - return 'workflow'; |
|
51 | - } |
|
46 | + /** |
|
47 | + * {@inheritdoc} |
|
48 | + */ |
|
49 | + public function getID() { |
|
50 | + return 'workflow'; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * {@inheritdoc} |
|
55 | - */ |
|
56 | - public function getName() { |
|
57 | - return $this->l->t('Flow'); |
|
58 | - } |
|
53 | + /** |
|
54 | + * {@inheritdoc} |
|
55 | + */ |
|
56 | + public function getName() { |
|
57 | + return $this->l->t('Flow'); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * {@inheritdoc} |
|
62 | - */ |
|
63 | - public function getPriority() { |
|
64 | - return 55; |
|
65 | - } |
|
60 | + /** |
|
61 | + * {@inheritdoc} |
|
62 | + */ |
|
63 | + public function getPriority() { |
|
64 | + return 55; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * {@inheritdoc} |
|
69 | - */ |
|
70 | - public function getIcon() { |
|
71 | - return $this->url->imagePath(Application::APP_ID, 'app-dark.svg'); |
|
72 | - } |
|
67 | + /** |
|
68 | + * {@inheritdoc} |
|
69 | + */ |
|
70 | + public function getIcon() { |
|
71 | + return $this->url->imagePath(Application::APP_ID, 'app-dark.svg'); |
|
72 | + } |
|
73 | 73 | } |
@@ -36,37 +36,37 @@ |
||
36 | 36 | |
37 | 37 | class DirectEditingViewController extends Controller { |
38 | 38 | |
39 | - /** @var IEventDispatcher */ |
|
40 | - private $eventDispatcher; |
|
39 | + /** @var IEventDispatcher */ |
|
40 | + private $eventDispatcher; |
|
41 | 41 | |
42 | - /** @var IManager */ |
|
43 | - private $directEditingManager; |
|
42 | + /** @var IManager */ |
|
43 | + private $directEditingManager; |
|
44 | 44 | |
45 | - /** @var ILogger */ |
|
46 | - private $logger; |
|
45 | + /** @var ILogger */ |
|
46 | + private $logger; |
|
47 | 47 | |
48 | - public function __construct($appName, IRequest $request, IEventDispatcher $eventDispatcher, IManager $manager, ILogger $logger) { |
|
49 | - parent::__construct($appName, $request); |
|
48 | + public function __construct($appName, IRequest $request, IEventDispatcher $eventDispatcher, IManager $manager, ILogger $logger) { |
|
49 | + parent::__construct($appName, $request); |
|
50 | 50 | |
51 | - $this->eventDispatcher = $eventDispatcher; |
|
52 | - $this->directEditingManager = $manager; |
|
53 | - $this->logger = $logger; |
|
54 | - } |
|
51 | + $this->eventDispatcher = $eventDispatcher; |
|
52 | + $this->directEditingManager = $manager; |
|
53 | + $this->logger = $logger; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @PublicPage |
|
58 | - * @NoCSRFRequired |
|
59 | - * |
|
60 | - * @param string $token |
|
61 | - * @return Response |
|
62 | - */ |
|
63 | - public function edit(string $token): Response { |
|
64 | - $this->eventDispatcher->dispatchTyped(new RegisterDirectEditorEvent($this->directEditingManager)); |
|
65 | - try { |
|
66 | - return $this->directEditingManager->edit($token); |
|
67 | - } catch (Exception $e) { |
|
68 | - $this->logger->logException($e); |
|
69 | - return new NotFoundResponse(); |
|
70 | - } |
|
71 | - } |
|
56 | + /** |
|
57 | + * @PublicPage |
|
58 | + * @NoCSRFRequired |
|
59 | + * |
|
60 | + * @param string $token |
|
61 | + * @return Response |
|
62 | + */ |
|
63 | + public function edit(string $token): Response { |
|
64 | + $this->eventDispatcher->dispatchTyped(new RegisterDirectEditorEvent($this->directEditingManager)); |
|
65 | + try { |
|
66 | + return $this->directEditingManager->edit($token); |
|
67 | + } catch (Exception $e) { |
|
68 | + $this->logger->logException($e); |
|
69 | + return new NotFoundResponse(); |
|
70 | + } |
|
71 | + } |
|
72 | 72 | } |
@@ -42,72 +42,72 @@ |
||
42 | 42 | * @since 6.0.0 |
43 | 43 | */ |
44 | 44 | interface File extends Node { |
45 | - /** |
|
46 | - * Get the content of the file as string |
|
47 | - * |
|
48 | - * @return string |
|
49 | - * @throws NotPermittedException |
|
50 | - * @throws LockedException |
|
51 | - * @since 6.0.0 |
|
52 | - */ |
|
53 | - public function getContent(); |
|
45 | + /** |
|
46 | + * Get the content of the file as string |
|
47 | + * |
|
48 | + * @return string |
|
49 | + * @throws NotPermittedException |
|
50 | + * @throws LockedException |
|
51 | + * @since 6.0.0 |
|
52 | + */ |
|
53 | + public function getContent(); |
|
54 | 54 | |
55 | - /** |
|
56 | - * Write to the file from string data |
|
57 | - * |
|
58 | - * @param string|resource $data |
|
59 | - * @throws NotPermittedException |
|
60 | - * @throws GenericFileException |
|
61 | - * @throws LockedException |
|
62 | - * @since 6.0.0 |
|
63 | - */ |
|
64 | - public function putContent($data); |
|
55 | + /** |
|
56 | + * Write to the file from string data |
|
57 | + * |
|
58 | + * @param string|resource $data |
|
59 | + * @throws NotPermittedException |
|
60 | + * @throws GenericFileException |
|
61 | + * @throws LockedException |
|
62 | + * @since 6.0.0 |
|
63 | + */ |
|
64 | + public function putContent($data); |
|
65 | 65 | |
66 | - /** |
|
67 | - * Get the mimetype of the file |
|
68 | - * |
|
69 | - * @return string |
|
70 | - * @since 6.0.0 |
|
71 | - */ |
|
72 | - public function getMimeType(); |
|
66 | + /** |
|
67 | + * Get the mimetype of the file |
|
68 | + * |
|
69 | + * @return string |
|
70 | + * @since 6.0.0 |
|
71 | + */ |
|
72 | + public function getMimeType(); |
|
73 | 73 | |
74 | - /** |
|
75 | - * Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen |
|
76 | - * |
|
77 | - * @param string $mode |
|
78 | - * @return resource |
|
79 | - * @throws NotPermittedException |
|
80 | - * @throws LockedException |
|
81 | - * @since 6.0.0 |
|
82 | - */ |
|
83 | - public function fopen($mode); |
|
74 | + /** |
|
75 | + * Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen |
|
76 | + * |
|
77 | + * @param string $mode |
|
78 | + * @return resource |
|
79 | + * @throws NotPermittedException |
|
80 | + * @throws LockedException |
|
81 | + * @since 6.0.0 |
|
82 | + */ |
|
83 | + public function fopen($mode); |
|
84 | 84 | |
85 | - /** |
|
86 | - * Compute the hash of the file |
|
87 | - * Type of hash is set with $type and can be anything supported by php's hash_file |
|
88 | - * |
|
89 | - * @param string $type |
|
90 | - * @param bool $raw |
|
91 | - * @return string |
|
92 | - * @since 6.0.0 |
|
93 | - */ |
|
94 | - public function hash($type, $raw = false); |
|
85 | + /** |
|
86 | + * Compute the hash of the file |
|
87 | + * Type of hash is set with $type and can be anything supported by php's hash_file |
|
88 | + * |
|
89 | + * @param string $type |
|
90 | + * @param bool $raw |
|
91 | + * @return string |
|
92 | + * @since 6.0.0 |
|
93 | + */ |
|
94 | + public function hash($type, $raw = false); |
|
95 | 95 | |
96 | - /** |
|
97 | - * Get the stored checksum for this file |
|
98 | - * |
|
99 | - * @return string |
|
100 | - * @since 9.0.0 |
|
101 | - * @throws InvalidPathException |
|
102 | - * @throws NotFoundException |
|
103 | - */ |
|
104 | - public function getChecksum(); |
|
96 | + /** |
|
97 | + * Get the stored checksum for this file |
|
98 | + * |
|
99 | + * @return string |
|
100 | + * @since 9.0.0 |
|
101 | + * @throws InvalidPathException |
|
102 | + * @throws NotFoundException |
|
103 | + */ |
|
104 | + public function getChecksum(); |
|
105 | 105 | |
106 | - /** |
|
107 | - * Get the extension of this file |
|
108 | - * |
|
109 | - * @return string |
|
110 | - * @since 15.0.0 |
|
111 | - */ |
|
112 | - public function getExtension(): string; |
|
106 | + /** |
|
107 | + * Get the extension of this file |
|
108 | + * |
|
109 | + * @return string |
|
110 | + * @since 15.0.0 |
|
111 | + */ |
|
112 | + public function getExtension(): string; |
|
113 | 113 | } |
@@ -32,10 +32,10 @@ |
||
32 | 32 | * @since 18.0.0 |
33 | 33 | */ |
34 | 34 | interface IUrl { |
35 | - /** |
|
36 | - * returns a URL that is related to the entity, e.g. the link to a share |
|
37 | - * |
|
38 | - * @since 18.0.0 |
|
39 | - */ |
|
40 | - public function getUrl(): string; |
|
35 | + /** |
|
36 | + * returns a URL that is related to the entity, e.g. the link to a share |
|
37 | + * |
|
38 | + * @since 18.0.0 |
|
39 | + */ |
|
40 | + public function getUrl(): string; |
|
41 | 41 | } |
@@ -32,10 +32,10 @@ |
||
32 | 32 | * @since 18.0.0 |
33 | 33 | */ |
34 | 34 | interface IDisplayName { |
35 | - /** |
|
36 | - * returns the end user facing name of the object related to the entity |
|
37 | - * |
|
38 | - * @since 18.0.0 |
|
39 | - */ |
|
40 | - public function getDisplayName(): string; |
|
35 | + /** |
|
36 | + * returns the end user facing name of the object related to the entity |
|
37 | + * |
|
38 | + * @since 18.0.0 |
|
39 | + */ |
|
40 | + public function getDisplayName(): string; |
|
41 | 41 | } |
@@ -32,11 +32,11 @@ |
||
32 | 32 | * @since 18.0.0 |
33 | 33 | */ |
34 | 34 | interface IIcon { |
35 | - /** |
|
36 | - * returns a URL to an icon that is related to the entity, for instance |
|
37 | - * a group icon for groups. |
|
38 | - * |
|
39 | - * @since 18.0.0 |
|
40 | - */ |
|
41 | - public function getIconUrl(): string; |
|
35 | + /** |
|
36 | + * returns a URL to an icon that is related to the entity, for instance |
|
37 | + * a group icon for groups. |
|
38 | + * |
|
39 | + * @since 18.0.0 |
|
40 | + */ |
|
41 | + public function getIconUrl(): string; |
|
42 | 42 | } |
@@ -37,24 +37,24 @@ |
||
37 | 37 | * @method string getNodeName() |
38 | 38 | */ |
39 | 39 | class TransferOwnership extends Entity { |
40 | - /** @var string */ |
|
41 | - protected $sourceUser; |
|
40 | + /** @var string */ |
|
41 | + protected $sourceUser; |
|
42 | 42 | |
43 | - /** @var string */ |
|
44 | - protected $targetUser; |
|
43 | + /** @var string */ |
|
44 | + protected $targetUser; |
|
45 | 45 | |
46 | - /** @var integer */ |
|
47 | - protected $fileId; |
|
46 | + /** @var integer */ |
|
47 | + protected $fileId; |
|
48 | 48 | |
49 | - /** @var string */ |
|
50 | - protected $nodeName; |
|
49 | + /** @var string */ |
|
50 | + protected $nodeName; |
|
51 | 51 | |
52 | - public function __construct() { |
|
53 | - $this->addType('sourceUser', 'string'); |
|
54 | - $this->addType('targetUser', 'string'); |
|
55 | - $this->addType('fileId', 'integer'); |
|
56 | - $this->addType('nodeName', 'string'); |
|
57 | - } |
|
52 | + public function __construct() { |
|
53 | + $this->addType('sourceUser', 'string'); |
|
54 | + $this->addType('targetUser', 'string'); |
|
55 | + $this->addType('fileId', 'integer'); |
|
56 | + $this->addType('nodeName', 'string'); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | 60 | } |
@@ -32,83 +32,83 @@ |
||
32 | 32 | use OCP\IUser; |
33 | 33 | |
34 | 34 | class VersionManager implements IVersionManager { |
35 | - /** @var (IVersionBackend[])[] */ |
|
36 | - private $backends = []; |
|
37 | - |
|
38 | - public function registerBackend(string $storageType, IVersionBackend $backend) { |
|
39 | - if (!isset($this->backends[$storageType])) { |
|
40 | - $this->backends[$storageType] = []; |
|
41 | - } |
|
42 | - $this->backends[$storageType][] = $backend; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * @return (IVersionBackend[])[] |
|
47 | - */ |
|
48 | - private function getBackends(): array { |
|
49 | - return $this->backends; |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * @param IStorage $storage |
|
54 | - * @return IVersionBackend |
|
55 | - * @throws BackendNotFoundException |
|
56 | - */ |
|
57 | - public function getBackendForStorage(IStorage $storage): IVersionBackend { |
|
58 | - $fullType = get_class($storage); |
|
59 | - $backends = $this->getBackends(); |
|
60 | - |
|
61 | - $foundType = ''; |
|
62 | - $foundBackend = null; |
|
63 | - |
|
64 | - foreach ($backends as $type => $backendsForType) { |
|
65 | - if ( |
|
66 | - $storage->instanceOfStorage($type) && |
|
67 | - ($foundType === '' || is_subclass_of($type, $foundType)) |
|
68 | - ) { |
|
69 | - foreach ($backendsForType as $backend) { |
|
70 | - /** @var IVersionBackend $backend */ |
|
71 | - if ($backend->useBackendForStorage($storage)) { |
|
72 | - $foundBackend = $backend; |
|
73 | - $foundType = $type; |
|
74 | - } |
|
75 | - } |
|
76 | - } |
|
77 | - } |
|
78 | - |
|
79 | - if ($foundType === '' || $foundBackend === null) { |
|
80 | - throw new BackendNotFoundException("Version backend for $fullType not found"); |
|
81 | - } else { |
|
82 | - return $foundBackend; |
|
83 | - } |
|
84 | - } |
|
85 | - |
|
86 | - public function getVersionsForFile(IUser $user, FileInfo $file): array { |
|
87 | - $backend = $this->getBackendForStorage($file->getStorage()); |
|
88 | - return $backend->getVersionsForFile($user, $file); |
|
89 | - } |
|
90 | - |
|
91 | - public function createVersion(IUser $user, FileInfo $file) { |
|
92 | - $backend = $this->getBackendForStorage($file->getStorage()); |
|
93 | - $backend->createVersion($user, $file); |
|
94 | - } |
|
95 | - |
|
96 | - public function rollback(IVersion $version) { |
|
97 | - $backend = $version->getBackend(); |
|
98 | - return $backend->rollback($version); |
|
99 | - } |
|
100 | - |
|
101 | - public function read(IVersion $version) { |
|
102 | - $backend = $version->getBackend(); |
|
103 | - return $backend->read($version); |
|
104 | - } |
|
105 | - |
|
106 | - public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File { |
|
107 | - $backend = $this->getBackendForStorage($sourceFile->getStorage()); |
|
108 | - return $backend->getVersionFile($user, $sourceFile, $revision); |
|
109 | - } |
|
110 | - |
|
111 | - public function useBackendForStorage(IStorage $storage): bool { |
|
112 | - return false; |
|
113 | - } |
|
35 | + /** @var (IVersionBackend[])[] */ |
|
36 | + private $backends = []; |
|
37 | + |
|
38 | + public function registerBackend(string $storageType, IVersionBackend $backend) { |
|
39 | + if (!isset($this->backends[$storageType])) { |
|
40 | + $this->backends[$storageType] = []; |
|
41 | + } |
|
42 | + $this->backends[$storageType][] = $backend; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * @return (IVersionBackend[])[] |
|
47 | + */ |
|
48 | + private function getBackends(): array { |
|
49 | + return $this->backends; |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * @param IStorage $storage |
|
54 | + * @return IVersionBackend |
|
55 | + * @throws BackendNotFoundException |
|
56 | + */ |
|
57 | + public function getBackendForStorage(IStorage $storage): IVersionBackend { |
|
58 | + $fullType = get_class($storage); |
|
59 | + $backends = $this->getBackends(); |
|
60 | + |
|
61 | + $foundType = ''; |
|
62 | + $foundBackend = null; |
|
63 | + |
|
64 | + foreach ($backends as $type => $backendsForType) { |
|
65 | + if ( |
|
66 | + $storage->instanceOfStorage($type) && |
|
67 | + ($foundType === '' || is_subclass_of($type, $foundType)) |
|
68 | + ) { |
|
69 | + foreach ($backendsForType as $backend) { |
|
70 | + /** @var IVersionBackend $backend */ |
|
71 | + if ($backend->useBackendForStorage($storage)) { |
|
72 | + $foundBackend = $backend; |
|
73 | + $foundType = $type; |
|
74 | + } |
|
75 | + } |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + if ($foundType === '' || $foundBackend === null) { |
|
80 | + throw new BackendNotFoundException("Version backend for $fullType not found"); |
|
81 | + } else { |
|
82 | + return $foundBackend; |
|
83 | + } |
|
84 | + } |
|
85 | + |
|
86 | + public function getVersionsForFile(IUser $user, FileInfo $file): array { |
|
87 | + $backend = $this->getBackendForStorage($file->getStorage()); |
|
88 | + return $backend->getVersionsForFile($user, $file); |
|
89 | + } |
|
90 | + |
|
91 | + public function createVersion(IUser $user, FileInfo $file) { |
|
92 | + $backend = $this->getBackendForStorage($file->getStorage()); |
|
93 | + $backend->createVersion($user, $file); |
|
94 | + } |
|
95 | + |
|
96 | + public function rollback(IVersion $version) { |
|
97 | + $backend = $version->getBackend(); |
|
98 | + return $backend->rollback($version); |
|
99 | + } |
|
100 | + |
|
101 | + public function read(IVersion $version) { |
|
102 | + $backend = $version->getBackend(); |
|
103 | + return $backend->read($version); |
|
104 | + } |
|
105 | + |
|
106 | + public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File { |
|
107 | + $backend = $this->getBackendForStorage($sourceFile->getStorage()); |
|
108 | + return $backend->getVersionFile($user, $sourceFile, $revision); |
|
109 | + } |
|
110 | + |
|
111 | + public function useBackendForStorage(IStorage $storage): bool { |
|
112 | + return false; |
|
113 | + } |
|
114 | 114 | } |
@@ -35,63 +35,63 @@ |
||
35 | 35 | |
36 | 36 | class Notifier implements INotifier { |
37 | 37 | |
38 | - /** @var IFactory */ |
|
39 | - private $factory; |
|
40 | - |
|
41 | - /** @var IURLGenerator */ |
|
42 | - private $url; |
|
43 | - |
|
44 | - public function __construct(IFactory $factory, IURLGenerator $url) { |
|
45 | - $this->factory = $factory; |
|
46 | - $this->url = $url; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Identifier of the notifier, only use [a-z0-9_] |
|
51 | - * |
|
52 | - * @return string |
|
53 | - * @since 17.0.0 |
|
54 | - */ |
|
55 | - public function getID(): string { |
|
56 | - return 'twofactor_backupcodes'; |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * Human readable name describing the notifier |
|
61 | - * |
|
62 | - * @return string |
|
63 | - * @since 17.0.0 |
|
64 | - */ |
|
65 | - public function getName(): string { |
|
66 | - return $this->factory->get('twofactor_backupcodes')->t('Second-factor backup codes'); |
|
67 | - } |
|
68 | - |
|
69 | - public function prepare(INotification $notification, string $languageCode): INotification { |
|
70 | - if ($notification->getApp() !== 'twofactor_backupcodes') { |
|
71 | - // Not my app => throw |
|
72 | - throw new \InvalidArgumentException(); |
|
73 | - } |
|
74 | - |
|
75 | - // Read the language from the notification |
|
76 | - $l = $this->factory->get('twofactor_backupcodes', $languageCode); |
|
77 | - |
|
78 | - switch ($notification->getSubject()) { |
|
79 | - case 'create_backupcodes': |
|
80 | - $notification->setParsedSubject( |
|
81 | - $l->t('Generate backup codes') |
|
82 | - )->setParsedMessage( |
|
83 | - $l->t('You enabled two-factor authentication but did not generate backup codes yet. They are needed to restore access to your account in case you lose your second factor.') |
|
84 | - ); |
|
85 | - |
|
86 | - $notification->setLink($this->url->linkToRouteAbsolute('settings.PersonalSettings.index', ['section' => 'security'])); |
|
87 | - |
|
88 | - $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/password.svg'))); |
|
89 | - |
|
90 | - return $notification; |
|
91 | - |
|
92 | - default: |
|
93 | - // Unknown subject => Unknown notification => throw |
|
94 | - throw new \InvalidArgumentException(); |
|
95 | - } |
|
96 | - } |
|
38 | + /** @var IFactory */ |
|
39 | + private $factory; |
|
40 | + |
|
41 | + /** @var IURLGenerator */ |
|
42 | + private $url; |
|
43 | + |
|
44 | + public function __construct(IFactory $factory, IURLGenerator $url) { |
|
45 | + $this->factory = $factory; |
|
46 | + $this->url = $url; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Identifier of the notifier, only use [a-z0-9_] |
|
51 | + * |
|
52 | + * @return string |
|
53 | + * @since 17.0.0 |
|
54 | + */ |
|
55 | + public function getID(): string { |
|
56 | + return 'twofactor_backupcodes'; |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * Human readable name describing the notifier |
|
61 | + * |
|
62 | + * @return string |
|
63 | + * @since 17.0.0 |
|
64 | + */ |
|
65 | + public function getName(): string { |
|
66 | + return $this->factory->get('twofactor_backupcodes')->t('Second-factor backup codes'); |
|
67 | + } |
|
68 | + |
|
69 | + public function prepare(INotification $notification, string $languageCode): INotification { |
|
70 | + if ($notification->getApp() !== 'twofactor_backupcodes') { |
|
71 | + // Not my app => throw |
|
72 | + throw new \InvalidArgumentException(); |
|
73 | + } |
|
74 | + |
|
75 | + // Read the language from the notification |
|
76 | + $l = $this->factory->get('twofactor_backupcodes', $languageCode); |
|
77 | + |
|
78 | + switch ($notification->getSubject()) { |
|
79 | + case 'create_backupcodes': |
|
80 | + $notification->setParsedSubject( |
|
81 | + $l->t('Generate backup codes') |
|
82 | + )->setParsedMessage( |
|
83 | + $l->t('You enabled two-factor authentication but did not generate backup codes yet. They are needed to restore access to your account in case you lose your second factor.') |
|
84 | + ); |
|
85 | + |
|
86 | + $notification->setLink($this->url->linkToRouteAbsolute('settings.PersonalSettings.index', ['section' => 'security'])); |
|
87 | + |
|
88 | + $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/password.svg'))); |
|
89 | + |
|
90 | + return $notification; |
|
91 | + |
|
92 | + default: |
|
93 | + // Unknown subject => Unknown notification => throw |
|
94 | + throw new \InvalidArgumentException(); |
|
95 | + } |
|
96 | + } |
|
97 | 97 | } |