Skip to content

Commit 53030d1

Browse files
Alexey Abelalexeyabel
authored andcommitted
Format code with phpfmt
1 parent 6c9ee50 commit 53030d1

File tree

7 files changed

+1655
-1559
lines changed

7 files changed

+1655
-1559
lines changed

lib/AppInfo/Application.php

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,41 +21,45 @@
2121

2222
namespace OCA\UserBackendSqlRaw\AppInfo;
2323

24-
use \OCP\AppFramework\App;
2524
use OCP\AppFramework\Bootstrap\IBootContext;
2625
use OCP\AppFramework\Bootstrap\IBootstrap;
2726
use OCP\AppFramework\Bootstrap\IRegistrationContext;
2827
use Psr\Container\ContainerInterface;
28+
use \OCP\AppFramework\App;
2929

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';
3233

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+
}
3638

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+
}
5558

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+
}
6165
}

0 commit comments

Comments
 (0)