mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-07 07:56:23 +00:00
ocsmsapp.php cleanup & fix
This commit is contained in:
parent
06f8f37237
commit
a5d0869dd7
@ -27,55 +27,53 @@ use \OCA\OcSms\Db\ConfigMapper;
|
||||
|
||||
class OcSmsApp extends App {
|
||||
|
||||
private $c;
|
||||
|
||||
/**
|
||||
* OcSmsApp constructor.
|
||||
* @param array $urlParams
|
||||
*/
|
||||
public function __construct (array $urlParams=array()) {
|
||||
parent::__construct('ocsms', $urlParams);
|
||||
|
||||
$container = $this->getContainer();
|
||||
$this->c = $container;
|
||||
$app = $this;
|
||||
$server = $container->query('ServerContainer');
|
||||
|
||||
/**
|
||||
* Database Layer
|
||||
*/
|
||||
$container->registerService('ConfigMapper', function (IContainer $c) use ($app) {
|
||||
$container->registerService('ConfigMapper', function (IContainer $c) use ($server) {
|
||||
return new ConfigMapper(
|
||||
$c->query('ServerContainer')->getDb(),
|
||||
$server->getDb(),
|
||||
$c->query('CurrentUID'),
|
||||
$c->query('ServerContainer')->getCrypto()
|
||||
$server->getCrypto()
|
||||
);
|
||||
});
|
||||
|
||||
$container->registerService('Sms', function(IContainer $c) {
|
||||
return new Sms($c->query('ServerContainer')->getDb());
|
||||
$container->registerService('Sms', function(IContainer $c) use ($server) {
|
||||
return new Sms($server->getDb());
|
||||
});
|
||||
|
||||
$container->registerService('SmsMapper', function(IContainer $c) {
|
||||
return new SmsMapper($c->query('ServerContainer')->getDb());
|
||||
$container->registerService('SmsMapper', function(IContainer $c) use ($server) {
|
||||
return new SmsMapper($server->getDb());
|
||||
});
|
||||
|
||||
/**
|
||||
* Managers
|
||||
*/
|
||||
$container->registerService('ContactsManager', function(IContainer $c) {
|
||||
return $server = $c->query('ServerContainer')->getContactsManager();
|
||||
$container->registerService('ContactsManager', function(IContainer $c) use ($server) {
|
||||
return $server->getContactsManager();
|
||||
});
|
||||
|
||||
/**
|
||||
* Controllers
|
||||
*/
|
||||
$container->registerService('SettingsController', function(IContainer $c) use($app) {
|
||||
$container->registerService('SettingsController', function(IContainer $c) {
|
||||
return new SettingsController(
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('ConfigMapper'),
|
||||
$app
|
||||
$c->query('ConfigMapper')
|
||||
);
|
||||
});
|
||||
|
||||
$container->registerService('SmsController', function(IContainer $c) use($app) {
|
||||
$server = $c->query('ServerContainer');
|
||||
$container->registerService('SmsController', function(IContainer $c) use($server) {
|
||||
return new SmsController(
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
@ -83,18 +81,16 @@ class OcSmsApp extends App {
|
||||
$c->query('SmsMapper'),
|
||||
$c->query('ConfigMapper'),
|
||||
$server->getContactsManager(),
|
||||
$server->getURLGenerator(),
|
||||
$app
|
||||
$server->getURLGenerator()
|
||||
);
|
||||
});
|
||||
|
||||
$container->registerService('ApiController', function(IContainer $c) use($app) {
|
||||
$container->registerService('ApiController', function(IContainer $c) {
|
||||
return new ApiController(
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('CurrentUID'),
|
||||
$c->query('SmsMapper'),
|
||||
$app
|
||||
$c->query('SmsMapper')
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -17,20 +17,16 @@ use \OCP\AppFramework\Http;
|
||||
use \OCP\AppFramework\Controller;
|
||||
use \OCP\AppFramework\Http\JSONResponse;
|
||||
|
||||
use \OCA\OcSms\AppInfo\OcSmsApp;
|
||||
|
||||
use \OCA\OcSms\Db\SmsMapper;
|
||||
|
||||
class ApiController extends Controller {
|
||||
|
||||
private $app;
|
||||
private $userId;
|
||||
private $smsMapper;
|
||||
private $errorMsg;
|
||||
|
||||
public function __construct ($appName, IRequest $request, $userId, SmsMapper $mapper, OcSmsApp $app) {
|
||||
public function __construct ($appName, IRequest $request, $userId, SmsMapper $mapper) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->app = $app;
|
||||
$this->userId = $userId;
|
||||
$this->smsMapper = $mapper;
|
||||
}
|
||||
|
@ -17,20 +17,16 @@ use \OCP\AppFramework\Controller;
|
||||
use \OCP\AppFramework\Http\JSONResponse;
|
||||
use \OCP\AppFramework\Http;
|
||||
|
||||
use \OCA\OcSms\AppInfo\OcSmsApp;
|
||||
|
||||
use \OCA\OcSms\Db\ConfigMapper;
|
||||
|
||||
use \OCA\OcSms\Lib\CountryCodes;
|
||||
|
||||
class SettingsController extends Controller {
|
||||
|
||||
private $app;
|
||||
private $configMapper;
|
||||
|
||||
public function __construct ($appName, IRequest $request, ConfigMapper $cfgMapper, OcSmsApp $app){
|
||||
public function __construct ($appName, IRequest $request, ConfigMapper $cfgMapper){
|
||||
parent::__construct($appName, $request);
|
||||
$this->app = $app;
|
||||
$this->configMapper = $cfgMapper;
|
||||
}
|
||||
|
||||
|
@ -13,14 +13,13 @@ namespace OCA\OcSms\Controller;
|
||||
|
||||
|
||||
use \OCP\IRequest;
|
||||
use \OCP\IURLGenerator;
|
||||
use \OCP\Contacts\IManager as IContactsManager;
|
||||
use \OCP\AppFramework\Http\TemplateResponse;
|
||||
use \OCP\AppFramework\Controller;
|
||||
use \OCP\AppFramework\Http\JSONResponse;
|
||||
use \OCP\AppFramework\Http;
|
||||
|
||||
use \OCA\OcSms\AppInfo\OcSmsApp;
|
||||
|
||||
use \OCA\OcSms\Db\ConfigMapper;
|
||||
use \OCA\OcSms\Db\SmsMapper;
|
||||
|
||||
@ -29,17 +28,25 @@ use \OCA\OcSms\Lib\PhoneNumberFormatter;
|
||||
|
||||
class SmsController extends Controller {
|
||||
|
||||
private $app;
|
||||
private $userId;
|
||||
private $configMapper;
|
||||
private $smsMapper;
|
||||
private $urlGenerator;
|
||||
private $contactCache;
|
||||
|
||||
/**
|
||||
* SmsController constructor.
|
||||
* @param string $appName
|
||||
* @param IRequest $request
|
||||
* @param $userId
|
||||
* @param SmsMapper $mapper
|
||||
* @param ConfigMapper $cfgMapper
|
||||
* @param IContactsManager $contactsManager
|
||||
* @param $urlGenerator
|
||||
*/
|
||||
public function __construct ($appName, IRequest $request, $userId, SmsMapper $mapper, ConfigMapper $cfgMapper,
|
||||
IContactsManager $contactsManager, $urlGenerator, OcSmsApp $app) {
|
||||
IContactsManager $contactsManager, IURLGenerator $urlGenerator) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->app = $app;
|
||||
$this->userId = $userId;
|
||||
$this->smsMapper = $mapper;
|
||||
$this->configMapper = $cfgMapper;
|
||||
|
Loading…
x
Reference in New Issue
Block a user