@@ -30,24 +30,24 @@ |
||
| 30 | 30 | * @template T |
| 31 | 31 | */ |
| 32 | 32 | class ServiceRegistration extends ARegistration { |
| 33 | - /** |
|
| 34 | - * @var string |
|
| 35 | - * @psalm-var class-string<T> |
|
| 36 | - */ |
|
| 37 | - private $service; |
|
| 33 | + /** |
|
| 34 | + * @var string |
|
| 35 | + * @psalm-var class-string<T> |
|
| 36 | + */ |
|
| 37 | + private $service; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @psalm-param class-string<T> $service |
|
| 41 | - */ |
|
| 42 | - public function __construct(string $appId, string $service) { |
|
| 43 | - parent::__construct($appId); |
|
| 44 | - $this->service = $service; |
|
| 45 | - } |
|
| 39 | + /** |
|
| 40 | + * @psalm-param class-string<T> $service |
|
| 41 | + */ |
|
| 42 | + public function __construct(string $appId, string $service) { |
|
| 43 | + parent::__construct($appId); |
|
| 44 | + $this->service = $service; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @psalm-return class-string<T> |
|
| 49 | - */ |
|
| 50 | - public function getService(): string { |
|
| 51 | - return $this->service; |
|
| 52 | - } |
|
| 47 | + /** |
|
| 48 | + * @psalm-return class-string<T> |
|
| 49 | + */ |
|
| 50 | + public function getService(): string { |
|
| 51 | + return $this->service; |
|
| 52 | + } |
|
| 53 | 53 | } |
@@ -29,14 +29,14 @@ |
||
| 29 | 29 | use OCP\Files\FileInfo; |
| 30 | 30 | |
| 31 | 31 | class WebP extends Image { |
| 32 | - /** |
|
| 33 | - * {@inheritDoc} |
|
| 34 | - */ |
|
| 35 | - public function getMimeType(): string { |
|
| 36 | - return '/image\/webp/'; |
|
| 37 | - } |
|
| 32 | + /** |
|
| 33 | + * {@inheritDoc} |
|
| 34 | + */ |
|
| 35 | + public function getMimeType(): string { |
|
| 36 | + return '/image\/webp/'; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public function isAvailable(FileInfo $file): bool { |
|
| 40 | - return (bool)(imagetypes() & IMG_WEBP); |
|
| 41 | - } |
|
| 39 | + public function isAvailable(FileInfo $file): bool { |
|
| 40 | + return (bool)(imagetypes() & IMG_WEBP); |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -37,6 +37,6 @@ |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function isAvailable(FileInfo $file): bool { |
| 40 | - return (bool)(imagetypes() & IMG_WEBP); |
|
| 40 | + return (bool) (imagetypes() & IMG_WEBP); |
|
| 41 | 41 | } |
| 42 | 42 | } |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - throw new \Exception('Could not load ' . $className, 0, $e); |
|
| 264 | + throw new \Exception('Could not load '.$className, 0, $e); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | |
@@ -271,10 +271,10 @@ discard block |
||
| 271 | 271 | * @throws \Exception |
| 272 | 272 | */ |
| 273 | 273 | private function loadSabrePluginsFromInfoXml(array $classes): array { |
| 274 | - return array_map(function (string $className): ServerPlugin { |
|
| 274 | + return array_map(function(string $className): ServerPlugin { |
|
| 275 | 275 | $instance = $this->createClass($className); |
| 276 | 276 | if (!($instance instanceof ServerPlugin)) { |
| 277 | - throw new \Exception('Sabre server plugin ' . $className . ' does not implement the ' . ServerPlugin::class . ' interface'); |
|
| 277 | + throw new \Exception('Sabre server plugin '.$className.' does not implement the '.ServerPlugin::class.' interface'); |
|
| 278 | 278 | } |
| 279 | 279 | return $instance; |
| 280 | 280 | }, $classes); |
@@ -285,10 +285,10 @@ discard block |
||
| 285 | 285 | * @return Collection[] |
| 286 | 286 | */ |
| 287 | 287 | private function loadSabreCollectionsFromInfoXml(array $classes): array { |
| 288 | - return array_map(function (string $className): Collection { |
|
| 288 | + return array_map(function(string $className): Collection { |
|
| 289 | 289 | $instance = $this->createClass($className); |
| 290 | 290 | if (!($instance instanceof Collection)) { |
| 291 | - throw new \Exception('Sabre collection plugin ' . $className . ' does not implement the ' . Collection::class . ' interface'); |
|
| 291 | + throw new \Exception('Sabre collection plugin '.$className.' does not implement the '.Collection::class.' interface'); |
|
| 292 | 292 | } |
| 293 | 293 | return $instance; |
| 294 | 294 | }, $classes); |
@@ -299,10 +299,10 @@ discard block |
||
| 299 | 299 | * @return IAddressBookProvider[] |
| 300 | 300 | */ |
| 301 | 301 | private function loadSabreAddressBookPluginsFromInfoXml(array $classes): array { |
| 302 | - return array_map(function (string $className): IAddressBookProvider { |
|
| 302 | + return array_map(function(string $className): IAddressBookProvider { |
|
| 303 | 303 | $instance = $this->createClass($className); |
| 304 | 304 | if (!($instance instanceof IAddressBookProvider)) { |
| 305 | - throw new \Exception('Sabre address book plugin class ' . $className . ' does not implement the ' . IAddressBookProvider::class . ' interface'); |
|
| 305 | + throw new \Exception('Sabre address book plugin class '.$className.' does not implement the '.IAddressBookProvider::class.' interface'); |
|
| 306 | 306 | } |
| 307 | 307 | return $instance; |
| 308 | 308 | }, $classes); |
@@ -313,10 +313,10 @@ discard block |
||
| 313 | 313 | * @return ICalendarProvider[] |
| 314 | 314 | */ |
| 315 | 315 | private function loadSabreCalendarPluginsFromInfoXml(array $classes): array { |
| 316 | - return array_map(function (string $className): ICalendarProvider { |
|
| 316 | + return array_map(function(string $className): ICalendarProvider { |
|
| 317 | 317 | $instance = $this->createClass($className); |
| 318 | 318 | if (!($instance instanceof ICalendarProvider)) { |
| 319 | - throw new \Exception('Sabre calendar plugin class ' . $className . ' does not implement the ' . ICalendarProvider::class . ' interface'); |
|
| 319 | + throw new \Exception('Sabre calendar plugin class '.$className.' does not implement the '.ICalendarProvider::class.' interface'); |
|
| 320 | 320 | } |
| 321 | 321 | return $instance; |
| 322 | 322 | }, $classes); |
@@ -27,272 +27,272 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class PluginManager { |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * App plugins |
|
| 32 | - * |
|
| 33 | - * @var ServerPlugin[] |
|
| 34 | - */ |
|
| 35 | - private $plugins = []; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * App collections |
|
| 39 | - * |
|
| 40 | - * @var Collection[] |
|
| 41 | - */ |
|
| 42 | - private $collections = []; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Address book plugins |
|
| 46 | - * |
|
| 47 | - * @var IAddressBookProvider[] |
|
| 48 | - */ |
|
| 49 | - private $addressBookPlugins = []; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Calendar plugins |
|
| 53 | - * |
|
| 54 | - * @var ICalendarProvider[] |
|
| 55 | - */ |
|
| 56 | - private $calendarPlugins = []; |
|
| 57 | - |
|
| 58 | - /** @var bool */ |
|
| 59 | - private $populated = false; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Contstruct a PluginManager |
|
| 63 | - * |
|
| 64 | - * @param ServerContainer $container server container for resolving plugin classes |
|
| 65 | - * @param IAppManager $appManager app manager to loading apps and their info |
|
| 66 | - */ |
|
| 67 | - public function __construct( |
|
| 68 | - private ServerContainer $container, |
|
| 69 | - private IAppManager $appManager, |
|
| 70 | - ) { |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Returns an array of app-registered plugins |
|
| 75 | - * |
|
| 76 | - * @return ServerPlugin[] |
|
| 77 | - */ |
|
| 78 | - public function getAppPlugins() { |
|
| 79 | - $this->populate(); |
|
| 80 | - return $this->plugins; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Returns an array of app-registered collections |
|
| 85 | - * |
|
| 86 | - * @return array |
|
| 87 | - */ |
|
| 88 | - public function getAppCollections() { |
|
| 89 | - $this->populate(); |
|
| 90 | - return $this->collections; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @return IAddressBookProvider[] |
|
| 95 | - */ |
|
| 96 | - public function getAddressBookPlugins(): array { |
|
| 97 | - $this->populate(); |
|
| 98 | - return $this->addressBookPlugins; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Returns an array of app-registered calendar plugins |
|
| 103 | - * |
|
| 104 | - * @return ICalendarProvider[] |
|
| 105 | - */ |
|
| 106 | - public function getCalendarPlugins():array { |
|
| 107 | - $this->populate(); |
|
| 108 | - return $this->calendarPlugins; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Retrieve plugin and collection list and populate attributes |
|
| 113 | - */ |
|
| 114 | - private function populate(): void { |
|
| 115 | - if ($this->populated) { |
|
| 116 | - return; |
|
| 117 | - } |
|
| 118 | - $this->populated = true; |
|
| 119 | - |
|
| 120 | - $this->calendarPlugins[] = $this->container->get(AppCalendarPlugin::class); |
|
| 121 | - |
|
| 122 | - foreach ($this->appManager->getEnabledApps() as $app) { |
|
| 123 | - // load plugins and collections from info.xml |
|
| 124 | - $info = $this->appManager->getAppInfo($app); |
|
| 125 | - if (!isset($info['types']) || !in_array('dav', $info['types'], true)) { |
|
| 126 | - continue; |
|
| 127 | - } |
|
| 128 | - $plugins = $this->loadSabrePluginsFromInfoXml($this->extractPluginList($info)); |
|
| 129 | - foreach ($plugins as $plugin) { |
|
| 130 | - $this->plugins[] = $plugin; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - $collections = $this->loadSabreCollectionsFromInfoXml($this->extractCollectionList($info)); |
|
| 134 | - foreach ($collections as $collection) { |
|
| 135 | - $this->collections[] = $collection; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $addresbookPlugins = $this->loadSabreAddressBookPluginsFromInfoXml($this->extractAddressBookPluginList($info)); |
|
| 139 | - foreach ($addresbookPlugins as $addresbookPlugin) { |
|
| 140 | - $this->addressBookPlugins[] = $addresbookPlugin; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - $calendarPlugins = $this->loadSabreCalendarPluginsFromInfoXml($this->extractCalendarPluginList($info)); |
|
| 144 | - foreach ($calendarPlugins as $calendarPlugin) { |
|
| 145 | - $this->calendarPlugins[] = $calendarPlugin; |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * @param array $array |
|
| 152 | - * @return string[] |
|
| 153 | - */ |
|
| 154 | - private function extractPluginList(array $array): array { |
|
| 155 | - if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 156 | - if (isset($array['sabre']['plugins']) && is_array($array['sabre']['plugins'])) { |
|
| 157 | - if (isset($array['sabre']['plugins']['plugin'])) { |
|
| 158 | - $items = $array['sabre']['plugins']['plugin']; |
|
| 159 | - if (!is_array($items)) { |
|
| 160 | - $items = [$items]; |
|
| 161 | - } |
|
| 162 | - return $items; |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - return []; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * @param array $array |
|
| 171 | - * @return string[] |
|
| 172 | - */ |
|
| 173 | - private function extractCollectionList(array $array): array { |
|
| 174 | - if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 175 | - if (isset($array['sabre']['collections']) && is_array($array['sabre']['collections'])) { |
|
| 176 | - if (isset($array['sabre']['collections']['collection'])) { |
|
| 177 | - $items = $array['sabre']['collections']['collection']; |
|
| 178 | - if (!is_array($items)) { |
|
| 179 | - $items = [$items]; |
|
| 180 | - } |
|
| 181 | - return $items; |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - return []; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * @param array $array |
|
| 190 | - * @return string[] |
|
| 191 | - */ |
|
| 192 | - private function extractAddressBookPluginList(array $array): array { |
|
| 193 | - if (!isset($array['sabre']) || !is_array($array['sabre'])) { |
|
| 194 | - return []; |
|
| 195 | - } |
|
| 196 | - if (!isset($array['sabre']['address-book-plugins']) || !is_array($array['sabre']['address-book-plugins'])) { |
|
| 197 | - return []; |
|
| 198 | - } |
|
| 199 | - if (!isset($array['sabre']['address-book-plugins']['plugin'])) { |
|
| 200 | - return []; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - $items = $array['sabre']['address-book-plugins']['plugin']; |
|
| 204 | - if (!is_array($items)) { |
|
| 205 | - $items = [$items]; |
|
| 206 | - } |
|
| 207 | - return $items; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * @param array $array |
|
| 212 | - * @return string[] |
|
| 213 | - */ |
|
| 214 | - private function extractCalendarPluginList(array $array): array { |
|
| 215 | - if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 216 | - if (isset($array['sabre']['calendar-plugins']) && is_array($array['sabre']['calendar-plugins'])) { |
|
| 217 | - if (isset($array['sabre']['calendar-plugins']['plugin'])) { |
|
| 218 | - $items = $array['sabre']['calendar-plugins']['plugin']; |
|
| 219 | - if (!is_array($items)) { |
|
| 220 | - $items = [$items]; |
|
| 221 | - } |
|
| 222 | - return $items; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - return []; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - private function createClass(string $className): object { |
|
| 230 | - try { |
|
| 231 | - return $this->container->get($className); |
|
| 232 | - } catch (QueryException $e) { |
|
| 233 | - if (class_exists($className)) { |
|
| 234 | - return new $className(); |
|
| 235 | - } |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - throw new \Exception('Could not load ' . $className, 0, $e); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * @param string[] $classes |
|
| 244 | - * @return ServerPlugin[] |
|
| 245 | - * @throws \Exception |
|
| 246 | - */ |
|
| 247 | - private function loadSabrePluginsFromInfoXml(array $classes): array { |
|
| 248 | - return array_map(function (string $className): ServerPlugin { |
|
| 249 | - $instance = $this->createClass($className); |
|
| 250 | - if (!($instance instanceof ServerPlugin)) { |
|
| 251 | - throw new \Exception('Sabre server plugin ' . $className . ' does not implement the ' . ServerPlugin::class . ' interface'); |
|
| 252 | - } |
|
| 253 | - return $instance; |
|
| 254 | - }, $classes); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * @param string[] $classes |
|
| 259 | - * @return Collection[] |
|
| 260 | - */ |
|
| 261 | - private function loadSabreCollectionsFromInfoXml(array $classes): array { |
|
| 262 | - return array_map(function (string $className): Collection { |
|
| 263 | - $instance = $this->createClass($className); |
|
| 264 | - if (!($instance instanceof Collection)) { |
|
| 265 | - throw new \Exception('Sabre collection plugin ' . $className . ' does not implement the ' . Collection::class . ' interface'); |
|
| 266 | - } |
|
| 267 | - return $instance; |
|
| 268 | - }, $classes); |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * @param string[] $classes |
|
| 273 | - * @return IAddressBookProvider[] |
|
| 274 | - */ |
|
| 275 | - private function loadSabreAddressBookPluginsFromInfoXml(array $classes): array { |
|
| 276 | - return array_map(function (string $className): IAddressBookProvider { |
|
| 277 | - $instance = $this->createClass($className); |
|
| 278 | - if (!($instance instanceof IAddressBookProvider)) { |
|
| 279 | - throw new \Exception('Sabre address book plugin class ' . $className . ' does not implement the ' . IAddressBookProvider::class . ' interface'); |
|
| 280 | - } |
|
| 281 | - return $instance; |
|
| 282 | - }, $classes); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * @param string[] $classes |
|
| 287 | - * @return ICalendarProvider[] |
|
| 288 | - */ |
|
| 289 | - private function loadSabreCalendarPluginsFromInfoXml(array $classes): array { |
|
| 290 | - return array_map(function (string $className): ICalendarProvider { |
|
| 291 | - $instance = $this->createClass($className); |
|
| 292 | - if (!($instance instanceof ICalendarProvider)) { |
|
| 293 | - throw new \Exception('Sabre calendar plugin class ' . $className . ' does not implement the ' . ICalendarProvider::class . ' interface'); |
|
| 294 | - } |
|
| 295 | - return $instance; |
|
| 296 | - }, $classes); |
|
| 297 | - } |
|
| 30 | + /** |
|
| 31 | + * App plugins |
|
| 32 | + * |
|
| 33 | + * @var ServerPlugin[] |
|
| 34 | + */ |
|
| 35 | + private $plugins = []; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * App collections |
|
| 39 | + * |
|
| 40 | + * @var Collection[] |
|
| 41 | + */ |
|
| 42 | + private $collections = []; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Address book plugins |
|
| 46 | + * |
|
| 47 | + * @var IAddressBookProvider[] |
|
| 48 | + */ |
|
| 49 | + private $addressBookPlugins = []; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Calendar plugins |
|
| 53 | + * |
|
| 54 | + * @var ICalendarProvider[] |
|
| 55 | + */ |
|
| 56 | + private $calendarPlugins = []; |
|
| 57 | + |
|
| 58 | + /** @var bool */ |
|
| 59 | + private $populated = false; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Contstruct a PluginManager |
|
| 63 | + * |
|
| 64 | + * @param ServerContainer $container server container for resolving plugin classes |
|
| 65 | + * @param IAppManager $appManager app manager to loading apps and their info |
|
| 66 | + */ |
|
| 67 | + public function __construct( |
|
| 68 | + private ServerContainer $container, |
|
| 69 | + private IAppManager $appManager, |
|
| 70 | + ) { |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Returns an array of app-registered plugins |
|
| 75 | + * |
|
| 76 | + * @return ServerPlugin[] |
|
| 77 | + */ |
|
| 78 | + public function getAppPlugins() { |
|
| 79 | + $this->populate(); |
|
| 80 | + return $this->plugins; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Returns an array of app-registered collections |
|
| 85 | + * |
|
| 86 | + * @return array |
|
| 87 | + */ |
|
| 88 | + public function getAppCollections() { |
|
| 89 | + $this->populate(); |
|
| 90 | + return $this->collections; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @return IAddressBookProvider[] |
|
| 95 | + */ |
|
| 96 | + public function getAddressBookPlugins(): array { |
|
| 97 | + $this->populate(); |
|
| 98 | + return $this->addressBookPlugins; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Returns an array of app-registered calendar plugins |
|
| 103 | + * |
|
| 104 | + * @return ICalendarProvider[] |
|
| 105 | + */ |
|
| 106 | + public function getCalendarPlugins():array { |
|
| 107 | + $this->populate(); |
|
| 108 | + return $this->calendarPlugins; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Retrieve plugin and collection list and populate attributes |
|
| 113 | + */ |
|
| 114 | + private function populate(): void { |
|
| 115 | + if ($this->populated) { |
|
| 116 | + return; |
|
| 117 | + } |
|
| 118 | + $this->populated = true; |
|
| 119 | + |
|
| 120 | + $this->calendarPlugins[] = $this->container->get(AppCalendarPlugin::class); |
|
| 121 | + |
|
| 122 | + foreach ($this->appManager->getEnabledApps() as $app) { |
|
| 123 | + // load plugins and collections from info.xml |
|
| 124 | + $info = $this->appManager->getAppInfo($app); |
|
| 125 | + if (!isset($info['types']) || !in_array('dav', $info['types'], true)) { |
|
| 126 | + continue; |
|
| 127 | + } |
|
| 128 | + $plugins = $this->loadSabrePluginsFromInfoXml($this->extractPluginList($info)); |
|
| 129 | + foreach ($plugins as $plugin) { |
|
| 130 | + $this->plugins[] = $plugin; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + $collections = $this->loadSabreCollectionsFromInfoXml($this->extractCollectionList($info)); |
|
| 134 | + foreach ($collections as $collection) { |
|
| 135 | + $this->collections[] = $collection; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $addresbookPlugins = $this->loadSabreAddressBookPluginsFromInfoXml($this->extractAddressBookPluginList($info)); |
|
| 139 | + foreach ($addresbookPlugins as $addresbookPlugin) { |
|
| 140 | + $this->addressBookPlugins[] = $addresbookPlugin; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + $calendarPlugins = $this->loadSabreCalendarPluginsFromInfoXml($this->extractCalendarPluginList($info)); |
|
| 144 | + foreach ($calendarPlugins as $calendarPlugin) { |
|
| 145 | + $this->calendarPlugins[] = $calendarPlugin; |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * @param array $array |
|
| 152 | + * @return string[] |
|
| 153 | + */ |
|
| 154 | + private function extractPluginList(array $array): array { |
|
| 155 | + if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 156 | + if (isset($array['sabre']['plugins']) && is_array($array['sabre']['plugins'])) { |
|
| 157 | + if (isset($array['sabre']['plugins']['plugin'])) { |
|
| 158 | + $items = $array['sabre']['plugins']['plugin']; |
|
| 159 | + if (!is_array($items)) { |
|
| 160 | + $items = [$items]; |
|
| 161 | + } |
|
| 162 | + return $items; |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + return []; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * @param array $array |
|
| 171 | + * @return string[] |
|
| 172 | + */ |
|
| 173 | + private function extractCollectionList(array $array): array { |
|
| 174 | + if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 175 | + if (isset($array['sabre']['collections']) && is_array($array['sabre']['collections'])) { |
|
| 176 | + if (isset($array['sabre']['collections']['collection'])) { |
|
| 177 | + $items = $array['sabre']['collections']['collection']; |
|
| 178 | + if (!is_array($items)) { |
|
| 179 | + $items = [$items]; |
|
| 180 | + } |
|
| 181 | + return $items; |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + return []; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * @param array $array |
|
| 190 | + * @return string[] |
|
| 191 | + */ |
|
| 192 | + private function extractAddressBookPluginList(array $array): array { |
|
| 193 | + if (!isset($array['sabre']) || !is_array($array['sabre'])) { |
|
| 194 | + return []; |
|
| 195 | + } |
|
| 196 | + if (!isset($array['sabre']['address-book-plugins']) || !is_array($array['sabre']['address-book-plugins'])) { |
|
| 197 | + return []; |
|
| 198 | + } |
|
| 199 | + if (!isset($array['sabre']['address-book-plugins']['plugin'])) { |
|
| 200 | + return []; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + $items = $array['sabre']['address-book-plugins']['plugin']; |
|
| 204 | + if (!is_array($items)) { |
|
| 205 | + $items = [$items]; |
|
| 206 | + } |
|
| 207 | + return $items; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * @param array $array |
|
| 212 | + * @return string[] |
|
| 213 | + */ |
|
| 214 | + private function extractCalendarPluginList(array $array): array { |
|
| 215 | + if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 216 | + if (isset($array['sabre']['calendar-plugins']) && is_array($array['sabre']['calendar-plugins'])) { |
|
| 217 | + if (isset($array['sabre']['calendar-plugins']['plugin'])) { |
|
| 218 | + $items = $array['sabre']['calendar-plugins']['plugin']; |
|
| 219 | + if (!is_array($items)) { |
|
| 220 | + $items = [$items]; |
|
| 221 | + } |
|
| 222 | + return $items; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + return []; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + private function createClass(string $className): object { |
|
| 230 | + try { |
|
| 231 | + return $this->container->get($className); |
|
| 232 | + } catch (QueryException $e) { |
|
| 233 | + if (class_exists($className)) { |
|
| 234 | + return new $className(); |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + throw new \Exception('Could not load ' . $className, 0, $e); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * @param string[] $classes |
|
| 244 | + * @return ServerPlugin[] |
|
| 245 | + * @throws \Exception |
|
| 246 | + */ |
|
| 247 | + private function loadSabrePluginsFromInfoXml(array $classes): array { |
|
| 248 | + return array_map(function (string $className): ServerPlugin { |
|
| 249 | + $instance = $this->createClass($className); |
|
| 250 | + if (!($instance instanceof ServerPlugin)) { |
|
| 251 | + throw new \Exception('Sabre server plugin ' . $className . ' does not implement the ' . ServerPlugin::class . ' interface'); |
|
| 252 | + } |
|
| 253 | + return $instance; |
|
| 254 | + }, $classes); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * @param string[] $classes |
|
| 259 | + * @return Collection[] |
|
| 260 | + */ |
|
| 261 | + private function loadSabreCollectionsFromInfoXml(array $classes): array { |
|
| 262 | + return array_map(function (string $className): Collection { |
|
| 263 | + $instance = $this->createClass($className); |
|
| 264 | + if (!($instance instanceof Collection)) { |
|
| 265 | + throw new \Exception('Sabre collection plugin ' . $className . ' does not implement the ' . Collection::class . ' interface'); |
|
| 266 | + } |
|
| 267 | + return $instance; |
|
| 268 | + }, $classes); |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * @param string[] $classes |
|
| 273 | + * @return IAddressBookProvider[] |
|
| 274 | + */ |
|
| 275 | + private function loadSabreAddressBookPluginsFromInfoXml(array $classes): array { |
|
| 276 | + return array_map(function (string $className): IAddressBookProvider { |
|
| 277 | + $instance = $this->createClass($className); |
|
| 278 | + if (!($instance instanceof IAddressBookProvider)) { |
|
| 279 | + throw new \Exception('Sabre address book plugin class ' . $className . ' does not implement the ' . IAddressBookProvider::class . ' interface'); |
|
| 280 | + } |
|
| 281 | + return $instance; |
|
| 282 | + }, $classes); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * @param string[] $classes |
|
| 287 | + * @return ICalendarProvider[] |
|
| 288 | + */ |
|
| 289 | + private function loadSabreCalendarPluginsFromInfoXml(array $classes): array { |
|
| 290 | + return array_map(function (string $className): ICalendarProvider { |
|
| 291 | + $instance = $this->createClass($className); |
|
| 292 | + if (!($instance instanceof ICalendarProvider)) { |
|
| 293 | + throw new \Exception('Sabre calendar plugin class ' . $className . ' does not implement the ' . ICalendarProvider::class . ' interface'); |
|
| 294 | + } |
|
| 295 | + return $instance; |
|
| 296 | + }, $classes); |
|
| 297 | + } |
|
| 298 | 298 | } |
@@ -35,61 +35,61 @@ |
||
| 35 | 35 | * @since 22.0.0 |
| 36 | 36 | */ |
| 37 | 37 | class AbstractCacheEvent extends Event implements ICacheEvent { |
| 38 | - protected $storage; |
|
| 39 | - protected $path; |
|
| 40 | - protected $fileId; |
|
| 41 | - protected $storageId; |
|
| 38 | + protected $storage; |
|
| 39 | + protected $path; |
|
| 40 | + protected $fileId; |
|
| 41 | + protected $storageId; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param IStorage $storage |
|
| 45 | - * @param string $path |
|
| 46 | - * @param int $fileId |
|
| 47 | - * @since 22.0.0 |
|
| 48 | - */ |
|
| 49 | - public function __construct(IStorage $storage, string $path, int $fileId, int $storageId) { |
|
| 50 | - $this->storage = $storage; |
|
| 51 | - $this->path = $path; |
|
| 52 | - $this->fileId = $fileId; |
|
| 53 | - $this->storageId = $storageId; |
|
| 54 | - } |
|
| 43 | + /** |
|
| 44 | + * @param IStorage $storage |
|
| 45 | + * @param string $path |
|
| 46 | + * @param int $fileId |
|
| 47 | + * @since 22.0.0 |
|
| 48 | + */ |
|
| 49 | + public function __construct(IStorage $storage, string $path, int $fileId, int $storageId) { |
|
| 50 | + $this->storage = $storage; |
|
| 51 | + $this->path = $path; |
|
| 52 | + $this->fileId = $fileId; |
|
| 53 | + $this->storageId = $storageId; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @return IStorage |
|
| 58 | - * @since 22.0.0 |
|
| 59 | - */ |
|
| 60 | - public function getStorage(): IStorage { |
|
| 61 | - return $this->storage; |
|
| 62 | - } |
|
| 56 | + /** |
|
| 57 | + * @return IStorage |
|
| 58 | + * @since 22.0.0 |
|
| 59 | + */ |
|
| 60 | + public function getStorage(): IStorage { |
|
| 61 | + return $this->storage; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @return string |
|
| 66 | - * @since 22.0.0 |
|
| 67 | - */ |
|
| 68 | - public function getPath(): string { |
|
| 69 | - return $this->path; |
|
| 70 | - } |
|
| 64 | + /** |
|
| 65 | + * @return string |
|
| 66 | + * @since 22.0.0 |
|
| 67 | + */ |
|
| 68 | + public function getPath(): string { |
|
| 69 | + return $this->path; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @param string $path |
|
| 74 | - * @since 22.0.0 |
|
| 75 | - */ |
|
| 76 | - public function setPath(string $path): void { |
|
| 77 | - $this->path = $path; |
|
| 78 | - } |
|
| 72 | + /** |
|
| 73 | + * @param string $path |
|
| 74 | + * @since 22.0.0 |
|
| 75 | + */ |
|
| 76 | + public function setPath(string $path): void { |
|
| 77 | + $this->path = $path; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @return int |
|
| 82 | - * @since 22.0.0 |
|
| 83 | - */ |
|
| 84 | - public function getFileId(): int { |
|
| 85 | - return $this->fileId; |
|
| 86 | - } |
|
| 80 | + /** |
|
| 81 | + * @return int |
|
| 82 | + * @since 22.0.0 |
|
| 83 | + */ |
|
| 84 | + public function getFileId(): int { |
|
| 85 | + return $this->fileId; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * @return int |
|
| 90 | - * @since 22.0.0 |
|
| 91 | - */ |
|
| 92 | - public function getStorageId(): int { |
|
| 93 | - return $this->storageId; |
|
| 94 | - } |
|
| 88 | + /** |
|
| 89 | + * @return int |
|
| 90 | + * @since 22.0.0 |
|
| 91 | + */ |
|
| 92 | + public function getStorageId(): int { |
|
| 93 | + return $this->storageId; |
|
| 94 | + } |
|
| 95 | 95 | } |
@@ -38,41 +38,41 @@ |
||
| 38 | 38 | * Auto-generated migration step: Please modify to your needs! |
| 39 | 39 | */ |
| 40 | 40 | class Version1011Date20190806104428 extends SimpleMigrationStep { |
| 41 | - /** |
|
| 42 | - * @param IOutput $output |
|
| 43 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 44 | - * @param array $options |
|
| 45 | - * @return null|ISchemaWrapper |
|
| 46 | - */ |
|
| 47 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 48 | - /** @var ISchemaWrapper $schema */ |
|
| 49 | - $schema = $schemaClosure(); |
|
| 41 | + /** |
|
| 42 | + * @param IOutput $output |
|
| 43 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 44 | + * @param array $options |
|
| 45 | + * @return null|ISchemaWrapper |
|
| 46 | + */ |
|
| 47 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 48 | + /** @var ISchemaWrapper $schema */ |
|
| 49 | + $schema = $schemaClosure(); |
|
| 50 | 50 | |
| 51 | - $table = $schema->createTable('dav_cal_proxy'); |
|
| 52 | - $table->addColumn('id', Types::BIGINT, [ |
|
| 53 | - 'autoincrement' => true, |
|
| 54 | - 'notnull' => true, |
|
| 55 | - 'length' => 11, |
|
| 56 | - 'unsigned' => true, |
|
| 57 | - ]); |
|
| 58 | - $table->addColumn('owner_id', Types::STRING, [ |
|
| 59 | - 'notnull' => true, |
|
| 60 | - 'length' => 64, |
|
| 61 | - ]); |
|
| 62 | - $table->addColumn('proxy_id', Types::STRING, [ |
|
| 63 | - 'notnull' => true, |
|
| 64 | - 'length' => 64, |
|
| 65 | - ]); |
|
| 66 | - $table->addColumn('permissions', Types::INTEGER, [ |
|
| 67 | - 'notnull' => false, |
|
| 68 | - 'length' => 4, |
|
| 69 | - 'unsigned' => true, |
|
| 70 | - ]); |
|
| 51 | + $table = $schema->createTable('dav_cal_proxy'); |
|
| 52 | + $table->addColumn('id', Types::BIGINT, [ |
|
| 53 | + 'autoincrement' => true, |
|
| 54 | + 'notnull' => true, |
|
| 55 | + 'length' => 11, |
|
| 56 | + 'unsigned' => true, |
|
| 57 | + ]); |
|
| 58 | + $table->addColumn('owner_id', Types::STRING, [ |
|
| 59 | + 'notnull' => true, |
|
| 60 | + 'length' => 64, |
|
| 61 | + ]); |
|
| 62 | + $table->addColumn('proxy_id', Types::STRING, [ |
|
| 63 | + 'notnull' => true, |
|
| 64 | + 'length' => 64, |
|
| 65 | + ]); |
|
| 66 | + $table->addColumn('permissions', Types::INTEGER, [ |
|
| 67 | + 'notnull' => false, |
|
| 68 | + 'length' => 4, |
|
| 69 | + 'unsigned' => true, |
|
| 70 | + ]); |
|
| 71 | 71 | |
| 72 | - $table->setPrimaryKey(['id']); |
|
| 73 | - $table->addUniqueIndex(['owner_id', 'proxy_id', 'permissions'], 'dav_cal_proxy_uidx'); |
|
| 74 | - $table->addIndex(['proxy_id'], 'dav_cal_proxy_ipid'); |
|
| 72 | + $table->setPrimaryKey(['id']); |
|
| 73 | + $table->addUniqueIndex(['owner_id', 'proxy_id', 'permissions'], 'dav_cal_proxy_uidx'); |
|
| 74 | + $table->addIndex(['proxy_id'], 'dav_cal_proxy_ipid'); |
|
| 75 | 75 | |
| 76 | - return $schema; |
|
| 77 | - } |
|
| 76 | + return $schema; |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -35,21 +35,21 @@ |
||
| 35 | 35 | * Auto-generated migration step: Please modify to your needs! |
| 36 | 36 | */ |
| 37 | 37 | class Version1017Date20210216083742 extends SimpleMigrationStep { |
| 38 | - /** |
|
| 39 | - * @param IOutput $output |
|
| 40 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 41 | - * @param array $options |
|
| 42 | - * @return null|ISchemaWrapper |
|
| 43 | - */ |
|
| 44 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 45 | - /** @var ISchemaWrapper $schema */ |
|
| 46 | - $schema = $schemaClosure(); |
|
| 38 | + /** |
|
| 39 | + * @param IOutput $output |
|
| 40 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 41 | + * @param array $options |
|
| 42 | + * @return null|ISchemaWrapper |
|
| 43 | + */ |
|
| 44 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 45 | + /** @var ISchemaWrapper $schema */ |
|
| 46 | + $schema = $schemaClosure(); |
|
| 47 | 47 | |
| 48 | - $table = $schema->getTable('dav_cal_proxy'); |
|
| 49 | - if ($table->hasIndex('dav_cal_proxy_ioid')) { |
|
| 50 | - $table->dropIndex('dav_cal_proxy_ioid'); |
|
| 51 | - } |
|
| 48 | + $table = $schema->getTable('dav_cal_proxy'); |
|
| 49 | + if ($table->hasIndex('dav_cal_proxy_ioid')) { |
|
| 50 | + $table->dropIndex('dav_cal_proxy_ioid'); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - return $schema; |
|
| 54 | - } |
|
| 53 | + return $schema; |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -35,21 +35,21 @@ |
||
| 35 | 35 | * Auto-generated migration step: Please modify to your needs! |
| 36 | 36 | */ |
| 37 | 37 | class Version22000Date20210216084241 extends SimpleMigrationStep { |
| 38 | - /** |
|
| 39 | - * @param IOutput $output |
|
| 40 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 41 | - * @param array $options |
|
| 42 | - * @return null|ISchemaWrapper |
|
| 43 | - */ |
|
| 44 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 45 | - /** @var ISchemaWrapper $schema */ |
|
| 46 | - $schema = $schemaClosure(); |
|
| 38 | + /** |
|
| 39 | + * @param IOutput $output |
|
| 40 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 41 | + * @param array $options |
|
| 42 | + * @return null|ISchemaWrapper |
|
| 43 | + */ |
|
| 44 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 45 | + /** @var ISchemaWrapper $schema */ |
|
| 46 | + $schema = $schemaClosure(); |
|
| 47 | 47 | |
| 48 | - $table = $schema->getTable('share_external'); |
|
| 49 | - if ($table->hasIndex('sh_external_user')) { |
|
| 50 | - $table->dropIndex('sh_external_user'); |
|
| 51 | - } |
|
| 48 | + $table = $schema->getTable('share_external'); |
|
| 49 | + if ($table->hasIndex('sh_external_user')) { |
|
| 50 | + $table->dropIndex('sh_external_user'); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - return $schema; |
|
| 54 | - } |
|
| 53 | + return $schema; |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -25,28 +25,28 @@ |
||
| 25 | 25 | use OCP\IDBConnection; |
| 26 | 26 | |
| 27 | 27 | class HomePropagator extends Propagator { |
| 28 | - private $ignoredBaseFolders; |
|
| 28 | + private $ignoredBaseFolders; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @param \OC\Files\Storage\Storage $storage |
|
| 32 | - */ |
|
| 33 | - public function __construct(\OC\Files\Storage\Storage $storage, IDBConnection $connection) { |
|
| 34 | - parent::__construct($storage, $connection); |
|
| 35 | - $this->ignoredBaseFolders = ['files_encryption']; |
|
| 36 | - } |
|
| 30 | + /** |
|
| 31 | + * @param \OC\Files\Storage\Storage $storage |
|
| 32 | + */ |
|
| 33 | + public function __construct(\OC\Files\Storage\Storage $storage, IDBConnection $connection) { |
|
| 34 | + parent::__construct($storage, $connection); |
|
| 35 | + $this->ignoredBaseFolders = ['files_encryption']; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param string $internalPath |
|
| 41 | - * @param int $time |
|
| 42 | - * @param int $sizeDifference number of bytes the file has grown |
|
| 43 | - */ |
|
| 44 | - public function propagateChange($internalPath, $time, $sizeDifference = 0) { |
|
| 45 | - [$baseFolder] = explode('/', $internalPath, 2); |
|
| 46 | - if (in_array($baseFolder, $this->ignoredBaseFolders)) { |
|
| 47 | - return []; |
|
| 48 | - } else { |
|
| 49 | - parent::propagateChange($internalPath, $time, $sizeDifference); |
|
| 50 | - } |
|
| 51 | - } |
|
| 39 | + /** |
|
| 40 | + * @param string $internalPath |
|
| 41 | + * @param int $time |
|
| 42 | + * @param int $sizeDifference number of bytes the file has grown |
|
| 43 | + */ |
|
| 44 | + public function propagateChange($internalPath, $time, $sizeDifference = 0) { |
|
| 45 | + [$baseFolder] = explode('/', $internalPath, 2); |
|
| 46 | + if (in_array($baseFolder, $this->ignoredBaseFolders)) { |
|
| 47 | + return []; |
|
| 48 | + } else { |
|
| 49 | + parent::propagateChange($internalPath, $time, $sizeDifference); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -28,19 +28,19 @@ |
||
| 28 | 28 | use OC\Files\Storage\Wrapper\Jail; |
| 29 | 29 | |
| 30 | 30 | class JailPropagator extends Propagator { |
| 31 | - /** |
|
| 32 | - * @var Jail |
|
| 33 | - */ |
|
| 34 | - protected $storage; |
|
| 31 | + /** |
|
| 32 | + * @var Jail |
|
| 33 | + */ |
|
| 34 | + protected $storage; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param string $internalPath |
|
| 38 | - * @param int $time |
|
| 39 | - * @param int $sizeDifference |
|
| 40 | - */ |
|
| 41 | - public function propagateChange($internalPath, $time, $sizeDifference = 0) { |
|
| 42 | - /** @var \OC\Files\Storage\Storage $storage */ |
|
| 43 | - [$storage, $sourceInternalPath] = $this->storage->resolvePath($internalPath); |
|
| 44 | - $storage->getPropagator()->propagateChange($sourceInternalPath, $time, $sizeDifference); |
|
| 45 | - } |
|
| 36 | + /** |
|
| 37 | + * @param string $internalPath |
|
| 38 | + * @param int $time |
|
| 39 | + * @param int $sizeDifference |
|
| 40 | + */ |
|
| 41 | + public function propagateChange($internalPath, $time, $sizeDifference = 0) { |
|
| 42 | + /** @var \OC\Files\Storage\Storage $storage */ |
|
| 43 | + [$storage, $sourceInternalPath] = $this->storage->resolvePath($internalPath); |
|
| 44 | + $storage->getPropagator()->propagateChange($sourceInternalPath, $time, $sizeDifference); |
|
| 45 | + } |
|
| 46 | 46 | } |