| Conditions | 42 |
| Paths | 1 |
| Total Lines | 211 |
| Code Lines | 112 |
| 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 | |||
| 117 | if ($schema->hasTable('twofactor_providers')) { |
||
| 118 | $table = $schema->getTable('twofactor_providers'); |
||
| 119 | |||
| 120 | if (!$table->hasIndex('twofactor_providers_uid')) { |
||
| 121 | $subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid'); |
||
| 122 | } |
||
| 123 | } |
||
| 124 | |||
| 125 | if ($schema->hasTable('login_flow_v2')) { |
||
| 126 | $table = $schema->getTable('login_flow_v2'); |
||
| 127 | |||
| 128 | if (!$table->hasIndex('poll_token')) { |
||
| 129 | $subject->addHintForMissingSubject($table->getName(), 'poll_token'); |
||
| 130 | } |
||
| 131 | if (!$table->hasIndex('login_token')) { |
||
| 132 | $subject->addHintForMissingSubject($table->getName(), 'login_token'); |
||
| 133 | } |
||
| 134 | if (!$table->hasIndex('timestamp')) { |
||
| 135 | $subject->addHintForMissingSubject($table->getName(), 'timestamp'); |
||
| 136 | } |
||
| 137 | } |
||
| 138 | |||
| 139 | if ($schema->hasTable('whats_new')) { |
||
| 140 | $table = $schema->getTable('whats_new'); |
||
| 141 | |||
| 142 | if (!$table->hasIndex('version')) { |
||
| 143 | $subject->addHintForMissingSubject($table->getName(), 'version'); |
||
| 144 | } |
||
| 145 | } |
||
| 146 | |||
| 147 | if ($schema->hasTable('cards')) { |
||
| 148 | $table = $schema->getTable('cards'); |
||
| 149 | |||
| 150 | if (!$table->hasIndex('cards_abid')) { |
||
| 151 | $subject->addHintForMissingSubject($table->getName(), 'cards_abid'); |
||
| 152 | } |
||
| 153 | |||
| 154 | if (!$table->hasIndex('cards_abiduri')) { |
||
| 155 | $subject->addHintForMissingSubject($table->getName(), 'cards_abiduri'); |
||
| 156 | } |
||
| 157 | } |
||
| 158 | |||
| 159 | if ($schema->hasTable('cards_properties')) { |
||
| 160 | $table = $schema->getTable('cards_properties'); |
||
| 161 | |||
| 162 | if (!$table->hasIndex('cards_prop_abid')) { |
||
| 163 | $subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid'); |
||
| 164 | } |
||
| 165 | } |
||
| 166 | |||
| 167 | if ($schema->hasTable('calendarobjects_props')) { |
||
| 168 | $table = $schema->getTable('calendarobjects_props'); |
||
| 169 | |||
| 170 | if (!$table->hasIndex('calendarobject_calid_index')) { |
||
| 171 | $subject->addHintForMissingSubject($table->getName(), 'calendarobject_calid_index'); |
||
| 172 | } |
||
| 173 | } |
||
| 174 | |||
| 175 | if ($schema->hasTable('schedulingobjects')) { |
||
| 176 | $table = $schema->getTable('schedulingobjects'); |
||
| 177 | if (!$table->hasIndex('schedulobj_principuri_index')) { |
||
| 178 | $subject->addHintForMissingSubject($table->getName(), 'schedulobj_principuri_index'); |
||
| 179 | } |
||
| 180 | } |
||
| 181 | |||
| 182 | if ($schema->hasTable('properties')) { |
||
| 183 | $table = $schema->getTable('properties'); |
||
| 184 | if (!$table->hasIndex('properties_path_index')) { |
||
| 185 | $subject->addHintForMissingSubject($table->getName(), 'properties_path_index'); |
||
| 186 | } |
||
| 187 | } |
||
| 188 | } |
||
| 189 | ); |
||
| 190 | |||
| 191 | $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT, |
||
| 192 | function (GenericEvent $event) use ($container) { |
||
| 193 | /** @var MissingPrimaryKeyInformation $subject */ |
||
| 194 | $subject = $event->getSubject(); |
||
| 195 | |||
| 196 | $schema = new SchemaWrapper($container->query(Connection::class)); |
||
| 197 | |||
| 198 | if ($schema->hasTable('federated_reshares')) { |
||
| 199 | $table = $schema->getTable('federated_reshares'); |
||
| 200 | |||
| 201 | if (!$table->hasPrimaryKey()) { |
||
| 202 | $subject->addHintForMissingSubject($table->getName()); |
||
| 203 | } |
||
| 204 | } |
||
| 205 | |||
| 206 | if ($schema->hasTable('systemtag_object_mapping')) { |
||
| 207 | $table = $schema->getTable('systemtag_object_mapping'); |
||
| 208 | |||
| 209 | if (!$table->hasPrimaryKey()) { |
||
| 210 | $subject->addHintForMissingSubject($table->getName()); |
||
| 211 | } |
||
| 212 | } |
||
| 213 | |||
| 214 | if ($schema->hasTable('comments_read_markers')) { |
||
| 215 | $table = $schema->getTable('comments_read_markers'); |
||
| 216 | |||
| 217 | if (!$table->hasPrimaryKey()) { |
||
| 218 | $subject->addHintForMissingSubject($table->getName()); |
||
| 219 | } |
||
| 220 | } |
||
| 221 | |||
| 222 | if ($schema->hasTable('collres_resources')) { |
||
| 223 | $table = $schema->getTable('collres_resources'); |
||
| 224 | |||
| 225 | if (!$table->hasPrimaryKey()) { |
||
| 226 | $subject->addHintForMissingSubject($table->getName()); |
||
| 227 | } |
||
| 228 | } |
||
| 229 | |||
| 230 | if ($schema->hasTable('collres_accesscache')) { |
||
| 231 | $table = $schema->getTable('collres_accesscache'); |
||
| 232 | |||
| 233 | if (!$table->hasPrimaryKey()) { |
||
| 234 | $subject->addHintForMissingSubject($table->getName()); |
||
| 235 | } |
||
| 236 | } |
||
| 237 | |||
| 238 | if ($schema->hasTable('filecache_extended')) { |
||
| 239 | $table = $schema->getTable('filecache_extended'); |
||
| 240 | |||
| 241 | if (!$table->hasPrimaryKey()) { |
||
| 242 | $subject->addHintForMissingSubject($table->getName()); |
||
| 243 | } |
||
| 244 | } |
||
| 245 | } |
||
| 246 | ); |
||
| 247 | |||
| 248 | $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, |
||
| 249 | function (GenericEvent $event) use ($container) { |
||
| 250 | /** @var MissingColumnInformation $subject */ |
||
| 251 | $subject = $event->getSubject(); |
||
| 252 | |||
| 253 | $schema = new SchemaWrapper($container->query(Connection::class)); |
||
| 254 | |||
| 255 | if ($schema->hasTable('comments')) { |
||
| 256 | $table = $schema->getTable('comments'); |
||
| 257 | |||
| 258 | if (!$table->hasColumn('reference_id')) { |
||
| 259 | $subject->addHintForMissingColumn($table->getName(), 'reference_id'); |
||
| 260 | } |
||
| 261 | } |
||
| 262 | } |
||
| 263 | ); |
||
| 264 | |||
| 265 | $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeActivityListener::class); |
||
| 266 | $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeNotificationsListener::class); |
||
| 267 | $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeEmailListener::class); |
||
| 268 | $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeActivityListener::class); |
||
| 269 | $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeNotificationsListener::class); |
||
| 270 | $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeEmailListener::class); |
||
| 271 | $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedStoreCleanupListener::class); |
||
| 272 | $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedTokenCleanupListener::class); |
||
| 273 | } |
||
| 275 |
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.