| Conditions | 41 |
| Paths | 1 |
| Total Lines | 207 |
| Code Lines | 110 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 60 | public function __construct() { |
||
| 61 | parent::__construct('core'); |
||
| 62 | |||
| 63 | $container = $this->getContainer(); |
||
| 64 | |||
| 65 | $container->registerService('defaultMailAddress', function () { |
||
| 66 | return Util::getDefaultEmailAddress('lostpassword-noreply'); |
||
| 67 | }); |
||
| 68 | |||
| 69 | $server = $container->getServer(); |
||
| 70 | /** @var IEventDispatcher $eventDispatcher */ |
||
| 71 | $eventDispatcher = $server->query(IEventDispatcher::class); |
||
| 72 | |||
| 73 | $notificationManager = $server->getNotificationManager(); |
||
| 74 | $notificationManager->registerNotifierService(RemoveLinkSharesNotifier::class); |
||
| 75 | $notificationManager->registerNotifierService(AuthenticationNotifier::class); |
||
| 76 | |||
| 77 | $oldEventDispatcher = $server->getEventDispatcher(); |
||
| 78 | |||
| 79 | $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT, |
||
| 80 | function (GenericEvent $event) use ($container) { |
||
| 81 | /** @var MissingIndexInformation $subject */ |
||
| 82 | $subject = $event->getSubject(); |
||
| 83 | |||
| 84 | $schema = new SchemaWrapper($container->query(IDBConnection::class)); |
||
| 85 | |||
| 86 | if ($schema->hasTable('share')) { |
||
| 87 | $table = $schema->getTable('share'); |
||
| 88 | |||
| 89 | if (!$table->hasIndex('share_with_index')) { |
||
| 90 | $subject->addHintForMissingSubject($table->getName(), 'share_with_index'); |
||
| 91 | } |
||
| 92 | if (!$table->hasIndex('parent_index')) { |
||
| 93 | $subject->addHintForMissingSubject($table->getName(), 'parent_index'); |
||
| 94 | } |
||
| 95 | if (!$table->hasIndex('owner_index')) { |
||
| 96 | $subject->addHintForMissingSubject($table->getName(), 'owner_index'); |
||
| 97 | } |
||
| 98 | if (!$table->hasIndex('initiator_index')) { |
||
| 99 | $subject->addHintForMissingSubject($table->getName(), 'initiator_index'); |
||
| 100 | } |
||
| 101 | } |
||
| 102 | |||
| 103 | if ($schema->hasTable('filecache')) { |
||
| 104 | $table = $schema->getTable('filecache'); |
||
| 105 | |||
| 106 | if (!$table->hasIndex('fs_mtime')) { |
||
| 107 | $subject->addHintForMissingSubject($table->getName(), 'fs_mtime'); |
||
| 108 | } |
||
| 109 | |||
| 110 | if (!$table->hasIndex('fs_size')) { |
||
| 111 | $subject->addHintForMissingSubject($table->getName(), 'fs_size'); |
||
| 112 | } |
||
| 113 | } |
||
| 114 | |||
| 115 | if ($schema->hasTable('twofactor_providers')) { |
||
| 116 | $table = $schema->getTable('twofactor_providers'); |
||
| 117 | |||
| 118 | if (!$table->hasIndex('twofactor_providers_uid')) { |
||
| 119 | $subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid'); |
||
| 120 | } |
||
| 121 | } |
||
| 122 | |||
| 123 | if ($schema->hasTable('login_flow_v2')) { |
||
| 124 | $table = $schema->getTable('login_flow_v2'); |
||
| 125 | |||
| 126 | if (!$table->hasIndex('poll_token')) { |
||
| 127 | $subject->addHintForMissingSubject($table->getName(), 'poll_token'); |
||
| 128 | } |
||
| 129 | if (!$table->hasIndex('login_token')) { |
||
| 130 | $subject->addHintForMissingSubject($table->getName(), 'login_token'); |
||
| 131 | } |
||
| 132 | if (!$table->hasIndex('timestamp')) { |
||
| 133 | $subject->addHintForMissingSubject($table->getName(), 'timestamp'); |
||
| 134 | } |
||
| 135 | } |
||
| 136 | |||
| 137 | if ($schema->hasTable('whats_new')) { |
||
| 138 | $table = $schema->getTable('whats_new'); |
||
| 139 | |||
| 140 | if (!$table->hasIndex('version')) { |
||
| 141 | $subject->addHintForMissingSubject($table->getName(), 'version'); |
||
| 142 | } |
||
| 143 | } |
||
| 144 | |||
| 145 | if ($schema->hasTable('cards')) { |
||
| 146 | $table = $schema->getTable('cards'); |
||
| 147 | |||
| 148 | if (!$table->hasIndex('cards_abid')) { |
||
| 149 | $subject->addHintForMissingSubject($table->getName(), 'cards_abid'); |
||
| 150 | } |
||
| 151 | } |
||
| 152 | |||
| 153 | if ($schema->hasTable('cards_properties')) { |
||
| 154 | $table = $schema->getTable('cards_properties'); |
||
| 155 | |||
| 156 | if (!$table->hasIndex('cards_prop_abid')) { |
||
| 157 | $subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid'); |
||
| 158 | } |
||
| 159 | } |
||
| 160 | |||
| 161 | if ($schema->hasTable('calendarobjects_props')) { |
||
| 162 | $table = $schema->getTable('calendarobjects_props'); |
||
| 163 | |||
| 164 | if (!$table->hasIndex('calendarobject_calid_index')) { |
||
| 165 | $subject->addHintForMissingSubject($table->getName(), 'calendarobject_calid_index'); |
||
| 166 | } |
||
| 167 | } |
||
| 168 | |||
| 169 | if ($schema->hasTable('schedulingobjects')) { |
||
| 170 | $table = $schema->getTable('schedulingobjects'); |
||
| 171 | if (!$table->hasIndex('schedulobj_principuri_index')) { |
||
| 172 | $subject->addHintForMissingSubject($table->getName(), 'schedulobj_principuri_index'); |
||
| 173 | } |
||
| 174 | } |
||
| 175 | |||
| 176 | if ($schema->hasTable('properties')) { |
||
| 177 | $table = $schema->getTable('properties'); |
||
| 178 | if (!$table->hasIndex('properties_path_index')) { |
||
| 179 | $subject->addHintForMissingSubject($table->getName(), 'properties_path_index'); |
||
| 180 | } |
||
| 181 | } |
||
| 182 | } |
||
| 183 | ); |
||
| 184 | |||
| 185 | $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT, |
||
| 186 | function (GenericEvent $event) use ($container) { |
||
| 187 | /** @var MissingPrimaryKeyInformation $subject */ |
||
| 188 | $subject = $event->getSubject(); |
||
| 189 | |||
| 190 | $schema = new SchemaWrapper($container->query(IDBConnection::class)); |
||
| 191 | |||
| 192 | if ($schema->hasTable('federated_reshares')) { |
||
| 193 | $table = $schema->getTable('federated_reshares'); |
||
| 194 | |||
| 195 | if (!$table->hasPrimaryKey()) { |
||
| 196 | $subject->addHintForMissingSubject($table->getName()); |
||
| 197 | } |
||
| 198 | } |
||
| 199 | |||
| 200 | if ($schema->hasTable('systemtag_object_mapping')) { |
||
| 201 | $table = $schema->getTable('systemtag_object_mapping'); |
||
| 202 | |||
| 203 | if (!$table->hasPrimaryKey()) { |
||
| 204 | $subject->addHintForMissingSubject($table->getName()); |
||
| 205 | } |
||
| 206 | } |
||
| 207 | |||
| 208 | if ($schema->hasTable('comments_read_markers')) { |
||
| 209 | $table = $schema->getTable('comments_read_markers'); |
||
| 210 | |||
| 211 | if (!$table->hasPrimaryKey()) { |
||
| 212 | $subject->addHintForMissingSubject($table->getName()); |
||
| 213 | } |
||
| 214 | } |
||
| 215 | |||
| 216 | if ($schema->hasTable('collres_resources')) { |
||
| 217 | $table = $schema->getTable('collres_resources'); |
||
| 218 | |||
| 219 | if (!$table->hasPrimaryKey()) { |
||
| 220 | $subject->addHintForMissingSubject($table->getName()); |
||
| 221 | } |
||
| 222 | } |
||
| 223 | |||
| 224 | if ($schema->hasTable('collres_accesscache')) { |
||
| 225 | $table = $schema->getTable('collres_accesscache'); |
||
| 226 | |||
| 227 | if (!$table->hasPrimaryKey()) { |
||
| 228 | $subject->addHintForMissingSubject($table->getName()); |
||
| 229 | } |
||
| 230 | } |
||
| 231 | |||
| 232 | if ($schema->hasTable('filecache_extended')) { |
||
| 233 | $table = $schema->getTable('filecache_extended'); |
||
| 234 | |||
| 235 | if (!$table->hasPrimaryKey()) { |
||
| 236 | $subject->addHintForMissingSubject($table->getName()); |
||
| 237 | } |
||
| 238 | } |
||
| 239 | } |
||
| 240 | ); |
||
| 241 | |||
| 242 | $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, |
||
| 243 | function (GenericEvent $event) use ($container) { |
||
| 244 | /** @var MissingColumnInformation $subject */ |
||
| 245 | $subject = $event->getSubject(); |
||
| 246 | |||
| 247 | $schema = new SchemaWrapper($container->query(IDBConnection::class)); |
||
| 248 | |||
| 249 | if ($schema->hasTable('comments')) { |
||
| 250 | $table = $schema->getTable('comments'); |
||
| 251 | |||
| 252 | if (!$table->hasColumn('reference_id')) { |
||
| 253 | $subject->addHintForMissingColumn($table->getName(), 'reference_id'); |
||
| 254 | } |
||
| 255 | } |
||
| 256 | } |
||
| 257 | ); |
||
| 258 | |||
| 259 | $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeActivityListener::class); |
||
| 260 | $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeNotificationsListener::class); |
||
| 261 | $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeEmailListener::class); |
||
| 262 | $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeActivityListener::class); |
||
| 263 | $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeNotificationsListener::class); |
||
| 264 | $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeEmailListener::class); |
||
| 265 | $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedStoreCleanupListener::class); |
||
| 266 | $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedTokenCleanupListener::class); |
||
| 267 | } |
||
| 269 |