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 {
|
class OcSmsApp extends App {
|
||||||
|
|
||||||
private $c;
|
/**
|
||||||
|
* OcSmsApp constructor.
|
||||||
|
* @param array $urlParams
|
||||||
|
*/
|
||||||
public function __construct (array $urlParams=array()) {
|
public function __construct (array $urlParams=array()) {
|
||||||
parent::__construct('ocsms', $urlParams);
|
parent::__construct('ocsms', $urlParams);
|
||||||
|
|
||||||
$container = $this->getContainer();
|
$container = $this->getContainer();
|
||||||
$this->c = $container;
|
$server = $container->query('ServerContainer');
|
||||||
$app = $this;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database Layer
|
* Database Layer
|
||||||
*/
|
*/
|
||||||
$container->registerService('ConfigMapper', function (IContainer $c) use ($app) {
|
$container->registerService('ConfigMapper', function (IContainer $c) use ($server) {
|
||||||
return new ConfigMapper(
|
return new ConfigMapper(
|
||||||
$c->query('ServerContainer')->getDb(),
|
$server->getDb(),
|
||||||
$c->query('CurrentUID'),
|
$c->query('CurrentUID'),
|
||||||
$c->query('ServerContainer')->getCrypto()
|
$server->getCrypto()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$container->registerService('Sms', function(IContainer $c) {
|
$container->registerService('Sms', function(IContainer $c) use ($server) {
|
||||||
return new Sms($c->query('ServerContainer')->getDb());
|
return new Sms($server->getDb());
|
||||||
});
|
});
|
||||||
|
|
||||||
$container->registerService('SmsMapper', function(IContainer $c) {
|
$container->registerService('SmsMapper', function(IContainer $c) use ($server) {
|
||||||
return new SmsMapper($c->query('ServerContainer')->getDb());
|
return new SmsMapper($server->getDb());
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Managers
|
* Managers
|
||||||
*/
|
*/
|
||||||
$container->registerService('ContactsManager', function(IContainer $c) {
|
$container->registerService('ContactsManager', function(IContainer $c) use ($server) {
|
||||||
return $server = $c->query('ServerContainer')->getContactsManager();
|
return $server->getContactsManager();
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controllers
|
* Controllers
|
||||||
*/
|
*/
|
||||||
$container->registerService('SettingsController', function(IContainer $c) use($app) {
|
$container->registerService('SettingsController', function(IContainer $c) {
|
||||||
return new SettingsController(
|
return new SettingsController(
|
||||||
$c->query('AppName'),
|
$c->query('AppName'),
|
||||||
$c->query('Request'),
|
$c->query('Request'),
|
||||||
$c->query('ConfigMapper'),
|
$c->query('ConfigMapper')
|
||||||
$app
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$container->registerService('SmsController', function(IContainer $c) use($app) {
|
$container->registerService('SmsController', function(IContainer $c) use($server) {
|
||||||
$server = $c->query('ServerContainer');
|
|
||||||
return new SmsController(
|
return new SmsController(
|
||||||
$c->query('AppName'),
|
$c->query('AppName'),
|
||||||
$c->query('Request'),
|
$c->query('Request'),
|
||||||
@ -83,18 +81,16 @@ class OcSmsApp extends App {
|
|||||||
$c->query('SmsMapper'),
|
$c->query('SmsMapper'),
|
||||||
$c->query('ConfigMapper'),
|
$c->query('ConfigMapper'),
|
||||||
$server->getContactsManager(),
|
$server->getContactsManager(),
|
||||||
$server->getURLGenerator(),
|
$server->getURLGenerator()
|
||||||
$app
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$container->registerService('ApiController', function(IContainer $c) use($app) {
|
$container->registerService('ApiController', function(IContainer $c) {
|
||||||
return new ApiController(
|
return new ApiController(
|
||||||
$c->query('AppName'),
|
$c->query('AppName'),
|
||||||
$c->query('Request'),
|
$c->query('Request'),
|
||||||
$c->query('CurrentUID'),
|
$c->query('CurrentUID'),
|
||||||
$c->query('SmsMapper'),
|
$c->query('SmsMapper')
|
||||||
$app
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -17,20 +17,16 @@ use \OCP\AppFramework\Http;
|
|||||||
use \OCP\AppFramework\Controller;
|
use \OCP\AppFramework\Controller;
|
||||||
use \OCP\AppFramework\Http\JSONResponse;
|
use \OCP\AppFramework\Http\JSONResponse;
|
||||||
|
|
||||||
use \OCA\OcSms\AppInfo\OcSmsApp;
|
|
||||||
|
|
||||||
use \OCA\OcSms\Db\SmsMapper;
|
use \OCA\OcSms\Db\SmsMapper;
|
||||||
|
|
||||||
class ApiController extends Controller {
|
class ApiController extends Controller {
|
||||||
|
|
||||||
private $app;
|
|
||||||
private $userId;
|
private $userId;
|
||||||
private $smsMapper;
|
private $smsMapper;
|
||||||
private $errorMsg;
|
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);
|
parent::__construct($appName, $request);
|
||||||
$this->app = $app;
|
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->smsMapper = $mapper;
|
$this->smsMapper = $mapper;
|
||||||
}
|
}
|
||||||
|
@ -17,20 +17,16 @@ use \OCP\AppFramework\Controller;
|
|||||||
use \OCP\AppFramework\Http\JSONResponse;
|
use \OCP\AppFramework\Http\JSONResponse;
|
||||||
use \OCP\AppFramework\Http;
|
use \OCP\AppFramework\Http;
|
||||||
|
|
||||||
use \OCA\OcSms\AppInfo\OcSmsApp;
|
|
||||||
|
|
||||||
use \OCA\OcSms\Db\ConfigMapper;
|
use \OCA\OcSms\Db\ConfigMapper;
|
||||||
|
|
||||||
use \OCA\OcSms\Lib\CountryCodes;
|
use \OCA\OcSms\Lib\CountryCodes;
|
||||||
|
|
||||||
class SettingsController extends Controller {
|
class SettingsController extends Controller {
|
||||||
|
|
||||||
private $app;
|
|
||||||
private $configMapper;
|
private $configMapper;
|
||||||
|
|
||||||
public function __construct ($appName, IRequest $request, ConfigMapper $cfgMapper, OcSmsApp $app){
|
public function __construct ($appName, IRequest $request, ConfigMapper $cfgMapper){
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->app = $app;
|
|
||||||
$this->configMapper = $cfgMapper;
|
$this->configMapper = $cfgMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,14 +13,13 @@ namespace OCA\OcSms\Controller;
|
|||||||
|
|
||||||
|
|
||||||
use \OCP\IRequest;
|
use \OCP\IRequest;
|
||||||
|
use \OCP\IURLGenerator;
|
||||||
use \OCP\Contacts\IManager as IContactsManager;
|
use \OCP\Contacts\IManager as IContactsManager;
|
||||||
use \OCP\AppFramework\Http\TemplateResponse;
|
use \OCP\AppFramework\Http\TemplateResponse;
|
||||||
use \OCP\AppFramework\Controller;
|
use \OCP\AppFramework\Controller;
|
||||||
use \OCP\AppFramework\Http\JSONResponse;
|
use \OCP\AppFramework\Http\JSONResponse;
|
||||||
use \OCP\AppFramework\Http;
|
use \OCP\AppFramework\Http;
|
||||||
|
|
||||||
use \OCA\OcSms\AppInfo\OcSmsApp;
|
|
||||||
|
|
||||||
use \OCA\OcSms\Db\ConfigMapper;
|
use \OCA\OcSms\Db\ConfigMapper;
|
||||||
use \OCA\OcSms\Db\SmsMapper;
|
use \OCA\OcSms\Db\SmsMapper;
|
||||||
|
|
||||||
@ -29,17 +28,25 @@ use \OCA\OcSms\Lib\PhoneNumberFormatter;
|
|||||||
|
|
||||||
class SmsController extends Controller {
|
class SmsController extends Controller {
|
||||||
|
|
||||||
private $app;
|
|
||||||
private $userId;
|
private $userId;
|
||||||
private $configMapper;
|
private $configMapper;
|
||||||
private $smsMapper;
|
private $smsMapper;
|
||||||
private $urlGenerator;
|
private $urlGenerator;
|
||||||
private $contactCache;
|
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,
|
public function __construct ($appName, IRequest $request, $userId, SmsMapper $mapper, ConfigMapper $cfgMapper,
|
||||||
IContactsManager $contactsManager, $urlGenerator, OcSmsApp $app) {
|
IContactsManager $contactsManager, IURLGenerator $urlGenerator) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->app = $app;
|
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->smsMapper = $mapper;
|
$this->smsMapper = $mapper;
|
||||||
$this->configMapper = $cfgMapper;
|
$this->configMapper = $cfgMapper;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user