|
21 | 21 |
|
22 | 22 | namespace OCA\UserBackendSqlRaw\AppInfo; |
23 | 23 |
|
24 | | -use \OCP\AppFramework\App; |
25 | 24 | use OCP\AppFramework\Bootstrap\IBootContext; |
26 | 25 | use OCP\AppFramework\Bootstrap\IBootstrap; |
27 | 26 | use OCP\AppFramework\Bootstrap\IRegistrationContext; |
28 | 27 | use Psr\Container\ContainerInterface; |
| 28 | +use \OCP\AppFramework\App; |
29 | 29 |
|
30 | | -class Application extends App implements IBootstrap { |
31 | | - public const APP_ID = 'user_backend_sql_raw'; |
| 30 | +class Application extends App implements IBootstrap |
| 31 | +{ |
| 32 | + public const APP_ID = 'user_backend_sql_raw'; |
32 | 33 |
|
33 | | - public function __construct(array $urlParams = array()) { |
34 | | - parent::__construct(Application::APP_ID, $urlParams); |
35 | | - } |
| 34 | + public function __construct(array $urlParams = array()) |
| 35 | + { |
| 36 | + parent::__construct(Application::APP_ID, $urlParams); |
| 37 | + } |
36 | 38 |
|
37 | | - public function register(IRegistrationContext $context): void { |
38 | | - /** |
39 | | - * "Service" in this context is simply a class that you want to be able to inject. |
40 | | - * |
41 | | - * We don't have to register all classes because they can be auto-wired, but OCA\UserBackendSqlRaw\Db |
42 | | - * is an abstract class and we need to manually define what Nextcloud will return when someone |
43 | | - * queries (requests an instance of) this class. We query Config first (this one was auto-wired) and |
44 | | - * use it's getDbType() method to instantiate the proper Db class by name. |
45 | | - * |
46 | | - * Nextcloud's dependency injection is partly explained in: |
47 | | - * https://docs.nextcloud.com/server/latest/developer_manual/basics/dependency_injection.html#how-to-deal-with-interface-and-primitive-type-parameters |
48 | | - */ |
49 | | - $context->registerService('OCA\UserBackendSqlRaw\Db', function (ContainerInterface $container) { |
50 | | - /** @var \OCA\UserBackendSqlRaw\Config $config */ |
51 | | - $config = $container->get('OCA\UserBackendSqlRaw\Config'); |
52 | | - return $container->get('OCA\UserBackendSqlRaw\Dbs\\' . ucfirst($config->getDbType())); |
53 | | - }); |
54 | | - } |
| 39 | + public function register(IRegistrationContext $context): void |
| 40 | + { |
| 41 | + /** |
| 42 | + * "Service" in this context is simply a class that you want to be able to inject. |
| 43 | + * |
| 44 | + * We don't have to register all classes because they can be auto-wired, but OCA\UserBackendSqlRaw\Db |
| 45 | + * is an abstract class and we need to manually define what Nextcloud will return when someone |
| 46 | + * queries (requests an instance of) this class. We query Config first (this one was auto-wired) and |
| 47 | + * use it's getDbType() method to instantiate the proper Db class by name. |
| 48 | + * |
| 49 | + * Nextcloud's dependency injection is partly explained in: |
| 50 | + * https://docs.nextcloud.com/server/latest/developer_manual/basics/dependency_injection.html#how-to-deal-with-interface-and-primitive-type-parameters |
| 51 | + */ |
| 52 | + $context->registerService('OCA\UserBackendSqlRaw\Db', function (ContainerInterface $container) { |
| 53 | + /** @var \OCA\UserBackendSqlRaw\Config $config */ |
| 54 | + $config = $container->get('OCA\UserBackendSqlRaw\Config'); |
| 55 | + return $container->get('OCA\UserBackendSqlRaw\Dbs\\' . ucfirst($config->getDbType())); |
| 56 | + }); |
| 57 | + } |
55 | 58 |
|
56 | | - public function boot(IBootContext $context): void { |
57 | | - $userBackendSqlRaw = $context->getAppContainer()->get(\OCA\UserBackendSqlRaw\UserBackend::class); |
58 | | - $userManager = $context->getAppContainer()->get('OCP\IUserManager'); |
59 | | - $userManager->registerBackend($userBackendSqlRaw); |
60 | | - } |
| 59 | + public function boot(IBootContext $context): void |
| 60 | + { |
| 61 | + $userBackendSqlRaw = $context->getAppContainer()->get(\OCA\UserBackendSqlRaw\UserBackend::class); |
| 62 | + $userManager = $context->getAppContainer()->get('OCP\IUserManager'); |
| 63 | + $userManager->registerBackend($userBackendSqlRaw); |
| 64 | + } |
61 | 65 | } |
0 commit comments