use DI getter shorthand

This commit is contained in:
Daniel Seifert 2023-01-03 11:20:12 +01:00
parent 1558e0275e
commit 9de541eb6c
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
6 changed files with 28 additions and 28 deletions

View File

@ -36,9 +36,9 @@ class AdminOrder extends AdminSendController
public function __construct()
{
$this->item = d3DicHandler::getInstance()->get('d3ox.linkmobility.'.Order::class);
d3DicHandler::getInstance()->set(OrderRecipients::class.'.args.order', $this->item);
$this->itemRecipients = d3DicHandler::getInstance()->get(OrderRecipients::class);
$this->item = d3GetOxidDIC()->get('d3ox.linkmobility.'.Order::class);
d3GetOxidDIC()->set(OrderRecipients::class.'.args.order', $this->item);
$this->itemRecipients = d3GetOxidDIC()->get(OrderRecipients::class);
parent::__construct();
}
@ -48,9 +48,9 @@ class AdminOrder extends AdminSendController
*/
protected function sendMessage(): string
{
d3DicHandler::getInstance()->setParameter(Sms::class.'.args.message', $this->getMessageBody());
d3GetOxidDIC()->setParameter(Sms::class.'.args.message', $this->getMessageBody());
/** @var Sms $sms */
$sms = d3DicHandler::getInstance()->get(Sms::class);
$sms = d3GetOxidDIC()->get(Sms::class);
return $sms->sendOrderMessage($this->item) ?
(string) $this->getSuccessSentMessage($sms) :
$this->getUnsuccessfullySentMessage($sms);

View File

@ -63,10 +63,10 @@ abstract class AdminSendController extends AdminController
return $this->itemRecipients->getSmsRecipient();
} catch (noRecipientFoundException $e) {
/** @var Language $lang */
$lang = d3DicHandler::getInstance()->get('d3ox.linkmobility.'.Language::class);
$lang = d3GetOxidDIC()->get('d3ox.linkmobility.'.Language::class);
$message = $lang->translateString($e->getMessage());
/** @var UtilsView $utilsView */
$utilsView = d3DicHandler::getInstance()->get('d3ox.linkmobility.'.UtilsView::class);
$utilsView = d3GetOxidDIC()->get('d3ox.linkmobility.'.UtilsView::class);
$utilsView->addErrorToDisplay($message);
}
@ -79,7 +79,7 @@ abstract class AdminSendController extends AdminController
public function send(): void
{
/** @var UtilsView $utilsView */
$utilsView = d3DicHandler::getInstance()->get('d3ox.linkmobility.'.UtilsView::class);
$utilsView = d3GetOxidDIC()->get('d3ox.linkmobility.'.UtilsView::class);
try {
$utilsView->addErrorToDisplay($this->sendMessage());
@ -95,16 +95,16 @@ abstract class AdminSendController extends AdminController
protected function getMessageBody(): string
{
/** @var Request $request */
$request = d3DicHandler::getInstance()->get('d3ox.linkmobility.'.Request::class);
$request = d3GetOxidDIC()->get('d3ox.linkmobility.'.Request::class);
$messageBody = $request->getRequestEscapedParameter('messagebody');
if (false === is_string($messageBody) || strlen(trim($messageBody)) <= 1) {
d3DicHandler::getInstance()->setParameter(
d3GetOxidDIC()->setParameter(
'd3ox.linkmobility.'.InvalidArgumentException::class.'.args.message',
Registry::getLang()->translateString('D3LM_EXC_MESSAGE_NO_LENGTH')
);
/** @var InvalidArgumentException $exc */
$exc = d3DicHandler::getInstance()->get('d3ox.linkmobility.'.InvalidArgumentException::class);
$exc = d3GetOxidDIC()->get('d3ox.linkmobility.'.InvalidArgumentException::class);
throw $exc;
}
@ -124,9 +124,9 @@ abstract class AdminSendController extends AdminController
protected function getSuccessSentMessage(Sms $sms): successfullySentException
{
$smsCount = $sms->getResponse() ? $sms->getResponse()->getSmsCount() : 0;
d3DicHandler::getInstance()->setParameter(successfullySentException::class.'.args.smscount', $smsCount);
d3GetOxidDIC()->setParameter(successfullySentException::class.'.args.smscount', $smsCount);
/** @var successfullySentException $exc */
$exc = d3DicHandler::getInstance()->get(successfullySentException::class);
$exc = d3GetOxidDIC()->get(successfullySentException::class);
return $exc;
}

View File

@ -39,9 +39,9 @@ class AdminUser extends AdminSendController
public function __construct()
{
$this->item = d3DicHandler::getInstance()->get('d3ox.linkmobility.'.User::class);
d3DicHandler::getInstance()->set(UserRecipients::class.".args.user", $this->item);
$this->itemRecipients = d3DicHandler::getInstance()->get(UserRecipients::class);
$this->item = d3GetOxidDIC()->get('d3ox.linkmobility.'.User::class);
d3GetOxidDIC()->set(UserRecipients::class.".args.user", $this->item);
$this->itemRecipients = d3GetOxidDIC()->get(UserRecipients::class);
parent::__construct();
}
@ -51,9 +51,9 @@ class AdminUser extends AdminSendController
*/
protected function sendMessage(): string
{
d3DicHandler::getInstance()->setParameter(Sms::class.'.args.message', $this->getMessageBody());
d3GetOxidDIC()->setParameter(Sms::class.'.args.message', $this->getMessageBody());
/** @var Sms $sms */
$sms = d3DicHandler::getInstance()->get(Sms::class);
$sms = d3GetOxidDIC()->get(Sms::class);
return $sms->sendUserAccountMessage($this->item) ?
(string) $this->getSuccessSentMessage($sms) :
$this->getUnsuccessfullySentMessage($sms);

View File

@ -47,7 +47,7 @@ class AdminOrderTest extends AdminSend
->onlyMethods(['load'])
->getMock();
$itemMock->method('load')->willReturn(true);
d3DicHandler::getInstance()->set('d3ox.linkmobility.'.Order::class, $itemMock);
d3GetOxidDIC()->set('d3ox.linkmobility.'.Order::class, $itemMock);
$sut = parent::canConstruct();
@ -76,7 +76,7 @@ class AdminOrderTest extends AdminSend
->onlyMethods(['sendOrderMessage'])
->getMock();
$smsMock->expects($this->once())->method('sendOrderMessage')->willReturn($canSendItemMessage);
d3DicHandler::getInstance()->set(Sms::class, $smsMock);
d3GetOxidDIC()->set(Sms::class, $smsMock);
/** @var AdminOrder|MockObject $sut */
$sut = $this->getMockBuilder(AdminOrder::class)

View File

@ -148,7 +148,7 @@ class AdminSend extends LMUnitTestCase
->onlyMethods(['addErrorToDisplay'])
->getMock();
$utilsViewMock->expects($this->once())->method('addErrorToDisplay');
d3DicHandler::getInstance()->set('d3ox.linkmobility.'.UtilsView::class, $utilsViewMock);
d3GetOxidDIC()->set('d3ox.linkmobility.'.UtilsView::class, $utilsViewMock);
/** @var OrderRecipients|MockObject $itemRecipientsMock */
$itemRecipientsMock = $this->getMockBuilder($this->itemRecipientClass)
@ -158,8 +158,8 @@ class AdminSend extends LMUnitTestCase
$itemRecipientsMock->method('getSmsRecipient')->willThrowException(
oxNew(noRecipientFoundException::class)
);
d3DicHandler::getInstance()->set(OrderRecipients::class, $itemRecipientsMock);
d3DicHandler::getInstance()->set(UserRecipients::class, $itemRecipientsMock);
d3GetOxidDIC()->set(OrderRecipients::class, $itemRecipientsMock);
d3GetOxidDIC()->set(UserRecipients::class, $itemRecipientsMock);
/** @var AdminOrder|AdminUser|MockObject $sut */
$sut = $this->getMockBuilder($this->subjectUnderTestClass)
@ -201,7 +201,7 @@ class AdminSend extends LMUnitTestCase
->onlyMethods(['addErrorToDisplay'])
->getMock();
$utilsViewMock->expects($this->once())->method('addErrorToDisplay');
d3DicHandler::getInstance()->set('d3ox.linkmobility.'.UtilsView::class, $utilsViewMock);
d3GetOxidDIC()->set('d3ox.linkmobility.'.UtilsView::class, $utilsViewMock);
/** @var AdminOrder|AdminUser|MockObject $sut */
$sut = $this->getMockBuilder($this->subjectUnderTestClass)
@ -249,7 +249,7 @@ class AdminSend extends LMUnitTestCase
->onlyMethods(['getRequestEscapedParameter'])
->getMock();
$requestMock->method('getRequestEscapedParameter')->willReturn($message);
d3DicHandler::getInstance()->set('d3ox.linkmobility.'.Request::class, $requestMock);
d3GetOxidDIC()->set('d3ox.linkmobility.'.Request::class, $requestMock);
/** @var AdminOrder|AdminUser|MockObject $sut */
$sut = $this->getMockBuilder($this->subjectUnderTestClass)
@ -309,7 +309,7 @@ class AdminSend extends LMUnitTestCase
$successfullySendExceptionMock = $this->getMockBuilder(successfullySentException::class)
->disableOriginalConstructor()
->getMock();
d3DicHandler::getInstance()->set(successfullySentException::class, $successfullySendExceptionMock);
d3GetOxidDIC()->set(successfullySentException::class, $successfullySendExceptionMock);
/** @var Response|MockObject $resonseMock */
$resonseMock = $this->getMockBuilder(Response::class)

View File

@ -46,7 +46,7 @@ class AdminUserTest extends AdminSend
->onlyMethods(['load'])
->getMock();
$itemMock->method('load')->willReturn(true);
d3DicHandler::getInstance()->set('d3ox.linkmobility.'.User::class, $itemMock);
d3GetOxidDIC()->set('d3ox.linkmobility.'.User::class, $itemMock);
$sut = parent::canConstruct();
@ -75,7 +75,7 @@ class AdminUserTest extends AdminSend
->onlyMethods(['sendUserAccountMessage'])
->getMock();
$smsMock->expects($this->once())->method('sendUserAccountMessage')->willReturn($canSendItemMessage);
d3DicHandler::getInstance()->set(Sms::class, $smsMock);
d3GetOxidDIC()->set(Sms::class, $smsMock);
/** @var AdminUser|MockObject $sut */
$sut = $this->getMockBuilder(AdminUser::class)