@@ -60,11 +60,11 @@ |
||
| 60 | 60 | if ($readablePath) { |
| 61 | 61 | $message = "\"$path\"(\"$readablePath\") is locked"; |
| 62 | 62 | } else { |
| 63 | - $message = '"' . $path . '" is locked'; |
|
| 63 | + $message = '"'.$path.'" is locked'; |
|
| 64 | 64 | } |
| 65 | 65 | $this->existingLock = $existingLock; |
| 66 | 66 | if ($existingLock) { |
| 67 | - $message .= ', existing lock on file: ' . $existingLock; |
|
| 67 | + $message .= ', existing lock on file: '.$existingLock; |
|
| 68 | 68 | } |
| 69 | 69 | parent::__construct($message, 0, $previous); |
| 70 | 70 | $this->path = $path; |
@@ -14,64 +14,64 @@ |
||
| 14 | 14 | * @since 8.1.0 |
| 15 | 15 | */ |
| 16 | 16 | class LockedException extends \Exception { |
| 17 | - /** |
|
| 18 | - * Locked path |
|
| 19 | - * |
|
| 20 | - * @var string |
|
| 21 | - */ |
|
| 22 | - private $path; |
|
| 17 | + /** |
|
| 18 | + * Locked path |
|
| 19 | + * |
|
| 20 | + * @var string |
|
| 21 | + */ |
|
| 22 | + private $path; |
|
| 23 | 23 | |
| 24 | - /** @var string|null */ |
|
| 25 | - private $existingLock; |
|
| 24 | + /** @var string|null */ |
|
| 25 | + private $existingLock; |
|
| 26 | 26 | |
| 27 | - private ?string $readablePath; |
|
| 27 | + private ?string $readablePath; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * LockedException constructor. |
|
| 31 | - * |
|
| 32 | - * @param string $path locked path |
|
| 33 | - * @param \Exception|null $previous previous exception for cascading |
|
| 34 | - * @param string $existingLock since 14.0.0 |
|
| 35 | - * @param string $readablePath since 20.0.0 |
|
| 36 | - * @since 8.1.0 |
|
| 37 | - */ |
|
| 38 | - public function __construct(string $path, ?\Exception $previous = null, ?string $existingLock = null, ?string $readablePath = null) { |
|
| 39 | - $this->readablePath = $readablePath; |
|
| 40 | - if ($readablePath) { |
|
| 41 | - $message = "\"$path\"(\"$readablePath\") is locked"; |
|
| 42 | - } else { |
|
| 43 | - $message = '"' . $path . '" is locked'; |
|
| 44 | - } |
|
| 45 | - $this->existingLock = $existingLock; |
|
| 46 | - if ($existingLock) { |
|
| 47 | - $message .= ', existing lock on file: ' . $existingLock; |
|
| 48 | - } |
|
| 49 | - parent::__construct($message, 0, $previous); |
|
| 50 | - $this->path = $path; |
|
| 51 | - } |
|
| 29 | + /** |
|
| 30 | + * LockedException constructor. |
|
| 31 | + * |
|
| 32 | + * @param string $path locked path |
|
| 33 | + * @param \Exception|null $previous previous exception for cascading |
|
| 34 | + * @param string $existingLock since 14.0.0 |
|
| 35 | + * @param string $readablePath since 20.0.0 |
|
| 36 | + * @since 8.1.0 |
|
| 37 | + */ |
|
| 38 | + public function __construct(string $path, ?\Exception $previous = null, ?string $existingLock = null, ?string $readablePath = null) { |
|
| 39 | + $this->readablePath = $readablePath; |
|
| 40 | + if ($readablePath) { |
|
| 41 | + $message = "\"$path\"(\"$readablePath\") is locked"; |
|
| 42 | + } else { |
|
| 43 | + $message = '"' . $path . '" is locked'; |
|
| 44 | + } |
|
| 45 | + $this->existingLock = $existingLock; |
|
| 46 | + if ($existingLock) { |
|
| 47 | + $message .= ', existing lock on file: ' . $existingLock; |
|
| 48 | + } |
|
| 49 | + parent::__construct($message, 0, $previous); |
|
| 50 | + $this->path = $path; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @return string |
|
| 55 | - * @since 8.1.0 |
|
| 56 | - */ |
|
| 57 | - public function getPath(): string { |
|
| 58 | - return $this->path; |
|
| 59 | - } |
|
| 53 | + /** |
|
| 54 | + * @return string |
|
| 55 | + * @since 8.1.0 |
|
| 56 | + */ |
|
| 57 | + public function getPath(): string { |
|
| 58 | + return $this->path; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @return string |
|
| 63 | - * @since 19.0.0 |
|
| 64 | - */ |
|
| 65 | - public function getExistingLock(): ?string { |
|
| 66 | - return $this->existingLock; |
|
| 67 | - } |
|
| 61 | + /** |
|
| 62 | + * @return string |
|
| 63 | + * @since 19.0.0 |
|
| 64 | + */ |
|
| 65 | + public function getExistingLock(): ?string { |
|
| 66 | + return $this->existingLock; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @return ?string |
|
| 71 | - * @since 32.0.0 |
|
| 72 | - */ |
|
| 73 | - public function getReadablePath(): ?string { |
|
| 74 | - return $this->readablePath; |
|
| 75 | - } |
|
| 69 | + /** |
|
| 70 | + * @return ?string |
|
| 71 | + * @since 32.0.0 |
|
| 72 | + */ |
|
| 73 | + public function getReadablePath(): ?string { |
|
| 74 | + return $this->readablePath; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | } |
@@ -35,16 +35,16 @@ |
||
| 35 | 35 | use OCP\AppFramework\Bootstrap\IRegistrationContext; |
| 36 | 36 | |
| 37 | 37 | class Application extends App implements IBootstrap { |
| 38 | - public const APP_ID = 'sharebymail'; |
|
| 38 | + public const APP_ID = 'sharebymail'; |
|
| 39 | 39 | |
| 40 | - public function __construct() { |
|
| 41 | - parent::__construct(self::APP_ID); |
|
| 42 | - } |
|
| 40 | + public function __construct() { |
|
| 41 | + parent::__construct(self::APP_ID); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - public function register(IRegistrationContext $context): void { |
|
| 45 | - $context->registerCapability(Capabilities::class); |
|
| 46 | - } |
|
| 44 | + public function register(IRegistrationContext $context): void { |
|
| 45 | + $context->registerCapability(Capabilities::class); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function boot(IBootContext $context): void { |
|
| 49 | - } |
|
| 48 | + public function boot(IBootContext $context): void { |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -33,51 +33,51 @@ |
||
| 33 | 33 | |
| 34 | 34 | class Version1010Date20200630191302 extends SimpleMigrationStep { |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param IOutput $output |
|
| 38 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 39 | - * @param array $options |
|
| 40 | - * @return null|ISchemaWrapper |
|
| 41 | - */ |
|
| 42 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 43 | - /** @var ISchemaWrapper $schema */ |
|
| 44 | - $schema = $schemaClosure(); |
|
| 36 | + /** |
|
| 37 | + * @param IOutput $output |
|
| 38 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 39 | + * @param array $options |
|
| 40 | + * @return null|ISchemaWrapper |
|
| 41 | + */ |
|
| 42 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 43 | + /** @var ISchemaWrapper $schema */ |
|
| 44 | + $schema = $schemaClosure(); |
|
| 45 | 45 | |
| 46 | - if (!$schema->hasTable('trusted_servers')) { |
|
| 47 | - $table = $schema->createTable('trusted_servers'); |
|
| 48 | - $table->addColumn('id', Types::INTEGER, [ |
|
| 49 | - 'autoincrement' => true, |
|
| 50 | - 'notnull' => true, |
|
| 51 | - 'length' => 4, |
|
| 52 | - ]); |
|
| 53 | - $table->addColumn('url', Types::STRING, [ |
|
| 54 | - 'notnull' => true, |
|
| 55 | - 'length' => 512, |
|
| 56 | - ]); |
|
| 57 | - $table->addColumn('url_hash', Types::STRING, [ |
|
| 58 | - 'notnull' => true, |
|
| 59 | - 'default' => '', |
|
| 60 | - ]); |
|
| 61 | - $table->addColumn('token', Types::STRING, [ |
|
| 62 | - 'notnull' => false, |
|
| 63 | - 'length' => 128, |
|
| 64 | - ]); |
|
| 65 | - $table->addColumn('shared_secret', Types::STRING, [ |
|
| 66 | - 'notnull' => false, |
|
| 67 | - 'length' => 256, |
|
| 68 | - ]); |
|
| 69 | - $table->addColumn('status', Types::INTEGER, [ |
|
| 70 | - 'notnull' => true, |
|
| 71 | - 'length' => 4, |
|
| 72 | - 'default' => 2, |
|
| 73 | - ]); |
|
| 74 | - $table->addColumn('sync_token', Types::STRING, [ |
|
| 75 | - 'notnull' => false, |
|
| 76 | - 'length' => 512, |
|
| 77 | - ]); |
|
| 78 | - $table->setPrimaryKey(['id']); |
|
| 79 | - $table->addUniqueIndex(['url_hash'], 'url_hash'); |
|
| 80 | - } |
|
| 81 | - return $schema; |
|
| 82 | - } |
|
| 46 | + if (!$schema->hasTable('trusted_servers')) { |
|
| 47 | + $table = $schema->createTable('trusted_servers'); |
|
| 48 | + $table->addColumn('id', Types::INTEGER, [ |
|
| 49 | + 'autoincrement' => true, |
|
| 50 | + 'notnull' => true, |
|
| 51 | + 'length' => 4, |
|
| 52 | + ]); |
|
| 53 | + $table->addColumn('url', Types::STRING, [ |
|
| 54 | + 'notnull' => true, |
|
| 55 | + 'length' => 512, |
|
| 56 | + ]); |
|
| 57 | + $table->addColumn('url_hash', Types::STRING, [ |
|
| 58 | + 'notnull' => true, |
|
| 59 | + 'default' => '', |
|
| 60 | + ]); |
|
| 61 | + $table->addColumn('token', Types::STRING, [ |
|
| 62 | + 'notnull' => false, |
|
| 63 | + 'length' => 128, |
|
| 64 | + ]); |
|
| 65 | + $table->addColumn('shared_secret', Types::STRING, [ |
|
| 66 | + 'notnull' => false, |
|
| 67 | + 'length' => 256, |
|
| 68 | + ]); |
|
| 69 | + $table->addColumn('status', Types::INTEGER, [ |
|
| 70 | + 'notnull' => true, |
|
| 71 | + 'length' => 4, |
|
| 72 | + 'default' => 2, |
|
| 73 | + ]); |
|
| 74 | + $table->addColumn('sync_token', Types::STRING, [ |
|
| 75 | + 'notnull' => false, |
|
| 76 | + 'length' => 512, |
|
| 77 | + ]); |
|
| 78 | + $table->setPrimaryKey(['id']); |
|
| 79 | + $table->addUniqueIndex(['url_hash'], 'url_hash'); |
|
| 80 | + } |
|
| 81 | + return $schema; |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -33,16 +33,16 @@ |
||
| 33 | 33 | use OCP\AppFramework\Bootstrap\IRegistrationContext; |
| 34 | 34 | |
| 35 | 35 | class Application extends App implements IBootstrap { |
| 36 | - public const APP_ID = 'cloud_federation_api'; |
|
| 36 | + public const APP_ID = 'cloud_federation_api'; |
|
| 37 | 37 | |
| 38 | - public function __construct() { |
|
| 39 | - parent::__construct(self::APP_ID); |
|
| 40 | - } |
|
| 38 | + public function __construct() { |
|
| 39 | + parent::__construct(self::APP_ID); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function register(IRegistrationContext $context): void { |
|
| 43 | - $context->registerCapability(Capabilities::class); |
|
| 44 | - } |
|
| 42 | + public function register(IRegistrationContext $context): void { |
|
| 43 | + $context->registerCapability(Capabilities::class); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public function boot(IBootContext $context): void { |
|
| 47 | - } |
|
| 46 | + public function boot(IBootContext $context): void { |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | if (isset($this->namespaces[$namespace])) { |
| 105 | 105 | if (!isset($this->hasNoAppContainer[$namespace])) { |
| 106 | - $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application'; |
|
| 106 | + $applicationClassName = 'OCA\\'.$sensitiveNamespace.'\\AppInfo\\Application'; |
|
| 107 | 107 | if (class_exists($applicationClassName)) { |
| 108 | 108 | $app = new $applicationClassName(); |
| 109 | 109 | if (isset($this->appContainers[$namespace])) { |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | try { |
| 162 | - [,$namespace,] = explode('\\', $id); |
|
| 162 | + [,$namespace, ] = explode('\\', $id); |
|
| 163 | 163 | return $this->getAppContainer(strtolower($namespace), $namespace); |
| 164 | 164 | } catch (QueryException $e) { |
| 165 | 165 | return null; |
@@ -21,154 +21,154 @@ |
||
| 21 | 21 | * @package OC |
| 22 | 22 | */ |
| 23 | 23 | class ServerContainer extends SimpleContainer { |
| 24 | - /** @var DIContainer[] */ |
|
| 25 | - protected $appContainers; |
|
| 26 | - |
|
| 27 | - /** @var string[] */ |
|
| 28 | - protected $hasNoAppContainer; |
|
| 29 | - |
|
| 30 | - /** @var string[] */ |
|
| 31 | - protected $namespaces; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * ServerContainer constructor. |
|
| 35 | - */ |
|
| 36 | - public function __construct() { |
|
| 37 | - parent::__construct(); |
|
| 38 | - $this->appContainers = []; |
|
| 39 | - $this->namespaces = []; |
|
| 40 | - $this->hasNoAppContainer = []; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @param string $appName |
|
| 45 | - * @param string $appNamespace |
|
| 46 | - */ |
|
| 47 | - public function registerNamespace(string $appName, string $appNamespace): void { |
|
| 48 | - // Cut of OCA\ and lowercase |
|
| 49 | - $appNamespace = strtolower(substr($appNamespace, strrpos($appNamespace, '\\') + 1)); |
|
| 50 | - $this->namespaces[$appNamespace] = $appName; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @param string $appName |
|
| 55 | - * @param DIContainer $container |
|
| 56 | - */ |
|
| 57 | - public function registerAppContainer(string $appName, DIContainer $container): void { |
|
| 58 | - $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @param string $appName |
|
| 63 | - * @return DIContainer |
|
| 64 | - * @throws QueryException |
|
| 65 | - */ |
|
| 66 | - public function getRegisteredAppContainer(string $appName): DIContainer { |
|
| 67 | - if (isset($this->appContainers[strtolower(App::buildAppNamespace($appName, ''))])) { |
|
| 68 | - return $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))]; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - throw new QueryException(); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @param string $namespace |
|
| 76 | - * @param string $sensitiveNamespace |
|
| 77 | - * @return DIContainer |
|
| 78 | - * @throws QueryException |
|
| 79 | - */ |
|
| 80 | - protected function getAppContainer(string $namespace, string $sensitiveNamespace): DIContainer { |
|
| 81 | - if (isset($this->appContainers[$namespace])) { |
|
| 82 | - return $this->appContainers[$namespace]; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - if (isset($this->namespaces[$namespace])) { |
|
| 86 | - if (!isset($this->hasNoAppContainer[$namespace])) { |
|
| 87 | - $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application'; |
|
| 88 | - if (class_exists($applicationClassName)) { |
|
| 89 | - $app = new $applicationClassName(); |
|
| 90 | - if (isset($this->appContainers[$namespace])) { |
|
| 91 | - $this->appContainers[$namespace]->offsetSet($applicationClassName, $app); |
|
| 92 | - return $this->appContainers[$namespace]; |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - $this->hasNoAppContainer[$namespace] = true; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - return new DIContainer($this->namespaces[$namespace]); |
|
| 99 | - } |
|
| 100 | - throw new QueryException(); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - public function has($id, bool $noRecursion = false): bool { |
|
| 104 | - if (!$noRecursion && ($appContainer = $this->getAppContainerForService($id)) !== null) { |
|
| 105 | - return $appContainer->has($id); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - return parent::has($id); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * @template T |
|
| 113 | - * @param class-string<T>|string $name |
|
| 114 | - * @return T|mixed |
|
| 115 | - * @psalm-template S as class-string<T>|string |
|
| 116 | - * @psalm-param S $name |
|
| 117 | - * @psalm-return (S is class-string<T> ? T : mixed) |
|
| 118 | - * @throws QueryException |
|
| 119 | - * @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get |
|
| 120 | - */ |
|
| 121 | - public function query(string $name, bool $autoload = true) { |
|
| 122 | - $name = $this->sanitizeName($name); |
|
| 123 | - |
|
| 124 | - if (str_starts_with($name, 'OCA\\')) { |
|
| 125 | - // Skip server container query for app namespace classes |
|
| 126 | - try { |
|
| 127 | - return parent::query($name, false); |
|
| 128 | - } catch (QueryException $e) { |
|
| 129 | - // Continue with general autoloading then |
|
| 130 | - } |
|
| 131 | - // In case the service starts with OCA\ we try to find the service in |
|
| 132 | - // the apps container first. |
|
| 133 | - if (($appContainer = $this->getAppContainerForService($name)) !== null) { |
|
| 134 | - try { |
|
| 135 | - return $appContainer->queryNoFallback($name); |
|
| 136 | - } catch (QueryException $e) { |
|
| 137 | - // Didn't find the service or the respective app container |
|
| 138 | - // In this case the service won't be part of the core container, |
|
| 139 | - // so we can throw directly |
|
| 140 | - throw $e; |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - } elseif (str_starts_with($name, 'OC\\Settings\\') && substr_count($name, '\\') >= 3) { |
|
| 144 | - $segments = explode('\\', $name); |
|
| 145 | - try { |
|
| 146 | - $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
| 147 | - return $appContainer->queryNoFallback($name); |
|
| 148 | - } catch (QueryException $e) { |
|
| 149 | - // Didn't find the service or the respective app container, |
|
| 150 | - // ignore it and fall back to the core container. |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - return parent::query($name, $autoload); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * @internal |
|
| 159 | - * @param string $id |
|
| 160 | - * @return DIContainer|null |
|
| 161 | - */ |
|
| 162 | - public function getAppContainerForService(string $id): ?DIContainer { |
|
| 163 | - if (!str_starts_with($id, 'OCA\\') || substr_count($id, '\\') < 2) { |
|
| 164 | - return null; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - try { |
|
| 168 | - [,$namespace,] = explode('\\', $id); |
|
| 169 | - return $this->getAppContainer(strtolower($namespace), $namespace); |
|
| 170 | - } catch (QueryException $e) { |
|
| 171 | - return null; |
|
| 172 | - } |
|
| 173 | - } |
|
| 24 | + /** @var DIContainer[] */ |
|
| 25 | + protected $appContainers; |
|
| 26 | + |
|
| 27 | + /** @var string[] */ |
|
| 28 | + protected $hasNoAppContainer; |
|
| 29 | + |
|
| 30 | + /** @var string[] */ |
|
| 31 | + protected $namespaces; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * ServerContainer constructor. |
|
| 35 | + */ |
|
| 36 | + public function __construct() { |
|
| 37 | + parent::__construct(); |
|
| 38 | + $this->appContainers = []; |
|
| 39 | + $this->namespaces = []; |
|
| 40 | + $this->hasNoAppContainer = []; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @param string $appName |
|
| 45 | + * @param string $appNamespace |
|
| 46 | + */ |
|
| 47 | + public function registerNamespace(string $appName, string $appNamespace): void { |
|
| 48 | + // Cut of OCA\ and lowercase |
|
| 49 | + $appNamespace = strtolower(substr($appNamespace, strrpos($appNamespace, '\\') + 1)); |
|
| 50 | + $this->namespaces[$appNamespace] = $appName; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @param string $appName |
|
| 55 | + * @param DIContainer $container |
|
| 56 | + */ |
|
| 57 | + public function registerAppContainer(string $appName, DIContainer $container): void { |
|
| 58 | + $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @param string $appName |
|
| 63 | + * @return DIContainer |
|
| 64 | + * @throws QueryException |
|
| 65 | + */ |
|
| 66 | + public function getRegisteredAppContainer(string $appName): DIContainer { |
|
| 67 | + if (isset($this->appContainers[strtolower(App::buildAppNamespace($appName, ''))])) { |
|
| 68 | + return $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))]; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + throw new QueryException(); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @param string $namespace |
|
| 76 | + * @param string $sensitiveNamespace |
|
| 77 | + * @return DIContainer |
|
| 78 | + * @throws QueryException |
|
| 79 | + */ |
|
| 80 | + protected function getAppContainer(string $namespace, string $sensitiveNamespace): DIContainer { |
|
| 81 | + if (isset($this->appContainers[$namespace])) { |
|
| 82 | + return $this->appContainers[$namespace]; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + if (isset($this->namespaces[$namespace])) { |
|
| 86 | + if (!isset($this->hasNoAppContainer[$namespace])) { |
|
| 87 | + $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application'; |
|
| 88 | + if (class_exists($applicationClassName)) { |
|
| 89 | + $app = new $applicationClassName(); |
|
| 90 | + if (isset($this->appContainers[$namespace])) { |
|
| 91 | + $this->appContainers[$namespace]->offsetSet($applicationClassName, $app); |
|
| 92 | + return $this->appContainers[$namespace]; |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + $this->hasNoAppContainer[$namespace] = true; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + return new DIContainer($this->namespaces[$namespace]); |
|
| 99 | + } |
|
| 100 | + throw new QueryException(); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + public function has($id, bool $noRecursion = false): bool { |
|
| 104 | + if (!$noRecursion && ($appContainer = $this->getAppContainerForService($id)) !== null) { |
|
| 105 | + return $appContainer->has($id); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + return parent::has($id); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * @template T |
|
| 113 | + * @param class-string<T>|string $name |
|
| 114 | + * @return T|mixed |
|
| 115 | + * @psalm-template S as class-string<T>|string |
|
| 116 | + * @psalm-param S $name |
|
| 117 | + * @psalm-return (S is class-string<T> ? T : mixed) |
|
| 118 | + * @throws QueryException |
|
| 119 | + * @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get |
|
| 120 | + */ |
|
| 121 | + public function query(string $name, bool $autoload = true) { |
|
| 122 | + $name = $this->sanitizeName($name); |
|
| 123 | + |
|
| 124 | + if (str_starts_with($name, 'OCA\\')) { |
|
| 125 | + // Skip server container query for app namespace classes |
|
| 126 | + try { |
|
| 127 | + return parent::query($name, false); |
|
| 128 | + } catch (QueryException $e) { |
|
| 129 | + // Continue with general autoloading then |
|
| 130 | + } |
|
| 131 | + // In case the service starts with OCA\ we try to find the service in |
|
| 132 | + // the apps container first. |
|
| 133 | + if (($appContainer = $this->getAppContainerForService($name)) !== null) { |
|
| 134 | + try { |
|
| 135 | + return $appContainer->queryNoFallback($name); |
|
| 136 | + } catch (QueryException $e) { |
|
| 137 | + // Didn't find the service or the respective app container |
|
| 138 | + // In this case the service won't be part of the core container, |
|
| 139 | + // so we can throw directly |
|
| 140 | + throw $e; |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + } elseif (str_starts_with($name, 'OC\\Settings\\') && substr_count($name, '\\') >= 3) { |
|
| 144 | + $segments = explode('\\', $name); |
|
| 145 | + try { |
|
| 146 | + $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
| 147 | + return $appContainer->queryNoFallback($name); |
|
| 148 | + } catch (QueryException $e) { |
|
| 149 | + // Didn't find the service or the respective app container, |
|
| 150 | + // ignore it and fall back to the core container. |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + return parent::query($name, $autoload); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * @internal |
|
| 159 | + * @param string $id |
|
| 160 | + * @return DIContainer|null |
|
| 161 | + */ |
|
| 162 | + public function getAppContainerForService(string $id): ?DIContainer { |
|
| 163 | + if (!str_starts_with($id, 'OCA\\') || substr_count($id, '\\') < 2) { |
|
| 164 | + return null; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + try { |
|
| 168 | + [,$namespace,] = explode('\\', $id); |
|
| 169 | + return $this->getAppContainer(strtolower($namespace), $namespace); |
|
| 170 | + } catch (QueryException $e) { |
|
| 171 | + return null; |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | 174 | } |
@@ -32,12 +32,12 @@ |
||
| 32 | 32 | * SSO providers that also have a SSO logout url |
| 33 | 33 | */ |
| 34 | 34 | interface ICustomLogout { |
| 35 | - /** |
|
| 36 | - * @since 20.0.0 |
|
| 37 | - * |
|
| 38 | - * The url to redirect to for logout |
|
| 39 | - * |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - public function getLogoutUrl(): string; |
|
| 35 | + /** |
|
| 36 | + * @since 20.0.0 |
|
| 37 | + * |
|
| 38 | + * The url to redirect to for logout |
|
| 39 | + * |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + public function getLogoutUrl(): string; |
|
| 43 | 43 | } |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | $baseDir = $vendorDir; |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'OCA\\UserStatus\\' => array($baseDir . '/../lib'), |
|
| 9 | + 'OCA\\UserStatus\\' => array($baseDir.'/../lib'), |
|
| 10 | 10 | ); |
@@ -370,18 +370,18 @@ discard block |
||
| 370 | 370 | private function findFileWithExtension($class, $ext) |
| 371 | 371 | { |
| 372 | 372 | // PSR-4 lookup |
| 373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
| 374 | 374 | |
| 375 | 375 | $first = $class[0]; |
| 376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
| 377 | 377 | $subPath = $class; |
| 378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
| 379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
| 380 | - $search = $subPath . '\\'; |
|
| 380 | + $search = $subPath.'\\'; |
|
| 381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
| 382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
| 382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
| 383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
| 384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
| 384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
| 385 | 385 | return $file; |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | // PSR-4 fallback dirs |
| 393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
| 394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
| 395 | 395 | return $file; |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
| 403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
| 404 | 404 | } else { |
| 405 | 405 | // PEAR-like class name |
| 406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
| 410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
| 411 | 411 | if (0 === strpos($class, $prefix)) { |
| 412 | 412 | foreach ($dirs as $dir) { |
| 413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 414 | 414 | return $file; |
| 415 | 415 | } |
| 416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | // PSR-0 fallback dirs |
| 422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
| 423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 424 | 424 | return $file; |
| 425 | 425 | } |
| 426 | 426 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @return string|null |
| 86 | 86 | * @since 20.0.0 |
| 87 | 87 | */ |
| 88 | - public function getMessage():?string; |
|
| 88 | + public function getMessage(): ?string; |
|
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * Get a custom icon provided by the user |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @return string|null |
| 94 | 94 | * @since 20.0.0 |
| 95 | 95 | */ |
| 96 | - public function getIcon():?string; |
|
| 96 | + public function getIcon(): ?string; |
|
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * Gets the time that the custom status will be cleared at |
@@ -101,5 +101,5 @@ discard block |
||
| 101 | 101 | * @return DateTimeImmutable|null |
| 102 | 102 | * @since 20.0.0 |
| 103 | 103 | */ |
| 104 | - public function getClearAt():?DateTimeImmutable; |
|
| 104 | + public function getClearAt(): ?DateTimeImmutable; |
|
| 105 | 105 | } |
@@ -16,119 +16,119 @@ |
||
| 16 | 16 | * @since 20.0.0 |
| 17 | 17 | */ |
| 18 | 18 | interface IUserStatus { |
| 19 | - /** |
|
| 20 | - * @var string |
|
| 21 | - * @since 20.0.0 |
|
| 22 | - */ |
|
| 23 | - public const ONLINE = 'online'; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @var string |
|
| 27 | - * @since 20.0.0 |
|
| 28 | - */ |
|
| 29 | - public const AWAY = 'away'; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var string |
|
| 33 | - * @since 20.0.0 |
|
| 34 | - */ |
|
| 35 | - public const DND = 'dnd'; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @var string |
|
| 39 | - * @since 28.0.0 |
|
| 40 | - */ |
|
| 41 | - public const BUSY = 'busy'; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var string |
|
| 45 | - * @since 20.0.0 |
|
| 46 | - */ |
|
| 47 | - public const OFFLINE = 'offline'; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @var string |
|
| 51 | - * @since 20.0.0 |
|
| 52 | - */ |
|
| 53 | - public const INVISIBLE = 'invisible'; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @var string |
|
| 57 | - * @since 25.0.0 |
|
| 58 | - */ |
|
| 59 | - public const MESSAGE_CALL = 'call'; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @var string |
|
| 63 | - * @since 25.0.0 |
|
| 64 | - */ |
|
| 65 | - public const MESSAGE_AVAILABILITY = 'availability'; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @var string |
|
| 69 | - * @since 28.0.1 |
|
| 70 | - */ |
|
| 71 | - public const MESSAGE_OUT_OF_OFFICE = 'out-of-office'; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * @var string |
|
| 75 | - * @since 28.0.0 |
|
| 76 | - */ |
|
| 77 | - public const MESSAGE_VACATION = 'vacationing'; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @var string |
|
| 81 | - * @since 28.0.0 |
|
| 82 | - */ |
|
| 83 | - public const MESSAGE_CALENDAR_BUSY = 'meeting'; |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @var string |
|
| 87 | - * @since 28.0.0 |
|
| 88 | - */ |
|
| 89 | - public const MESSAGE_CALENDAR_BUSY_TENTATIVE = 'busy-tentative'; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Get the user this status is connected to |
|
| 93 | - * |
|
| 94 | - * @return string |
|
| 95 | - * @since 20.0.0 |
|
| 96 | - */ |
|
| 97 | - public function getUserId():string; |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Get the status |
|
| 101 | - * |
|
| 102 | - * It will return one of the constants defined above. |
|
| 103 | - * It will never return invisible. In case a user marked |
|
| 104 | - * themselves as invisible, it will return offline. |
|
| 105 | - * |
|
| 106 | - * @return string See IUserStatus constants |
|
| 107 | - * @since 20.0.0 |
|
| 108 | - */ |
|
| 109 | - public function getStatus():string; |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Get a custom message provided by the user |
|
| 113 | - * |
|
| 114 | - * @return string|null |
|
| 115 | - * @since 20.0.0 |
|
| 116 | - */ |
|
| 117 | - public function getMessage():?string; |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * Get a custom icon provided by the user |
|
| 121 | - * |
|
| 122 | - * @return string|null |
|
| 123 | - * @since 20.0.0 |
|
| 124 | - */ |
|
| 125 | - public function getIcon():?string; |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * Gets the time that the custom status will be cleared at |
|
| 129 | - * |
|
| 130 | - * @return DateTimeImmutable|null |
|
| 131 | - * @since 20.0.0 |
|
| 132 | - */ |
|
| 133 | - public function getClearAt():?DateTimeImmutable; |
|
| 19 | + /** |
|
| 20 | + * @var string |
|
| 21 | + * @since 20.0.0 |
|
| 22 | + */ |
|
| 23 | + public const ONLINE = 'online'; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @var string |
|
| 27 | + * @since 20.0.0 |
|
| 28 | + */ |
|
| 29 | + public const AWAY = 'away'; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var string |
|
| 33 | + * @since 20.0.0 |
|
| 34 | + */ |
|
| 35 | + public const DND = 'dnd'; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @var string |
|
| 39 | + * @since 28.0.0 |
|
| 40 | + */ |
|
| 41 | + public const BUSY = 'busy'; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var string |
|
| 45 | + * @since 20.0.0 |
|
| 46 | + */ |
|
| 47 | + public const OFFLINE = 'offline'; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @var string |
|
| 51 | + * @since 20.0.0 |
|
| 52 | + */ |
|
| 53 | + public const INVISIBLE = 'invisible'; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @var string |
|
| 57 | + * @since 25.0.0 |
|
| 58 | + */ |
|
| 59 | + public const MESSAGE_CALL = 'call'; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @var string |
|
| 63 | + * @since 25.0.0 |
|
| 64 | + */ |
|
| 65 | + public const MESSAGE_AVAILABILITY = 'availability'; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @var string |
|
| 69 | + * @since 28.0.1 |
|
| 70 | + */ |
|
| 71 | + public const MESSAGE_OUT_OF_OFFICE = 'out-of-office'; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * @var string |
|
| 75 | + * @since 28.0.0 |
|
| 76 | + */ |
|
| 77 | + public const MESSAGE_VACATION = 'vacationing'; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @var string |
|
| 81 | + * @since 28.0.0 |
|
| 82 | + */ |
|
| 83 | + public const MESSAGE_CALENDAR_BUSY = 'meeting'; |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @var string |
|
| 87 | + * @since 28.0.0 |
|
| 88 | + */ |
|
| 89 | + public const MESSAGE_CALENDAR_BUSY_TENTATIVE = 'busy-tentative'; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Get the user this status is connected to |
|
| 93 | + * |
|
| 94 | + * @return string |
|
| 95 | + * @since 20.0.0 |
|
| 96 | + */ |
|
| 97 | + public function getUserId():string; |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Get the status |
|
| 101 | + * |
|
| 102 | + * It will return one of the constants defined above. |
|
| 103 | + * It will never return invisible. In case a user marked |
|
| 104 | + * themselves as invisible, it will return offline. |
|
| 105 | + * |
|
| 106 | + * @return string See IUserStatus constants |
|
| 107 | + * @since 20.0.0 |
|
| 108 | + */ |
|
| 109 | + public function getStatus():string; |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Get a custom message provided by the user |
|
| 113 | + * |
|
| 114 | + * @return string|null |
|
| 115 | + * @since 20.0.0 |
|
| 116 | + */ |
|
| 117 | + public function getMessage():?string; |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * Get a custom icon provided by the user |
|
| 121 | + * |
|
| 122 | + * @return string|null |
|
| 123 | + * @since 20.0.0 |
|
| 124 | + */ |
|
| 125 | + public function getIcon():?string; |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * Gets the time that the custom status will be cleared at |
|
| 129 | + * |
|
| 130 | + * @return DateTimeImmutable|null |
|
| 131 | + * @since 20.0.0 |
|
| 132 | + */ |
|
| 133 | + public function getClearAt():?DateTimeImmutable; |
|
| 134 | 134 | } |