@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | ); |
79 | 79 | } catch (Throwable $e) { |
80 | 80 | // Any error with reminders shouldn't abort the calendar move, so we just log it |
81 | - $this->logger->error('Error cleaning up reminders of a calendar moved into trashbin: ' . $e->getMessage(), [ |
|
81 | + $this->logger->error('Error cleaning up reminders of a calendar moved into trashbin: '.$e->getMessage(), [ |
|
82 | 82 | 'exception' => $e, |
83 | 83 | ]); |
84 | 84 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | ); |
94 | 94 | } catch (Throwable $e) { |
95 | 95 | // Any error with activities shouldn't abort the calendar deletion, so we just log it |
96 | - $this->logger->error('Error cleaning up reminders of a deleted calendar: ' . $e->getMessage(), [ |
|
96 | + $this->logger->error('Error cleaning up reminders of a deleted calendar: '.$e->getMessage(), [ |
|
97 | 97 | 'exception' => $e, |
98 | 98 | ]); |
99 | 99 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | ); |
115 | 115 | } catch (Throwable $e) { |
116 | 116 | // Any error with reminders shouldn't abort the calendar deletion, so we just log it |
117 | - $this->logger->error('Error restoring reminders of a calendar: ' . $e->getMessage(), [ |
|
117 | + $this->logger->error('Error restoring reminders of a calendar: '.$e->getMessage(), [ |
|
118 | 118 | 'exception' => $e, |
119 | 119 | ]); |
120 | 120 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | ); |
130 | 130 | } catch (Throwable $e) { |
131 | 131 | // Any error with reminders shouldn't abort the calendar object creation, so we just log it |
132 | - $this->logger->error('Error creating reminders of a calendar object: ' . $e->getMessage(), [ |
|
132 | + $this->logger->error('Error creating reminders of a calendar object: '.$e->getMessage(), [ |
|
133 | 133 | 'exception' => $e, |
134 | 134 | ]); |
135 | 135 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | ); |
145 | 145 | } catch (Throwable $e) { |
146 | 146 | // Any error with activities shouldn't abort the calendar object deletion, so we just log it |
147 | - $this->logger->error('Error cleaning up reminders of a calendar object: ' . $e->getMessage(), [ |
|
147 | + $this->logger->error('Error cleaning up reminders of a calendar object: '.$e->getMessage(), [ |
|
148 | 148 | 'exception' => $e, |
149 | 149 | ]); |
150 | 150 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | ); |
160 | 160 | } catch (Throwable $e) { |
161 | 161 | // Any error with reminders shouldn't abort the calendar object deletion, so we just log it |
162 | - $this->logger->error('Error deleting reminders of a calendar object: ' . $e->getMessage(), [ |
|
162 | + $this->logger->error('Error deleting reminders of a calendar object: '.$e->getMessage(), [ |
|
163 | 163 | 'exception' => $e, |
164 | 164 | ]); |
165 | 165 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | ); |
175 | 175 | } catch (Throwable $e) { |
176 | 176 | // Any error with reminders shouldn't abort the calendar object deletion, so we just log it |
177 | - $this->logger->error('Error restoring reminders of a calendar object: ' . $e->getMessage(), [ |
|
177 | + $this->logger->error('Error restoring reminders of a calendar object: '.$e->getMessage(), [ |
|
178 | 178 | 'exception' => $e, |
179 | 179 | ]); |
180 | 180 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | ); |
190 | 190 | } catch (Throwable $e) { |
191 | 191 | // Any error with activities shouldn't abort the calendar object deletion, so we just log it |
192 | - $this->logger->error('Error cleaning up reminders of a deleted calendar object: ' . $e->getMessage(), [ |
|
192 | + $this->logger->error('Error cleaning up reminders of a deleted calendar object: '.$e->getMessage(), [ |
|
193 | 193 | 'exception' => $e, |
194 | 194 | ]); |
195 | 195 | } |
@@ -28,141 +28,141 @@ |
||
28 | 28 | /** @template-implements IEventListener<CalendarMovedToTrashEvent|CalendarDeletedEvent|CalendarRestoredEvent|CalendarObjectCreatedEvent|CalendarObjectUpdatedEvent|CalendarObjectMovedToTrashEvent|CalendarObjectRestoredEvent|CalendarObjectDeletedEvent> */ |
29 | 29 | class CalendarObjectReminderUpdaterListener implements IEventListener { |
30 | 30 | |
31 | - public function __construct( |
|
32 | - private ReminderBackend $reminderBackend, |
|
33 | - private ReminderService $reminderService, |
|
34 | - private CalDavBackend $calDavBackend, |
|
35 | - private LoggerInterface $logger, |
|
36 | - ) { |
|
37 | - } |
|
31 | + public function __construct( |
|
32 | + private ReminderBackend $reminderBackend, |
|
33 | + private ReminderService $reminderService, |
|
34 | + private CalDavBackend $calDavBackend, |
|
35 | + private LoggerInterface $logger, |
|
36 | + ) { |
|
37 | + } |
|
38 | 38 | |
39 | - public function handle(Event $event): void { |
|
40 | - if ($event instanceof CalendarMovedToTrashEvent) { |
|
41 | - try { |
|
42 | - $this->reminderBackend->cleanRemindersForCalendar( |
|
43 | - $event->getCalendarId() |
|
44 | - ); |
|
39 | + public function handle(Event $event): void { |
|
40 | + if ($event instanceof CalendarMovedToTrashEvent) { |
|
41 | + try { |
|
42 | + $this->reminderBackend->cleanRemindersForCalendar( |
|
43 | + $event->getCalendarId() |
|
44 | + ); |
|
45 | 45 | |
46 | - $this->logger->debug( |
|
47 | - sprintf('Reminders of calendar %d cleaned up after move into trashbin', $event->getCalendarId()) |
|
48 | - ); |
|
49 | - } catch (Throwable $e) { |
|
50 | - // Any error with reminders shouldn't abort the calendar move, so we just log it |
|
51 | - $this->logger->error('Error cleaning up reminders of a calendar moved into trashbin: ' . $e->getMessage(), [ |
|
52 | - 'exception' => $e, |
|
53 | - ]); |
|
54 | - } |
|
55 | - } elseif ($event instanceof CalendarDeletedEvent) { |
|
56 | - try { |
|
57 | - $this->reminderBackend->cleanRemindersForCalendar( |
|
58 | - $event->getCalendarId() |
|
59 | - ); |
|
46 | + $this->logger->debug( |
|
47 | + sprintf('Reminders of calendar %d cleaned up after move into trashbin', $event->getCalendarId()) |
|
48 | + ); |
|
49 | + } catch (Throwable $e) { |
|
50 | + // Any error with reminders shouldn't abort the calendar move, so we just log it |
|
51 | + $this->logger->error('Error cleaning up reminders of a calendar moved into trashbin: ' . $e->getMessage(), [ |
|
52 | + 'exception' => $e, |
|
53 | + ]); |
|
54 | + } |
|
55 | + } elseif ($event instanceof CalendarDeletedEvent) { |
|
56 | + try { |
|
57 | + $this->reminderBackend->cleanRemindersForCalendar( |
|
58 | + $event->getCalendarId() |
|
59 | + ); |
|
60 | 60 | |
61 | - $this->logger->debug( |
|
62 | - sprintf('Reminders of calendar %d cleaned up', $event->getCalendarId()) |
|
63 | - ); |
|
64 | - } catch (Throwable $e) { |
|
65 | - // Any error with activities shouldn't abort the calendar deletion, so we just log it |
|
66 | - $this->logger->error('Error cleaning up reminders of a deleted calendar: ' . $e->getMessage(), [ |
|
67 | - 'exception' => $e, |
|
68 | - ]); |
|
69 | - } |
|
70 | - } elseif ($event instanceof CalendarRestoredEvent) { |
|
71 | - try { |
|
72 | - $objects = $this->calDavBackend->getCalendarObjects($event->getCalendarId()); |
|
73 | - $this->logger->debug(sprintf('Restoring calendar reminder objects for %d items', count($objects))); |
|
74 | - foreach ($objects as $object) { |
|
75 | - $fullObject = $this->calDavBackend->getCalendarObject( |
|
76 | - $event->getCalendarId(), |
|
77 | - $object['uri'] |
|
78 | - ); |
|
79 | - $this->reminderService->onCalendarObjectCreate($fullObject); |
|
80 | - } |
|
61 | + $this->logger->debug( |
|
62 | + sprintf('Reminders of calendar %d cleaned up', $event->getCalendarId()) |
|
63 | + ); |
|
64 | + } catch (Throwable $e) { |
|
65 | + // Any error with activities shouldn't abort the calendar deletion, so we just log it |
|
66 | + $this->logger->error('Error cleaning up reminders of a deleted calendar: ' . $e->getMessage(), [ |
|
67 | + 'exception' => $e, |
|
68 | + ]); |
|
69 | + } |
|
70 | + } elseif ($event instanceof CalendarRestoredEvent) { |
|
71 | + try { |
|
72 | + $objects = $this->calDavBackend->getCalendarObjects($event->getCalendarId()); |
|
73 | + $this->logger->debug(sprintf('Restoring calendar reminder objects for %d items', count($objects))); |
|
74 | + foreach ($objects as $object) { |
|
75 | + $fullObject = $this->calDavBackend->getCalendarObject( |
|
76 | + $event->getCalendarId(), |
|
77 | + $object['uri'] |
|
78 | + ); |
|
79 | + $this->reminderService->onCalendarObjectCreate($fullObject); |
|
80 | + } |
|
81 | 81 | |
82 | - $this->logger->debug( |
|
83 | - sprintf('Reminders of calendar %d restored', $event->getCalendarId()) |
|
84 | - ); |
|
85 | - } catch (Throwable $e) { |
|
86 | - // Any error with reminders shouldn't abort the calendar deletion, so we just log it |
|
87 | - $this->logger->error('Error restoring reminders of a calendar: ' . $e->getMessage(), [ |
|
88 | - 'exception' => $e, |
|
89 | - ]); |
|
90 | - } |
|
91 | - } elseif ($event instanceof CalendarObjectCreatedEvent) { |
|
92 | - try { |
|
93 | - $this->reminderService->onCalendarObjectCreate( |
|
94 | - $event->getObjectData() |
|
95 | - ); |
|
82 | + $this->logger->debug( |
|
83 | + sprintf('Reminders of calendar %d restored', $event->getCalendarId()) |
|
84 | + ); |
|
85 | + } catch (Throwable $e) { |
|
86 | + // Any error with reminders shouldn't abort the calendar deletion, so we just log it |
|
87 | + $this->logger->error('Error restoring reminders of a calendar: ' . $e->getMessage(), [ |
|
88 | + 'exception' => $e, |
|
89 | + ]); |
|
90 | + } |
|
91 | + } elseif ($event instanceof CalendarObjectCreatedEvent) { |
|
92 | + try { |
|
93 | + $this->reminderService->onCalendarObjectCreate( |
|
94 | + $event->getObjectData() |
|
95 | + ); |
|
96 | 96 | |
97 | - $this->logger->debug( |
|
98 | - sprintf('Reminders of calendar object of calendar %d created', $event->getCalendarId()) |
|
99 | - ); |
|
100 | - } catch (Throwable $e) { |
|
101 | - // Any error with reminders shouldn't abort the calendar object creation, so we just log it |
|
102 | - $this->logger->error('Error creating reminders of a calendar object: ' . $e->getMessage(), [ |
|
103 | - 'exception' => $e, |
|
104 | - ]); |
|
105 | - } |
|
106 | - } elseif ($event instanceof CalendarObjectUpdatedEvent) { |
|
107 | - try { |
|
108 | - $this->reminderService->onCalendarObjectEdit( |
|
109 | - $event->getObjectData() |
|
110 | - ); |
|
97 | + $this->logger->debug( |
|
98 | + sprintf('Reminders of calendar object of calendar %d created', $event->getCalendarId()) |
|
99 | + ); |
|
100 | + } catch (Throwable $e) { |
|
101 | + // Any error with reminders shouldn't abort the calendar object creation, so we just log it |
|
102 | + $this->logger->error('Error creating reminders of a calendar object: ' . $e->getMessage(), [ |
|
103 | + 'exception' => $e, |
|
104 | + ]); |
|
105 | + } |
|
106 | + } elseif ($event instanceof CalendarObjectUpdatedEvent) { |
|
107 | + try { |
|
108 | + $this->reminderService->onCalendarObjectEdit( |
|
109 | + $event->getObjectData() |
|
110 | + ); |
|
111 | 111 | |
112 | - $this->logger->debug( |
|
113 | - sprintf('Reminders of calendar object of calendar %d cleaned up', $event->getCalendarId()) |
|
114 | - ); |
|
115 | - } catch (Throwable $e) { |
|
116 | - // Any error with activities shouldn't abort the calendar object deletion, so we just log it |
|
117 | - $this->logger->error('Error cleaning up reminders of a calendar object: ' . $e->getMessage(), [ |
|
118 | - 'exception' => $e, |
|
119 | - ]); |
|
120 | - } |
|
121 | - } elseif ($event instanceof CalendarObjectMovedToTrashEvent) { |
|
122 | - try { |
|
123 | - $this->reminderService->onCalendarObjectDelete( |
|
124 | - $event->getObjectData() |
|
125 | - ); |
|
112 | + $this->logger->debug( |
|
113 | + sprintf('Reminders of calendar object of calendar %d cleaned up', $event->getCalendarId()) |
|
114 | + ); |
|
115 | + } catch (Throwable $e) { |
|
116 | + // Any error with activities shouldn't abort the calendar object deletion, so we just log it |
|
117 | + $this->logger->error('Error cleaning up reminders of a calendar object: ' . $e->getMessage(), [ |
|
118 | + 'exception' => $e, |
|
119 | + ]); |
|
120 | + } |
|
121 | + } elseif ($event instanceof CalendarObjectMovedToTrashEvent) { |
|
122 | + try { |
|
123 | + $this->reminderService->onCalendarObjectDelete( |
|
124 | + $event->getObjectData() |
|
125 | + ); |
|
126 | 126 | |
127 | - $this->logger->debug( |
|
128 | - sprintf('Reminders of restored calendar object of calendar %d deleted', $event->getCalendarId()) |
|
129 | - ); |
|
130 | - } catch (Throwable $e) { |
|
131 | - // Any error with reminders shouldn't abort the calendar object deletion, so we just log it |
|
132 | - $this->logger->error('Error deleting reminders of a calendar object: ' . $e->getMessage(), [ |
|
133 | - 'exception' => $e, |
|
134 | - ]); |
|
135 | - } |
|
136 | - } elseif ($event instanceof CalendarObjectRestoredEvent) { |
|
137 | - try { |
|
138 | - $this->reminderService->onCalendarObjectCreate( |
|
139 | - $event->getObjectData() |
|
140 | - ); |
|
127 | + $this->logger->debug( |
|
128 | + sprintf('Reminders of restored calendar object of calendar %d deleted', $event->getCalendarId()) |
|
129 | + ); |
|
130 | + } catch (Throwable $e) { |
|
131 | + // Any error with reminders shouldn't abort the calendar object deletion, so we just log it |
|
132 | + $this->logger->error('Error deleting reminders of a calendar object: ' . $e->getMessage(), [ |
|
133 | + 'exception' => $e, |
|
134 | + ]); |
|
135 | + } |
|
136 | + } elseif ($event instanceof CalendarObjectRestoredEvent) { |
|
137 | + try { |
|
138 | + $this->reminderService->onCalendarObjectCreate( |
|
139 | + $event->getObjectData() |
|
140 | + ); |
|
141 | 141 | |
142 | - $this->logger->debug( |
|
143 | - sprintf('Reminders of restored calendar object of calendar %d restored', $event->getCalendarId()) |
|
144 | - ); |
|
145 | - } catch (Throwable $e) { |
|
146 | - // Any error with reminders shouldn't abort the calendar object deletion, so we just log it |
|
147 | - $this->logger->error('Error restoring reminders of a calendar object: ' . $e->getMessage(), [ |
|
148 | - 'exception' => $e, |
|
149 | - ]); |
|
150 | - } |
|
151 | - } elseif ($event instanceof CalendarObjectDeletedEvent) { |
|
152 | - try { |
|
153 | - $this->reminderService->onCalendarObjectDelete( |
|
154 | - $event->getObjectData() |
|
155 | - ); |
|
142 | + $this->logger->debug( |
|
143 | + sprintf('Reminders of restored calendar object of calendar %d restored', $event->getCalendarId()) |
|
144 | + ); |
|
145 | + } catch (Throwable $e) { |
|
146 | + // Any error with reminders shouldn't abort the calendar object deletion, so we just log it |
|
147 | + $this->logger->error('Error restoring reminders of a calendar object: ' . $e->getMessage(), [ |
|
148 | + 'exception' => $e, |
|
149 | + ]); |
|
150 | + } |
|
151 | + } elseif ($event instanceof CalendarObjectDeletedEvent) { |
|
152 | + try { |
|
153 | + $this->reminderService->onCalendarObjectDelete( |
|
154 | + $event->getObjectData() |
|
155 | + ); |
|
156 | 156 | |
157 | - $this->logger->debug( |
|
158 | - sprintf('Reminders of calendar object of calendar %d cleaned up', $event->getCalendarId()) |
|
159 | - ); |
|
160 | - } catch (Throwable $e) { |
|
161 | - // Any error with activities shouldn't abort the calendar object deletion, so we just log it |
|
162 | - $this->logger->error('Error cleaning up reminders of a deleted calendar object: ' . $e->getMessage(), [ |
|
163 | - 'exception' => $e, |
|
164 | - ]); |
|
165 | - } |
|
166 | - } |
|
167 | - } |
|
157 | + $this->logger->debug( |
|
158 | + sprintf('Reminders of calendar object of calendar %d cleaned up', $event->getCalendarId()) |
|
159 | + ); |
|
160 | + } catch (Throwable $e) { |
|
161 | + // Any error with activities shouldn't abort the calendar object deletion, so we just log it |
|
162 | + $this->logger->error('Error cleaning up reminders of a deleted calendar object: ' . $e->getMessage(), [ |
|
163 | + 'exception' => $e, |
|
164 | + ]); |
|
165 | + } |
|
166 | + } |
|
167 | + } |
|
168 | 168 | } |
@@ -12,34 +12,34 @@ |
||
12 | 12 | |
13 | 13 | class Version1018Date20210312100735 extends SimpleMigrationStep { |
14 | 14 | |
15 | - /** |
|
16 | - * @param IOutput $output |
|
17 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
18 | - * @param array $options |
|
19 | - * @return ISchemaWrapper |
|
20 | - */ |
|
21 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
22 | - /** @var ISchemaWrapper $schema */ |
|
23 | - $schema = $schemaClosure(); |
|
24 | - |
|
25 | - $calendarsTable = $schema->getTable('calendars'); |
|
26 | - $calendarsTable->addColumn('deleted_at', Types::INTEGER, [ |
|
27 | - 'notnull' => false, |
|
28 | - 'length' => 4, |
|
29 | - 'unsigned' => true, |
|
30 | - ]); |
|
31 | - $calendarsTable->addIndex([ |
|
32 | - 'principaluri', |
|
33 | - 'deleted_at', |
|
34 | - ], 'cals_princ_del_idx'); |
|
35 | - |
|
36 | - $calendarObjectsTable = $schema->getTable('calendarobjects'); |
|
37 | - $calendarObjectsTable->addColumn('deleted_at', Types::INTEGER, [ |
|
38 | - 'notnull' => false, |
|
39 | - 'length' => 4, |
|
40 | - 'unsigned' => true, |
|
41 | - ]); |
|
42 | - |
|
43 | - return $schema; |
|
44 | - } |
|
15 | + /** |
|
16 | + * @param IOutput $output |
|
17 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
18 | + * @param array $options |
|
19 | + * @return ISchemaWrapper |
|
20 | + */ |
|
21 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
22 | + /** @var ISchemaWrapper $schema */ |
|
23 | + $schema = $schemaClosure(); |
|
24 | + |
|
25 | + $calendarsTable = $schema->getTable('calendars'); |
|
26 | + $calendarsTable->addColumn('deleted_at', Types::INTEGER, [ |
|
27 | + 'notnull' => false, |
|
28 | + 'length' => 4, |
|
29 | + 'unsigned' => true, |
|
30 | + ]); |
|
31 | + $calendarsTable->addIndex([ |
|
32 | + 'principaluri', |
|
33 | + 'deleted_at', |
|
34 | + ], 'cals_princ_del_idx'); |
|
35 | + |
|
36 | + $calendarObjectsTable = $schema->getTable('calendarobjects'); |
|
37 | + $calendarObjectsTable->addColumn('deleted_at', Types::INTEGER, [ |
|
38 | + 'notnull' => false, |
|
39 | + 'length' => 4, |
|
40 | + 'unsigned' => true, |
|
41 | + ]); |
|
42 | + |
|
43 | + return $schema; |
|
44 | + } |
|
45 | 45 | } |
@@ -32,10 +32,10 @@ |
||
32 | 32 | */ |
33 | 33 | interface IRestorable { |
34 | 34 | |
35 | - /** |
|
36 | - * Restore this node |
|
37 | - * |
|
38 | - * @throws Exception |
|
39 | - */ |
|
40 | - public function restore(): void; |
|
35 | + /** |
|
36 | + * Restore this node |
|
37 | + * |
|
38 | + * @throws Exception |
|
39 | + */ |
|
40 | + public function restore(): void; |
|
41 | 41 | } |
@@ -33,50 +33,50 @@ |
||
33 | 33 | use Sabre\DAV\INode; |
34 | 34 | |
35 | 35 | class RestoreTarget implements ICollection, IMoveTarget { |
36 | - public const NAME = 'restore'; |
|
36 | + public const NAME = 'restore'; |
|
37 | 37 | |
38 | - public function createFile($name, $data = null) { |
|
39 | - throw new Forbidden(); |
|
40 | - } |
|
38 | + public function createFile($name, $data = null) { |
|
39 | + throw new Forbidden(); |
|
40 | + } |
|
41 | 41 | |
42 | - public function createDirectory($name) { |
|
43 | - throw new Forbidden(); |
|
44 | - } |
|
42 | + public function createDirectory($name) { |
|
43 | + throw new Forbidden(); |
|
44 | + } |
|
45 | 45 | |
46 | - public function getChild($name) { |
|
47 | - throw new NotFound(); |
|
48 | - } |
|
46 | + public function getChild($name) { |
|
47 | + throw new NotFound(); |
|
48 | + } |
|
49 | 49 | |
50 | - public function getChildren(): array { |
|
51 | - return []; |
|
52 | - } |
|
50 | + public function getChildren(): array { |
|
51 | + return []; |
|
52 | + } |
|
53 | 53 | |
54 | - public function childExists($name): bool { |
|
55 | - return false; |
|
56 | - } |
|
54 | + public function childExists($name): bool { |
|
55 | + return false; |
|
56 | + } |
|
57 | 57 | |
58 | - public function moveInto($targetName, $sourcePath, INode $sourceNode): bool { |
|
59 | - if ($sourceNode instanceof IRestorable) { |
|
60 | - $sourceNode->restore(); |
|
61 | - return true; |
|
62 | - } |
|
58 | + public function moveInto($targetName, $sourcePath, INode $sourceNode): bool { |
|
59 | + if ($sourceNode instanceof IRestorable) { |
|
60 | + $sourceNode->restore(); |
|
61 | + return true; |
|
62 | + } |
|
63 | 63 | |
64 | - return false; |
|
65 | - } |
|
64 | + return false; |
|
65 | + } |
|
66 | 66 | |
67 | - public function delete() { |
|
68 | - throw new Forbidden(); |
|
69 | - } |
|
67 | + public function delete() { |
|
68 | + throw new Forbidden(); |
|
69 | + } |
|
70 | 70 | |
71 | - public function getName(): string { |
|
72 | - return 'restore'; |
|
73 | - } |
|
71 | + public function getName(): string { |
|
72 | + return 'restore'; |
|
73 | + } |
|
74 | 74 | |
75 | - public function setName($name) { |
|
76 | - throw new Forbidden(); |
|
77 | - } |
|
75 | + public function setName($name) { |
|
76 | + throw new Forbidden(); |
|
77 | + } |
|
78 | 78 | |
79 | - public function getLastModified() { |
|
80 | - return 0; |
|
81 | - } |
|
79 | + public function getLastModified() { |
|
80 | + return 0; |
|
81 | + } |
|
82 | 82 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | |
42 | 42 | $filename = strtr($filename, ['"' => '\\"', '\\' => '\\\\']); |
43 | 43 | |
44 | - $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
44 | + $this->addHeader('Content-Disposition', 'attachment; filename="'.$filename.'"'); |
|
45 | 45 | $this->addHeader('Content-Type', $contentType); |
46 | 46 | } |
47 | 47 | } |
@@ -18,20 +18,20 @@ |
||
18 | 18 | * @template-extends Response<Http::STATUS_*, array<string, mixed>> |
19 | 19 | */ |
20 | 20 | class DownloadResponse extends Response { |
21 | - /** |
|
22 | - * Creates a response that prompts the user to download the file |
|
23 | - * @param string $filename the name that the downloaded file should have |
|
24 | - * @param C $contentType the mimetype that the downloaded file should have |
|
25 | - * @param S $status |
|
26 | - * @param H $headers |
|
27 | - * @since 7.0.0 |
|
28 | - */ |
|
29 | - public function __construct(string $filename, string $contentType, int $status = Http::STATUS_OK, array $headers = []) { |
|
30 | - parent::__construct($status, $headers); |
|
21 | + /** |
|
22 | + * Creates a response that prompts the user to download the file |
|
23 | + * @param string $filename the name that the downloaded file should have |
|
24 | + * @param C $contentType the mimetype that the downloaded file should have |
|
25 | + * @param S $status |
|
26 | + * @param H $headers |
|
27 | + * @since 7.0.0 |
|
28 | + */ |
|
29 | + public function __construct(string $filename, string $contentType, int $status = Http::STATUS_OK, array $headers = []) { |
|
30 | + parent::__construct($status, $headers); |
|
31 | 31 | |
32 | - $filename = strtr($filename, ['"' => '\\"', '\\' => '\\\\']); |
|
32 | + $filename = strtr($filename, ['"' => '\\"', '\\' => '\\\\']); |
|
33 | 33 | |
34 | - $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
35 | - $this->addHeader('Content-Type', $contentType); |
|
36 | - } |
|
34 | + $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
35 | + $this->addHeader('Content-Type', $contentType); |
|
36 | + } |
|
37 | 37 | } |
@@ -37,22 +37,22 @@ |
||
37 | 37 | |
38 | 38 | class Version1008Date20181030113700 extends SimpleMigrationStep { |
39 | 39 | |
40 | - /** |
|
41 | - * @param IOutput $output |
|
42 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
43 | - * @param array $options |
|
44 | - * @return null|ISchemaWrapper |
|
45 | - */ |
|
46 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
47 | - /** @var ISchemaWrapper $schema */ |
|
48 | - $schema = $schemaClosure(); |
|
49 | - |
|
50 | - $table = $schema->getTable('cards'); |
|
51 | - $table->addColumn('uid', Types::STRING, [ |
|
52 | - 'notnull' => false, |
|
53 | - 'length' => 255 |
|
54 | - ]); |
|
55 | - |
|
56 | - return $schema; |
|
57 | - } |
|
40 | + /** |
|
41 | + * @param IOutput $output |
|
42 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
43 | + * @param array $options |
|
44 | + * @return null|ISchemaWrapper |
|
45 | + */ |
|
46 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
47 | + /** @var ISchemaWrapper $schema */ |
|
48 | + $schema = $schemaClosure(); |
|
49 | + |
|
50 | + $table = $schema->getTable('cards'); |
|
51 | + $table->addColumn('uid', Types::STRING, [ |
|
52 | + 'notnull' => false, |
|
53 | + 'length' => 255 |
|
54 | + ]); |
|
55 | + |
|
56 | + return $schema; |
|
57 | + } |
|
58 | 58 | } |
@@ -33,20 +33,20 @@ |
||
33 | 33 | |
34 | 34 | class Version1002Date20180821043638 extends SimpleMigrationStep { |
35 | 35 | |
36 | - /** |
|
37 | - * @param IOutput $output |
|
38 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | - * @param array $options |
|
40 | - * |
|
41 | - * @return ISchemaWrapper |
|
42 | - */ |
|
43 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
44 | - /** @var ISchemaWrapper $schema */ |
|
45 | - $schema = $schemaClosure(); |
|
46 | - $table = $schema->getTable('twofactor_backupcodes'); |
|
36 | + /** |
|
37 | + * @param IOutput $output |
|
38 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | + * @param array $options |
|
40 | + * |
|
41 | + * @return ISchemaWrapper |
|
42 | + */ |
|
43 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
44 | + /** @var ISchemaWrapper $schema */ |
|
45 | + $schema = $schemaClosure(); |
|
46 | + $table = $schema->getTable('twofactor_backupcodes'); |
|
47 | 47 | |
48 | - $table->getColumn('code')->setLength(128); |
|
48 | + $table->getColumn('code')->setLength(128); |
|
49 | 49 | |
50 | - return $schema; |
|
51 | - } |
|
50 | + return $schema; |
|
51 | + } |
|
52 | 52 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | public function getProperties(): array { |
69 | - return array_filter($this->properties, function ($obj) { |
|
69 | + return array_filter($this->properties, function($obj) { |
|
70 | 70 | return $obj instanceof IAccountProperty; |
71 | 71 | }); |
72 | 72 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $index = $obj->getName(); |
97 | 97 | if ($this->isCollection($index)) { |
98 | 98 | $incrementals[$index] = ($incrementals[$index] ?? -1) + 1; |
99 | - $index .= '#' . $incrementals[$index]; |
|
99 | + $index .= '#'.$incrementals[$index]; |
|
100 | 100 | } |
101 | 101 | $result[$index] = $obj; |
102 | 102 | } |
@@ -17,125 +17,125 @@ |
||
17 | 17 | use RuntimeException; |
18 | 18 | |
19 | 19 | class Account implements IAccount { |
20 | - use TAccountsHelper; |
|
21 | - |
|
22 | - /** @var IAccountPropertyCollection[]|IAccountProperty[] */ |
|
23 | - private array $properties = []; |
|
24 | - |
|
25 | - public function __construct( |
|
26 | - private IUser $user, |
|
27 | - ) { |
|
28 | - } |
|
29 | - |
|
30 | - public function setProperty(string $property, string $value, string $scope, string $verified, string $verificationData = ''): IAccount { |
|
31 | - if ($this->isCollection($property)) { |
|
32 | - throw new \InvalidArgumentException('setProperty cannot set an IAccountsPropertyCollection'); |
|
33 | - } |
|
34 | - $this->properties[$property] = new AccountProperty($property, $value, $scope, $verified, $verificationData); |
|
35 | - return $this; |
|
36 | - } |
|
37 | - |
|
38 | - public function getProperty(string $property): IAccountProperty { |
|
39 | - if ($this->isCollection($property)) { |
|
40 | - throw new \InvalidArgumentException('getProperty cannot retrieve an IAccountsPropertyCollection'); |
|
41 | - } |
|
42 | - if (!array_key_exists($property, $this->properties) || !$this->properties[$property] instanceof IAccountProperty) { |
|
43 | - throw new PropertyDoesNotExistException($property); |
|
44 | - } |
|
45 | - return $this->properties[$property]; |
|
46 | - } |
|
47 | - |
|
48 | - public function getProperties(): array { |
|
49 | - return array_filter($this->properties, function ($obj) { |
|
50 | - return $obj instanceof IAccountProperty; |
|
51 | - }); |
|
52 | - } |
|
53 | - |
|
54 | - public function setAllPropertiesFromJson(array $properties): IAccount { |
|
55 | - foreach ($properties as $propertyName => $propertyObject) { |
|
56 | - if ($this->isCollection($propertyName)) { |
|
57 | - $collection = new AccountPropertyCollection($propertyName); |
|
58 | - /** @var array<int, IAccountProperty> $collectionProperties */ |
|
59 | - $collectionProperties = []; |
|
60 | - /** @var array<int, array<string, string>> $propertyObject */ |
|
61 | - foreach ($propertyObject as ['value' => $value, 'scope' => $scope, 'verified' => $verified, 'verificationData' => $verificationData]) { |
|
62 | - $collectionProperties[] = new AccountProperty($collection->getName(), $value, $scope, $verified, $verificationData); |
|
63 | - } |
|
64 | - $collection->setProperties($collectionProperties); |
|
65 | - $this->setPropertyCollection($collection); |
|
66 | - } else { |
|
67 | - /** @var array<string, string> $propertyObject */ |
|
68 | - ['value' => $value, 'scope' => $scope, 'verified' => $verified, 'verificationData' => $verificationData] = $propertyObject; |
|
69 | - $this->setProperty($propertyName, $value, $scope, $verified, $verificationData); |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - return $this; |
|
74 | - } |
|
75 | - |
|
76 | - public function getAllProperties(): Generator { |
|
77 | - foreach ($this->properties as $propertyObject) { |
|
78 | - if ($propertyObject instanceof IAccountProperty) { |
|
79 | - yield $propertyObject; |
|
80 | - } elseif ($propertyObject instanceof IAccountPropertyCollection) { |
|
81 | - foreach ($propertyObject->getProperties() as $property) { |
|
82 | - yield $property; |
|
83 | - } |
|
84 | - } |
|
85 | - } |
|
86 | - } |
|
87 | - |
|
88 | - public function getFilteredProperties(?string $scope = null, ?string $verified = null): array { |
|
89 | - $result = $incrementals = []; |
|
90 | - /** @var IAccountProperty $obj */ |
|
91 | - foreach ($this->getAllProperties() as $obj) { |
|
92 | - if ($scope !== null && $scope !== $obj->getScope()) { |
|
93 | - continue; |
|
94 | - } |
|
95 | - if ($verified !== null && $verified !== $obj->getVerified()) { |
|
96 | - continue; |
|
97 | - } |
|
98 | - $index = $obj->getName(); |
|
99 | - if ($this->isCollection($index)) { |
|
100 | - $incrementals[$index] = ($incrementals[$index] ?? -1) + 1; |
|
101 | - $index .= '#' . $incrementals[$index]; |
|
102 | - } |
|
103 | - $result[$index] = $obj; |
|
104 | - } |
|
105 | - return $result; |
|
106 | - } |
|
107 | - |
|
108 | - /** @return array<string, IAccountProperty|array<int, IAccountProperty>> */ |
|
109 | - public function jsonSerialize(): array { |
|
110 | - $properties = $this->properties; |
|
111 | - foreach ($properties as $propertyName => $propertyObject) { |
|
112 | - if ($propertyObject instanceof IAccountPropertyCollection) { |
|
113 | - // Override collection serialization to discard duplicate name |
|
114 | - $properties[$propertyName] = $propertyObject->jsonSerialize()[$propertyName]; |
|
115 | - } |
|
116 | - } |
|
117 | - return $properties; |
|
118 | - } |
|
119 | - |
|
120 | - public function getUser(): IUser { |
|
121 | - return $this->user; |
|
122 | - } |
|
123 | - |
|
124 | - public function setPropertyCollection(IAccountPropertyCollection $propertyCollection): IAccount { |
|
125 | - $this->properties[$propertyCollection->getName()] = $propertyCollection; |
|
126 | - return $this; |
|
127 | - } |
|
128 | - |
|
129 | - public function getPropertyCollection(string $propertyCollectionName): IAccountPropertyCollection { |
|
130 | - if (!$this->isCollection($propertyCollectionName)) { |
|
131 | - throw new PropertyDoesNotExistException($propertyCollectionName); |
|
132 | - } |
|
133 | - if (!array_key_exists($propertyCollectionName, $this->properties)) { |
|
134 | - $this->properties[$propertyCollectionName] = new AccountPropertyCollection($propertyCollectionName); |
|
135 | - } |
|
136 | - if (!$this->properties[$propertyCollectionName] instanceof IAccountPropertyCollection) { |
|
137 | - throw new RuntimeException('Requested collection is not an IAccountPropertyCollection'); |
|
138 | - } |
|
139 | - return $this->properties[$propertyCollectionName]; |
|
140 | - } |
|
20 | + use TAccountsHelper; |
|
21 | + |
|
22 | + /** @var IAccountPropertyCollection[]|IAccountProperty[] */ |
|
23 | + private array $properties = []; |
|
24 | + |
|
25 | + public function __construct( |
|
26 | + private IUser $user, |
|
27 | + ) { |
|
28 | + } |
|
29 | + |
|
30 | + public function setProperty(string $property, string $value, string $scope, string $verified, string $verificationData = ''): IAccount { |
|
31 | + if ($this->isCollection($property)) { |
|
32 | + throw new \InvalidArgumentException('setProperty cannot set an IAccountsPropertyCollection'); |
|
33 | + } |
|
34 | + $this->properties[$property] = new AccountProperty($property, $value, $scope, $verified, $verificationData); |
|
35 | + return $this; |
|
36 | + } |
|
37 | + |
|
38 | + public function getProperty(string $property): IAccountProperty { |
|
39 | + if ($this->isCollection($property)) { |
|
40 | + throw new \InvalidArgumentException('getProperty cannot retrieve an IAccountsPropertyCollection'); |
|
41 | + } |
|
42 | + if (!array_key_exists($property, $this->properties) || !$this->properties[$property] instanceof IAccountProperty) { |
|
43 | + throw new PropertyDoesNotExistException($property); |
|
44 | + } |
|
45 | + return $this->properties[$property]; |
|
46 | + } |
|
47 | + |
|
48 | + public function getProperties(): array { |
|
49 | + return array_filter($this->properties, function ($obj) { |
|
50 | + return $obj instanceof IAccountProperty; |
|
51 | + }); |
|
52 | + } |
|
53 | + |
|
54 | + public function setAllPropertiesFromJson(array $properties): IAccount { |
|
55 | + foreach ($properties as $propertyName => $propertyObject) { |
|
56 | + if ($this->isCollection($propertyName)) { |
|
57 | + $collection = new AccountPropertyCollection($propertyName); |
|
58 | + /** @var array<int, IAccountProperty> $collectionProperties */ |
|
59 | + $collectionProperties = []; |
|
60 | + /** @var array<int, array<string, string>> $propertyObject */ |
|
61 | + foreach ($propertyObject as ['value' => $value, 'scope' => $scope, 'verified' => $verified, 'verificationData' => $verificationData]) { |
|
62 | + $collectionProperties[] = new AccountProperty($collection->getName(), $value, $scope, $verified, $verificationData); |
|
63 | + } |
|
64 | + $collection->setProperties($collectionProperties); |
|
65 | + $this->setPropertyCollection($collection); |
|
66 | + } else { |
|
67 | + /** @var array<string, string> $propertyObject */ |
|
68 | + ['value' => $value, 'scope' => $scope, 'verified' => $verified, 'verificationData' => $verificationData] = $propertyObject; |
|
69 | + $this->setProperty($propertyName, $value, $scope, $verified, $verificationData); |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + return $this; |
|
74 | + } |
|
75 | + |
|
76 | + public function getAllProperties(): Generator { |
|
77 | + foreach ($this->properties as $propertyObject) { |
|
78 | + if ($propertyObject instanceof IAccountProperty) { |
|
79 | + yield $propertyObject; |
|
80 | + } elseif ($propertyObject instanceof IAccountPropertyCollection) { |
|
81 | + foreach ($propertyObject->getProperties() as $property) { |
|
82 | + yield $property; |
|
83 | + } |
|
84 | + } |
|
85 | + } |
|
86 | + } |
|
87 | + |
|
88 | + public function getFilteredProperties(?string $scope = null, ?string $verified = null): array { |
|
89 | + $result = $incrementals = []; |
|
90 | + /** @var IAccountProperty $obj */ |
|
91 | + foreach ($this->getAllProperties() as $obj) { |
|
92 | + if ($scope !== null && $scope !== $obj->getScope()) { |
|
93 | + continue; |
|
94 | + } |
|
95 | + if ($verified !== null && $verified !== $obj->getVerified()) { |
|
96 | + continue; |
|
97 | + } |
|
98 | + $index = $obj->getName(); |
|
99 | + if ($this->isCollection($index)) { |
|
100 | + $incrementals[$index] = ($incrementals[$index] ?? -1) + 1; |
|
101 | + $index .= '#' . $incrementals[$index]; |
|
102 | + } |
|
103 | + $result[$index] = $obj; |
|
104 | + } |
|
105 | + return $result; |
|
106 | + } |
|
107 | + |
|
108 | + /** @return array<string, IAccountProperty|array<int, IAccountProperty>> */ |
|
109 | + public function jsonSerialize(): array { |
|
110 | + $properties = $this->properties; |
|
111 | + foreach ($properties as $propertyName => $propertyObject) { |
|
112 | + if ($propertyObject instanceof IAccountPropertyCollection) { |
|
113 | + // Override collection serialization to discard duplicate name |
|
114 | + $properties[$propertyName] = $propertyObject->jsonSerialize()[$propertyName]; |
|
115 | + } |
|
116 | + } |
|
117 | + return $properties; |
|
118 | + } |
|
119 | + |
|
120 | + public function getUser(): IUser { |
|
121 | + return $this->user; |
|
122 | + } |
|
123 | + |
|
124 | + public function setPropertyCollection(IAccountPropertyCollection $propertyCollection): IAccount { |
|
125 | + $this->properties[$propertyCollection->getName()] = $propertyCollection; |
|
126 | + return $this; |
|
127 | + } |
|
128 | + |
|
129 | + public function getPropertyCollection(string $propertyCollectionName): IAccountPropertyCollection { |
|
130 | + if (!$this->isCollection($propertyCollectionName)) { |
|
131 | + throw new PropertyDoesNotExistException($propertyCollectionName); |
|
132 | + } |
|
133 | + if (!array_key_exists($propertyCollectionName, $this->properties)) { |
|
134 | + $this->properties[$propertyCollectionName] = new AccountPropertyCollection($propertyCollectionName); |
|
135 | + } |
|
136 | + if (!$this->properties[$propertyCollectionName] instanceof IAccountPropertyCollection) { |
|
137 | + throw new RuntimeException('Requested collection is not an IAccountPropertyCollection'); |
|
138 | + } |
|
139 | + return $this->properties[$propertyCollectionName]; |
|
140 | + } |
|
141 | 141 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $user = $input->getArgument('uid'); |
97 | 97 | if (!$this->userManager->userExists($user)) { |
98 | 98 | throw new \InvalidArgumentException( |
99 | - 'User <' . $user . '> is unknown.'); |
|
99 | + 'User <'.$user.'> is unknown.'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $birthday = $input->getOption('birthday'); |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | $calendarInfo = $this->calDav->getCalendarByUri( |
115 | - 'principals/users/' . $user, |
|
115 | + 'principals/users/'.$user, |
|
116 | 116 | $name); |
117 | 117 | if ($calendarInfo === null) { |
118 | 118 | throw new \InvalidArgumentException( |
119 | - 'User <' . $user . '> has no calendar named <' . $name . '>. You can run occ dav:list-calendars to list calendars URIs for this user.'); |
|
119 | + 'User <'.$user.'> has no calendar named <'.$name.'>. You can run occ dav:list-calendars to list calendars URIs for this user.'); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | $calendar = new Calendar( |
@@ -22,82 +22,82 @@ |
||
22 | 22 | use Symfony\Component\Console\Output\OutputInterface; |
23 | 23 | |
24 | 24 | class DeleteCalendar extends Command { |
25 | - public function __construct( |
|
26 | - private CalDavBackend $calDav, |
|
27 | - private IConfig $config, |
|
28 | - private IL10N $l10n, |
|
29 | - private IUserManager $userManager, |
|
30 | - private LoggerInterface $logger, |
|
31 | - ) { |
|
32 | - parent::__construct(); |
|
33 | - } |
|
25 | + public function __construct( |
|
26 | + private CalDavBackend $calDav, |
|
27 | + private IConfig $config, |
|
28 | + private IL10N $l10n, |
|
29 | + private IUserManager $userManager, |
|
30 | + private LoggerInterface $logger, |
|
31 | + ) { |
|
32 | + parent::__construct(); |
|
33 | + } |
|
34 | 34 | |
35 | - protected function configure(): void { |
|
36 | - $this |
|
37 | - ->setName('dav:delete-calendar') |
|
38 | - ->setDescription('Delete a dav calendar') |
|
39 | - ->addArgument('uid', |
|
40 | - InputArgument::REQUIRED, |
|
41 | - 'User who owns the calendar') |
|
42 | - ->addArgument('name', |
|
43 | - InputArgument::OPTIONAL, |
|
44 | - 'Name of the calendar to delete') |
|
45 | - ->addOption('birthday', |
|
46 | - null, |
|
47 | - InputOption::VALUE_NONE, |
|
48 | - 'Delete the birthday calendar') |
|
49 | - ->addOption('force', |
|
50 | - 'f', |
|
51 | - InputOption::VALUE_NONE, |
|
52 | - 'Force delete skipping trashbin'); |
|
53 | - } |
|
35 | + protected function configure(): void { |
|
36 | + $this |
|
37 | + ->setName('dav:delete-calendar') |
|
38 | + ->setDescription('Delete a dav calendar') |
|
39 | + ->addArgument('uid', |
|
40 | + InputArgument::REQUIRED, |
|
41 | + 'User who owns the calendar') |
|
42 | + ->addArgument('name', |
|
43 | + InputArgument::OPTIONAL, |
|
44 | + 'Name of the calendar to delete') |
|
45 | + ->addOption('birthday', |
|
46 | + null, |
|
47 | + InputOption::VALUE_NONE, |
|
48 | + 'Delete the birthday calendar') |
|
49 | + ->addOption('force', |
|
50 | + 'f', |
|
51 | + InputOption::VALUE_NONE, |
|
52 | + 'Force delete skipping trashbin'); |
|
53 | + } |
|
54 | 54 | |
55 | - protected function execute( |
|
56 | - InputInterface $input, |
|
57 | - OutputInterface $output, |
|
58 | - ): int { |
|
59 | - /** @var string $user */ |
|
60 | - $user = $input->getArgument('uid'); |
|
61 | - if (!$this->userManager->userExists($user)) { |
|
62 | - throw new \InvalidArgumentException( |
|
63 | - 'User <' . $user . '> is unknown.'); |
|
64 | - } |
|
55 | + protected function execute( |
|
56 | + InputInterface $input, |
|
57 | + OutputInterface $output, |
|
58 | + ): int { |
|
59 | + /** @var string $user */ |
|
60 | + $user = $input->getArgument('uid'); |
|
61 | + if (!$this->userManager->userExists($user)) { |
|
62 | + throw new \InvalidArgumentException( |
|
63 | + 'User <' . $user . '> is unknown.'); |
|
64 | + } |
|
65 | 65 | |
66 | - $birthday = $input->getOption('birthday'); |
|
67 | - if ($birthday !== false) { |
|
68 | - $name = BirthdayService::BIRTHDAY_CALENDAR_URI; |
|
69 | - } else { |
|
70 | - /** @var string $name */ |
|
71 | - $name = $input->getArgument('name'); |
|
72 | - if (!$name) { |
|
73 | - throw new \InvalidArgumentException( |
|
74 | - 'Please specify a calendar name or --birthday'); |
|
75 | - } |
|
76 | - } |
|
66 | + $birthday = $input->getOption('birthday'); |
|
67 | + if ($birthday !== false) { |
|
68 | + $name = BirthdayService::BIRTHDAY_CALENDAR_URI; |
|
69 | + } else { |
|
70 | + /** @var string $name */ |
|
71 | + $name = $input->getArgument('name'); |
|
72 | + if (!$name) { |
|
73 | + throw new \InvalidArgumentException( |
|
74 | + 'Please specify a calendar name or --birthday'); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | - $calendarInfo = $this->calDav->getCalendarByUri( |
|
79 | - 'principals/users/' . $user, |
|
80 | - $name); |
|
81 | - if ($calendarInfo === null) { |
|
82 | - throw new \InvalidArgumentException( |
|
83 | - 'User <' . $user . '> has no calendar named <' . $name . '>. You can run occ dav:list-calendars to list calendars URIs for this user.'); |
|
84 | - } |
|
78 | + $calendarInfo = $this->calDav->getCalendarByUri( |
|
79 | + 'principals/users/' . $user, |
|
80 | + $name); |
|
81 | + if ($calendarInfo === null) { |
|
82 | + throw new \InvalidArgumentException( |
|
83 | + 'User <' . $user . '> has no calendar named <' . $name . '>. You can run occ dav:list-calendars to list calendars URIs for this user.'); |
|
84 | + } |
|
85 | 85 | |
86 | - $calendar = new Calendar( |
|
87 | - $this->calDav, |
|
88 | - $calendarInfo, |
|
89 | - $this->l10n, |
|
90 | - $this->config, |
|
91 | - $this->logger |
|
92 | - ); |
|
86 | + $calendar = new Calendar( |
|
87 | + $this->calDav, |
|
88 | + $calendarInfo, |
|
89 | + $this->l10n, |
|
90 | + $this->config, |
|
91 | + $this->logger |
|
92 | + ); |
|
93 | 93 | |
94 | - $force = $input->getOption('force'); |
|
95 | - if ($force) { |
|
96 | - $calendar->disableTrashbin(); |
|
97 | - } |
|
94 | + $force = $input->getOption('force'); |
|
95 | + if ($force) { |
|
96 | + $calendar->disableTrashbin(); |
|
97 | + } |
|
98 | 98 | |
99 | - $calendar->delete(); |
|
99 | + $calendar->delete(); |
|
100 | 100 | |
101 | - return self::SUCCESS; |
|
102 | - } |
|
101 | + return self::SUCCESS; |
|
102 | + } |
|
103 | 103 | } |