apply PSR-12 rules
Dieser Commit ist enthalten in:
Ursprung
f7f3ab0af4
Commit
328a98f90a
13
.php-cs-fixer.php
Normale Datei
13
.php-cs-fixer.php
Normale Datei
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in(__DIR__)
|
||||
;
|
||||
|
||||
$config = new PhpCsFixer\Config();
|
||||
return $config->setRules([
|
||||
'@PHP70Migration' => true,
|
||||
'@PSR12' => true
|
||||
])
|
||||
->setFinder($finder)
|
||||
;
|
@ -56,7 +56,7 @@ class AdminOrder extends AdminController
|
||||
public function getRecipientFromCurrentOrder()
|
||||
{
|
||||
try {
|
||||
return oxNew( OrderRecipients::class, $this->order )->getSmsRecipient();
|
||||
return oxNew(OrderRecipients::class, $this->order)->getSmsRecipient();
|
||||
} catch (noRecipientFoundException $e) {
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
Registry::getLang()->translateString($e->getMessage())
|
||||
@ -70,7 +70,7 @@ class AdminOrder extends AdminController
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
$messageBody = Registry::getRequest()->getRequestEscapedParameter( 'messagebody' );
|
||||
$messageBody = Registry::getRequest()->getRequestEscapedParameter('messagebody');
|
||||
|
||||
if (strlen($messageBody) <= 1) {
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
@ -83,16 +83,16 @@ class AdminOrder extends AdminController
|
||||
$order->load($this->getEditObjectId());
|
||||
|
||||
try {
|
||||
$sms = oxNew( Sms::class, $messageBody );
|
||||
if ( $sms->sendOrderMessage( $order ) ) {
|
||||
$this->setRemark( $sms->getRecipientsList(), $sms->getMessage() );
|
||||
$sms = oxNew(Sms::class, $messageBody);
|
||||
if ($sms->sendOrderMessage($order)) {
|
||||
$this->setRemark($sms->getRecipientsList(), $sms->getMessage());
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
oxNew(successfullySentException::class, $sms->getResponse()->getSmsCount() )
|
||||
oxNew(successfullySentException::class, $sms->getResponse()->getSmsCount())
|
||||
);
|
||||
} else {
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
sprintf(
|
||||
Registry::getLang()->translateString( 'D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND' ),
|
||||
Registry::getLang()->translateString('D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND'),
|
||||
$sms->getResponse()->getErrorMessage()
|
||||
)
|
||||
);
|
||||
@ -107,14 +107,14 @@ class AdminOrder extends AdminController
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setRemark( $recipients, $messageBody )
|
||||
protected function setRemark($recipients, $messageBody)
|
||||
{
|
||||
$remark = oxNew( Remark::class );
|
||||
$remark->assign( [
|
||||
$remark = oxNew(Remark::class);
|
||||
$remark->assign([
|
||||
'oxtype' => AdminUser::REMARK_IDENT,
|
||||
'oxparentid' => $this->order->getUser()->getId(),
|
||||
'oxtext' => $recipients.PHP_EOL.$messageBody
|
||||
] );
|
||||
]);
|
||||
$remark->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ use OxidEsales\Eshop\Core\Registry;
|
||||
|
||||
class AdminUser extends AdminController
|
||||
{
|
||||
const REMARK_IDENT = 'LMSMS';
|
||||
|
||||
public const REMARK_IDENT = 'LMSMS';
|
||||
|
||||
protected $_sThisTemplate = 'd3adminuser.tpl';
|
||||
|
||||
/**
|
||||
@ -57,7 +57,7 @@ class AdminUser extends AdminController
|
||||
public function getRecipientFromCurrentUser()
|
||||
{
|
||||
try {
|
||||
return oxNew( UserRecipients::class, $this->user )->getSmsRecipient();
|
||||
return oxNew(UserRecipients::class, $this->user)->getSmsRecipient();
|
||||
} catch (noRecipientFoundException $e) {
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
Registry::getLang()->translateString($e->getMessage())
|
||||
@ -71,7 +71,7 @@ class AdminUser extends AdminController
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
$messageBody = Registry::getRequest()->getRequestEscapedParameter( 'messagebody' );
|
||||
$messageBody = Registry::getRequest()->getRequestEscapedParameter('messagebody');
|
||||
|
||||
if (strlen($messageBody) <= 1) {
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
@ -85,7 +85,7 @@ class AdminUser extends AdminController
|
||||
|
||||
$sms = oxNew(Sms::class, $messageBody);
|
||||
if ($sms->sendUserAccountMessage($user)) {
|
||||
$this->setRemark( $sms->getRecipientsList(), $sms->getMessage() );
|
||||
$this->setRemark($sms->getRecipientsList(), $sms->getMessage());
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
sprintf(
|
||||
Registry::getLang()->translateString('D3LM_EXC_SMS_SUCC_SENT'),
|
||||
@ -95,7 +95,7 @@ class AdminUser extends AdminController
|
||||
} else {
|
||||
Registry::getUtilsView()->addErrorToDisplay(
|
||||
sprintf(
|
||||
Registry::getLang()->translateString( 'D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND' ),
|
||||
Registry::getLang()->translateString('D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND'),
|
||||
$sms->getResponse()->getErrorMessage()
|
||||
)
|
||||
);
|
||||
@ -107,14 +107,14 @@ class AdminUser extends AdminController
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setRemark( $recipients, $messageBody )
|
||||
protected function setRemark($recipients, $messageBody)
|
||||
{
|
||||
$remark = oxNew( Remark::class );
|
||||
$remark->assign( [
|
||||
$remark = oxNew(Remark::class);
|
||||
$remark->assign([
|
||||
'oxtype' => AdminUser::REMARK_IDENT,
|
||||
'oxparentid' => $this->getEditObjectId(),
|
||||
'oxtext' => $recipients.PHP_EOL.$messageBody
|
||||
] );
|
||||
]);
|
||||
$remark->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class Configuration
|
||||
*/
|
||||
public function getTestMode(): bool
|
||||
{
|
||||
return (bool) Registry::getConfig()->getConfigParam( 'd3linkmobility_debug');
|
||||
return (bool) Registry::getConfig()->getConfigParam('d3linkmobility_debug');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,4 +63,4 @@ class Configuration
|
||||
|
||||
return strtoupper($country);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,4 +16,5 @@ declare(strict_types=1);
|
||||
namespace D3\Linkmobility4OXID\Application\Model\Exceptions;
|
||||
|
||||
interface abortSendingExceptionInterface
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||
|
||||
class noRecipientFoundException extends StandardException implements abortSendingExceptionInterface
|
||||
{
|
||||
public function __construct( $sMessage = "D3LM_EXC_NO_RECIPIENT_SET", $iCode = 0, Exception $previous = null )
|
||||
public function __construct($sMessage = "D3LM_EXC_NO_RECIPIENT_SET", $iCode = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct( $sMessage, $iCode, $previous );
|
||||
parent::__construct($sMessage, $iCode, $previous);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,10 +26,10 @@ class successfullySentException extends Exception
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct( $messageCount = 1, $code = 0, Throwable $previous = null )
|
||||
public function __construct($messageCount = 1, $code = 0, Throwable $previous = null)
|
||||
{
|
||||
$message = sprintf( Registry::getLang()->translateString( 'D3LM_EXC_SMS_SUCC_SENT' ), $messageCount);
|
||||
$message = sprintf(Registry::getLang()->translateString('D3LM_EXC_SMS_SUCC_SENT'), $messageCount);
|
||||
|
||||
parent::__construct( $message, $code, $previous );
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,4 +29,4 @@ class MessageClient
|
||||
$client->setLogger(Registry::getLogger());
|
||||
return $client;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,11 +64,12 @@ class MessageSender
|
||||
}
|
||||
|
||||
try {
|
||||
$sms = oxNew( Sms::class, $messageBody );
|
||||
if ( $sms->sendOrderMessage( $order ) ) {
|
||||
$this->setRemark( $order->getId(), $sms->getRecipientsList(), $sms->getMessage() );
|
||||
$sms = oxNew(Sms::class, $messageBody);
|
||||
if ($sms->sendOrderMessage($order)) {
|
||||
$this->setRemark($order->getId(), $sms->getRecipientsList(), $sms->getMessage());
|
||||
}
|
||||
} catch (noRecipientFoundException $e) {}
|
||||
} catch (noRecipientFoundException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,12 +78,12 @@ class MessageSender
|
||||
*/
|
||||
protected function setRemark($orderId, $recipients, $message)
|
||||
{
|
||||
$remark = oxNew( Remark::class );
|
||||
$remark->assign( [
|
||||
$remark = oxNew(Remark::class);
|
||||
$remark->assign([
|
||||
'oxtype' => AdminUser::REMARK_IDENT,
|
||||
'oxparentid' => $orderId,
|
||||
'oxtext' => $recipients.PHP_EOL.$message
|
||||
] );
|
||||
]);
|
||||
$remark->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,7 @@ class OrderRecipients
|
||||
*/
|
||||
public function getSmsRecipient(): Recipient
|
||||
{
|
||||
foreach ($this->getSmsRecipientFields() as $phoneFieldName => $countryIdFieldName)
|
||||
{
|
||||
foreach ($this->getSmsRecipientFields() as $phoneFieldName => $countryIdFieldName) {
|
||||
$content = trim($this->order->getFieldData($phoneFieldName));
|
||||
|
||||
if (strlen($content)) {
|
||||
@ -72,7 +71,7 @@ class OrderRecipients
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getSanitizedCustomFields() : array
|
||||
public function getSanitizedCustomFields(): array
|
||||
{
|
||||
$customFields = (array) Registry::getConfig()->getConfigParam('d3linkmobility_smsOrderRecipientsFields');
|
||||
array_walk($customFields, [$this, 'checkFieldExists']);
|
||||
@ -85,9 +84,11 @@ class OrderRecipients
|
||||
$checkPhoneFieldName = trim($checkPhoneFieldName);
|
||||
$allFieldNames = oxNew(Order::class)->getFieldNames();
|
||||
|
||||
array_walk($allFieldNames, function(&$value) {$value = strtolower($value);});
|
||||
array_walk($allFieldNames, function (&$value) {
|
||||
$value = strtolower($value);
|
||||
});
|
||||
|
||||
$checkPhoneFieldName = in_array(strtolower($checkPhoneFieldName), $allFieldNames) &&
|
||||
in_array(strtolower($checkCountryFieldName), $allFieldNames) ? $checkPhoneFieldName : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,15 +23,15 @@ class RequestFactory extends \D3\LinkmobilityClient\SMS\RequestFactory
|
||||
{
|
||||
public function getSmsRequest(): SmsRequestInterface
|
||||
{
|
||||
$configuration = oxNew( Configuration::class );
|
||||
$configuration = oxNew(Configuration::class);
|
||||
|
||||
$request = parent::getSmsRequest();
|
||||
$request->setTestMode($configuration->getTestMode())
|
||||
->setSenderAddress(
|
||||
oxNew( Sender::class, $configuration->getSmsSenderNumber(), $configuration->getSmsSenderCountry() )
|
||||
oxNew(Sender::class, $configuration->getSmsSenderNumber(), $configuration->getSmsSenderCountry())
|
||||
)
|
||||
->setSenderAddressType( RequestInterface::SENDERADDRESSTYPE_INTERNATIONAL );
|
||||
->setSenderAddressType(RequestInterface::SENDERADDRESSTYPE_INTERNATIONAL);
|
||||
|
||||
return $request;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class Sms
|
||||
{
|
||||
try {
|
||||
return $this->sendCustomRecipientMessage(
|
||||
[ oxNew( UserRecipients::class, $user )->getSmsRecipient() ]
|
||||
[ oxNew(UserRecipients::class, $user)->getSmsRecipient() ]
|
||||
);
|
||||
} catch (noRecipientFoundException $e) {
|
||||
Registry::getLogger()->warning($e->getMessage());
|
||||
@ -72,7 +72,7 @@ class Sms
|
||||
try {
|
||||
Registry::getLogger()->debug('startRequest', ['orderId' => $order->getId()]);
|
||||
$return = $this->sendCustomRecipientMessage(
|
||||
[ oxNew( OrderRecipients::class, $order )->getSmsRecipient() ]
|
||||
[ oxNew(OrderRecipients::class, $order)->getSmsRecipient() ]
|
||||
);
|
||||
Registry::getLogger()->debug('finishRequest', ['orderId' => $order->getId()]);
|
||||
return $return;
|
||||
@ -91,12 +91,12 @@ class Sms
|
||||
{
|
||||
try {
|
||||
$this->setRecipients($recipientsArray);
|
||||
$configuration = oxNew( Configuration::class );
|
||||
$client = oxNew( MessageClient::class )->getClient();
|
||||
$configuration = oxNew(Configuration::class);
|
||||
$client = oxNew(MessageClient::class)->getClient();
|
||||
|
||||
/** @var SmsRequestInterface $request */
|
||||
$request = oxNew( RequestFactory::class, $this->getMessage(), $client )->getSmsRequest();
|
||||
$request->setTestMode( $configuration->getTestMode() )->setMethod( RequestInterface::METHOD_POST )
|
||||
$request = oxNew(RequestFactory::class, $this->getMessage(), $client)->getSmsRequest();
|
||||
$request->setTestMode($configuration->getTestMode())->setMethod(RequestInterface::METHOD_POST)
|
||||
->setSenderAddress(
|
||||
oxNew(
|
||||
Sender::class,
|
||||
@ -104,19 +104,19 @@ class Sms
|
||||
$configuration->getSmsSenderCountry()
|
||||
)
|
||||
)
|
||||
->setSenderAddressType( RequestInterface::SENDERADDRESSTYPE_INTERNATIONAL );
|
||||
->setSenderAddressType(RequestInterface::SENDERADDRESSTYPE_INTERNATIONAL);
|
||||
|
||||
$recipientsList = $request->getRecipientsList();
|
||||
foreach ($recipientsArray as $recipient) {
|
||||
$recipientsList->add( $recipient );
|
||||
$recipientsList->add($recipient);
|
||||
}
|
||||
|
||||
$response = $client->request( $request );
|
||||
$response = $client->request($request);
|
||||
|
||||
$this->response = $response;
|
||||
|
||||
if (false === $response->isSuccessful()) {
|
||||
Registry::getLogger()->warning( $response->getErrorMessage(), [$request->getBody()] );
|
||||
Registry::getLogger()->warning($response->getErrorMessage(), [$request->getBody()]);
|
||||
}
|
||||
|
||||
return $response->isSuccessful();
|
||||
@ -129,7 +129,7 @@ class Sms
|
||||
} catch (ApiException $e) {
|
||||
Registry::getLogger()->warning($e->getMessage());
|
||||
Registry::getUtilsView()->addErrorToDisplay($e);
|
||||
} catch ( InvalidArgumentException $e) {
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Registry::getLogger()->warning($e->getMessage());
|
||||
Registry::getUtilsView()->addErrorToDisplay($e);
|
||||
}
|
||||
@ -150,7 +150,7 @@ class Sms
|
||||
$this->recipients = $recipients;
|
||||
}
|
||||
|
||||
public function getRecipientsList() : string
|
||||
public function getRecipientsList(): string
|
||||
{
|
||||
$list = [];
|
||||
/** @var Recipient $recipient */
|
||||
@ -166,7 +166,7 @@ class Sms
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function sanitizeMessage($message) : string
|
||||
protected function sanitizeMessage($message): string
|
||||
{
|
||||
$message = trim(strip_tags($message));
|
||||
$message = $this->removeLineBreaks ? str_replace(["\r", "\n"], ' ', $message) : $message;
|
||||
@ -174,8 +174,8 @@ class Sms
|
||||
return $this->removeMultipleSpaces ? preg_replace($regexp, ' ', $message) : $message;
|
||||
}
|
||||
|
||||
public function getMessage() : string
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,11 +39,9 @@ class UserRecipients
|
||||
*/
|
||||
public function getSmsRecipient(): Recipient
|
||||
{
|
||||
foreach ($this->getSmsRecipientFields() as $fieldName)
|
||||
{
|
||||
foreach ($this->getSmsRecipientFields() as $fieldName) {
|
||||
$content = trim($this->user->getFieldData($fieldName));
|
||||
if (strlen($content)) {
|
||||
|
||||
$country = oxNew(Country::class);
|
||||
$country->load($this->user->getFieldData('oxcountryid'));
|
||||
|
||||
@ -73,7 +71,7 @@ class UserRecipients
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getSanitizedCustomFields() : array
|
||||
public function getSanitizedCustomFields(): array
|
||||
{
|
||||
$customFields = (array) Registry::getConfig()->getConfigParam('d3linkmobility_smsUserRecipientsFields');
|
||||
array_walk($customFields, [$this, 'checkFieldExists']);
|
||||
@ -88,8 +86,10 @@ class UserRecipients
|
||||
$checkFieldName = trim($checkFieldName);
|
||||
$allFieldNames = oxNew(User::class)->getFieldNames();
|
||||
|
||||
array_walk($allFieldNames, function(&$value) {$value = strtolower($value);});
|
||||
array_walk($allFieldNames, function (&$value) {
|
||||
$value = strtolower($value);
|
||||
});
|
||||
|
||||
$checkFieldName = in_array(strtolower($checkFieldName), $allFieldNames) ? $checkFieldName : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,12 +17,16 @@ namespace D3\Linkmobility4OXID\Modules\Aplication\Model {
|
||||
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
|
||||
class OrderModel_parent extends Order{}
|
||||
class OrderModel_parent extends Order
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace D3\Linkmobility4OXID\Modules\Core {
|
||||
|
||||
use OxidEsales\Eshop\Core\Email;
|
||||
|
||||
class EmailCore_parent extends Email{}
|
||||
}
|
||||
class EmailCore_parent extends Email
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ class OrderModel extends OrderModel_parent
|
||||
parent::cancelOrder();
|
||||
|
||||
if ($this->getFieldData('oxstorno') === 1) {
|
||||
$Email = oxNew( Email::class );
|
||||
$Email = oxNew(Email::class);
|
||||
$Email->d3SendCancelMessage($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class EmailCore extends EmailCore_parent
|
||||
*
|
||||
* @return TemplateRendererInterface
|
||||
*/
|
||||
protected function d3GetTplRenderer() : TemplateRendererInterface
|
||||
protected function d3GetTplRenderer(): TemplateRendererInterface
|
||||
{
|
||||
$bridge = ContainerFactory::getInstance()->getContainer()
|
||||
->get(TemplateRendererBridgeInterface::class);
|
||||
@ -136,4 +136,4 @@ class EmailCore extends EmailCore_parent
|
||||
|
||||
return $bridge->getTemplateRenderer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,4 +123,4 @@ $aModule = [
|
||||
'value' => false
|
||||
]
|
||||
]
|
||||
];
|
||||
];
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren