| Conditions | 43 |
| Paths | 1 |
| Total Lines | 215 |
| Code Lines | 114 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 62 | public function __construct() { |
||
| 63 | parent::__construct('core'); |
||
| 64 | |||
| 65 | $container = $this->getContainer(); |
||
| 66 | |||
| 67 | $container->registerService('defaultMailAddress', function () { |
||
| 68 | return Util::getDefaultEmailAddress('lostpassword-noreply'); |
||
| 69 | }); |
||
| 70 | |||
| 71 | $server = $container->getServer(); |
||
| 72 | /** @var IEventDispatcher $eventDispatcher */ |
||
| 73 | $eventDispatcher = $server->query(IEventDispatcher::class); |
||
| 74 | |||
| 75 | $notificationManager = $server->getNotificationManager(); |
||
| 76 | $notificationManager->registerNotifierService(CoreNotifier::class); |
||
| 77 | $notificationManager->registerNotifierService(AuthenticationNotifier::class); |
||
| 78 | |||
| 79 | $oldEventDispatcher = $server->getEventDispatcher(); |
||
| 80 | |||
| 81 | $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT, |
||
|
|
|||
| 82 | function (GenericEvent $event) use ($container) { |
||
| 83 | /** @var MissingIndexInformation $subject */ |
||
| 84 | $subject = $event->getSubject(); |
||
| 85 | |||
| 86 | $schema = new SchemaWrapper($container->query(Connection::class)); |
||
| 87 | |||
| 88 | if ($schema->hasTable('share')) { |
||
| 89 | $table = $schema->getTable('share'); |
||
| 90 | |||
| 91 | if (!$table->hasIndex('share_with_index')) { |
||
| 92 | $subject->addHintForMissingSubject($table->getName(), 'share_with_index'); |
||
| 93 | } |
||
| 94 | if (!$table->hasIndex('parent_index')) { |
||
| 95 | $subject->addHintForMissingSubject($table->getName(), 'parent_index'); |
||
| 96 | } |
||
| 97 | if (!$table->hasIndex('owner_index')) { |
||
| 98 | $subject->addHintForMissingSubject($table->getName(), 'owner_index'); |
||
| 99 | } |
||
| 100 | if (!$table->hasIndex('initiator_index')) { |
||
| 101 | $subject->addHintForMissingSubject($table->getName(), 'initiator_index'); |
||
| 102 | } |
||
| 103 | } |
||
| 104 | |||
| 105 | if ($schema->hasTable('filecache')) { |
||
| 106 | $table = $schema->getTable('filecache'); |
||
| 107 | |||
| 108 | if (!$table->hasIndex('fs_mtime')) { |
||
| 109 | $subject->addHintForMissingSubject($table->getName(), 'fs_mtime'); |
||
| 110 | } |
||
| 111 | |||
| 112 | if (!$table->hasIndex('fs_size')) { |
||
| 113 | $subject->addHintForMissingSubject($table->getName(), 'fs_size'); |
||
| 114 | } |
||
| 115 | |||
| 116 | if (!$table->hasIndex('fs_path_prefix')) { |
||
| 117 | $subject->addHintForMissingSubject($table->getName(), 'fs_path_prefix'); |
||
| 118 | } |
||
| 119 | } |
||
| 120 | |||
| 121 | if ($schema->hasTable('twofactor_providers')) { |
||
| 122 | $table = $schema->getTable('twofactor_providers'); |
||
| 123 | |||
| 124 | if (!$table->hasIndex('twofactor_providers_uid')) { |
||
| 125 | $subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid'); |
||
| 126 | } |
||
| 127 | } |
||
| 128 | |||
| 129 | if ($schema->hasTable('login_flow_v2')) { |
||
| 130 | $table = $schema->getTable('login_flow_v2'); |
||
| 131 | |||
| 132 | if (!$table->hasIndex('poll_token')) { |
||
| 133 | $subject->addHintForMissingSubject($table->getName(), 'poll_token'); |
||
| 134 | } |
||
| 135 | if (!$table->hasIndex('login_token')) { |
||
| 136 | $subject->addHintForMissingSubject($table->getName(), 'login_token'); |
||
| 137 | } |
||
| 138 | if (!$table->hasIndex('timestamp')) { |
||
| 139 | $subject->addHintForMissingSubject($table->getName(), 'timestamp'); |
||
| 140 | } |
||
| 141 | } |
||
| 142 | |||
| 143 | if ($schema->hasTable('whats_new')) { |
||
| 144 | $table = $schema->getTable('whats_new'); |
||
| 145 | |||
| 146 | if (!$table->hasIndex('version')) { |
||
| 147 | $subject->addHintForMissingSubject($table->getName(), 'version'); |
||
| 148 | } |
||
| 149 | } |
||
| 150 | |||
| 151 | if ($schema->hasTable('cards')) { |
||
| 152 | $table = $schema->getTable('cards'); |
||
| 153 | |||
| 154 | if (!$table->hasIndex('cards_abid')) { |
||
| 155 | $subject->addHintForMissingSubject($table->getName(), 'cards_abid'); |
||
| 156 | } |
||
| 157 | |||
| 158 | if (!$table->hasIndex('cards_abiduri')) { |
||
| 159 | $subject->addHintForMissingSubject($table->getName(), 'cards_abiduri'); |
||
| 160 | } |
||
| 161 | } |
||
| 162 | |||
| 163 | if ($schema->hasTable('cards_properties')) { |
||
| 164 | $table = $schema->getTable('cards_properties'); |
||
| 165 | |||
| 166 | if (!$table->hasIndex('cards_prop_abid')) { |
||
| 167 | $subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid'); |
||
| 168 | } |
||
| 169 | } |
||
| 170 | |||
| 171 | if ($schema->hasTable('calendarobjects_props')) { |
||
| 172 | $table = $schema->getTable('calendarobjects_props'); |
||
| 173 | |||
| 174 | if (!$table->hasIndex('calendarobject_calid_index')) { |
||
| 175 | $subject->addHintForMissingSubject($table->getName(), 'calendarobject_calid_index'); |
||
| 176 | } |
||
| 177 | } |
||
| 178 | |||
| 179 | if ($schema->hasTable('schedulingobjects')) { |
||
| 180 | $table = $schema->getTable('schedulingobjects'); |
||
| 181 | if (!$table->hasIndex('schedulobj_principuri_index')) { |
||
| 182 | $subject->addHintForMissingSubject($table->getName(), 'schedulobj_principuri_index'); |
||
| 183 | } |
||
| 184 | } |
||
| 185 | |||
| 186 | if ($schema->hasTable('properties')) { |
||
| 187 | $table = $schema->getTable('properties'); |
||
| 188 | if (!$table->hasIndex('properties_path_index')) { |
||
| 189 | $subject->addHintForMissingSubject($table->getName(), 'properties_path_index'); |
||
| 190 | } |
||
| 191 | } |
||
| 192 | } |
||
| 193 | ); |
||
| 194 | |||
| 195 | $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT, |
||
| 196 | function (GenericEvent $event) use ($container) { |
||
| 197 | /** @var MissingPrimaryKeyInformation $subject */ |
||
| 198 | $subject = $event->getSubject(); |
||
| 199 | |||
| 200 | $schema = new SchemaWrapper($container->query(Connection::class)); |
||
| 201 | |||
| 202 | if ($schema->hasTable('federated_reshares')) { |
||
| 203 | $table = $schema->getTable('federated_reshares'); |
||
| 204 | |||
| 205 | if (!$table->hasPrimaryKey()) { |
||
| 206 | $subject->addHintForMissingSubject($table->getName()); |
||
| 207 | } |
||
| 208 | } |
||
| 209 | |||
| 210 | if ($schema->hasTable('systemtag_object_mapping')) { |
||
| 211 | $table = $schema->getTable('systemtag_object_mapping'); |
||
| 212 | |||
| 213 | if (!$table->hasPrimaryKey()) { |
||
| 214 | $subject->addHintForMissingSubject($table->getName()); |
||
| 215 | } |
||
| 216 | } |
||
| 217 | |||
| 218 | if ($schema->hasTable('comments_read_markers')) { |
||
| 219 | $table = $schema->getTable('comments_read_markers'); |
||
| 220 | |||
| 221 | if (!$table->hasPrimaryKey()) { |
||
| 222 | $subject->addHintForMissingSubject($table->getName()); |
||
| 223 | } |
||
| 224 | } |
||
| 225 | |||
| 226 | if ($schema->hasTable('collres_resources')) { |
||
| 227 | $table = $schema->getTable('collres_resources'); |
||
| 228 | |||
| 229 | if (!$table->hasPrimaryKey()) { |
||
| 230 | $subject->addHintForMissingSubject($table->getName()); |
||
| 231 | } |
||
| 232 | } |
||
| 233 | |||
| 234 | if ($schema->hasTable('collres_accesscache')) { |
||
| 235 | $table = $schema->getTable('collres_accesscache'); |
||
| 236 | |||
| 237 | if (!$table->hasPrimaryKey()) { |
||
| 238 | $subject->addHintForMissingSubject($table->getName()); |
||
| 239 | } |
||
| 240 | } |
||
| 241 | |||
| 242 | if ($schema->hasTable('filecache_extended')) { |
||
| 243 | $table = $schema->getTable('filecache_extended'); |
||
| 244 | |||
| 245 | if (!$table->hasPrimaryKey()) { |
||
| 246 | $subject->addHintForMissingSubject($table->getName()); |
||
| 247 | } |
||
| 248 | } |
||
| 249 | } |
||
| 250 | ); |
||
| 251 | |||
| 252 | $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, |
||
| 253 | function (GenericEvent $event) use ($container) { |
||
| 254 | /** @var MissingColumnInformation $subject */ |
||
| 255 | $subject = $event->getSubject(); |
||
| 256 | |||
| 257 | $schema = new SchemaWrapper($container->query(Connection::class)); |
||
| 258 | |||
| 259 | if ($schema->hasTable('comments')) { |
||
| 260 | $table = $schema->getTable('comments'); |
||
| 261 | |||
| 262 | if (!$table->hasColumn('reference_id')) { |
||
| 263 | $subject->addHintForMissingColumn($table->getName(), 'reference_id'); |
||
| 264 | } |
||
| 265 | } |
||
| 266 | } |
||
| 267 | ); |
||
| 268 | |||
| 269 | $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeActivityListener::class); |
||
| 270 | $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeNotificationsListener::class); |
||
| 271 | $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeEmailListener::class); |
||
| 272 | $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeActivityListener::class); |
||
| 273 | $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeNotificationsListener::class); |
||
| 274 | $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeEmailListener::class); |
||
| 275 | $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedStoreCleanupListener::class); |
||
| 276 | $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedTokenCleanupListener::class); |
||
| 277 | } |
||
| 279 |
This class constant has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.