From 640fdb41c938e82c17c3e4ae3259110dd49d4b4f Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Mon, 20 Jun 2022 15:41:50 +0200 Subject: [PATCH] initial --- composer.json | 36 ++++++++++++++ .../Model/contactMessageSender.php | 34 +++++++++++++ .../views/admin/de/d3Linkmobility_lang.php | 28 +++++++++++ src/IntelliSenseHelper.php | 21 ++++++++ .../Controller/ContactController.php | 49 +++++++++++++++++++ .../Controller/StartController.php | 37 ++++++++++++++ src/metadata.php | 45 +++++++++++++++++ 7 files changed, 250 insertions(+) create mode 100644 composer.json create mode 100644 src/Application/Model/contactMessageSender.php create mode 100644 src/Application/views/admin/de/d3Linkmobility_lang.php create mode 100644 src/IntelliSenseHelper.php create mode 100644 src/Modules/Application/Controller/ContactController.php create mode 100644 src/Modules/Application/Controller/StartController.php create mode 100644 src/metadata.php diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..badb275 --- /dev/null +++ b/composer.json @@ -0,0 +1,36 @@ +{ + "name": "d3/linkmobility4oxid", + "description": "Linkmobility for OXID eShop", + "type": "oxideshop-module", + "keywords": [ + "linkmobility", + "php", + "sms", + "sms gateway" + ], + "homepage": "https://d3data.de/", + "authors": [ + { + "name": "D3 Data Development (Inh. Thomas Dartsch)", + "email": "info@shopmodule.com", + "homepage": "https://www.d3data.de", + "role": "Owner" + } + ], + "require": { + "php": "^7.0 || ^8.0", + "oxid-esales/oxideshop-ce": "6.7 - 6.10", + "d3/linkmobility-php-client": "*" + }, + "extra": { + "oxideshop": { + "source-directory": "/src", + "target-directory": "d3/linkmobility" + } + }, + "autoload": { + "psr-4": { + "D3\\Linkmobility4OXID\\": "src" + } + } +} diff --git a/src/Application/Model/contactMessageSender.php b/src/Application/Model/contactMessageSender.php new file mode 100644 index 0000000..ae1461f --- /dev/null +++ b/src/Application/Model/contactMessageSender.php @@ -0,0 +1,34 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\Linkmobility4OXID\Modules\Application\Controller; + +use D3\LinkmobilityClient\Client; +use D3\LinkmobilityClient\Request\RequestInterface; +use D3\LinkmobilityClient\SMS\Request; +use D3\LinkmobilityClient\ValueObject\Sender; +use D3\LinkmobilityClient\ValueObject\SmsMessage; + +class contactMessageSender +{ + public function send($email, $subject, $message) + { + $lmClient = oxNew(Client::class, 'token'); + $request = oxNew(Request::class, oxNew(Sender::class, 'sender'), oxNew(SmsMessage::class, $message)); + $request->setMethod(RequestInterface::METHOD_POST); + $response = $lmClient->request($request); + dumpvar($response); + } +} \ No newline at end of file diff --git a/src/Application/views/admin/de/d3Linkmobility_lang.php b/src/Application/views/admin/de/d3Linkmobility_lang.php new file mode 100644 index 0000000..2116900 --- /dev/null +++ b/src/Application/views/admin/de/d3Linkmobility_lang.php @@ -0,0 +1,28 @@ + + * @link https://www.oxidmodule.com + */ + +declare(strict_types=1); + +$sLangName = "Deutsch"; +// ------------------------------- +// RESOURCE IDENTITFIER = STRING +// ------------------------------- +$aLang = [ + +//Navigation + 'charset' => 'UTF-8', + + 'SHOP_MODULE_GROUP_d3linkmobility_general' => 'Grundeinstellungen', + 'SHOP_MODULE_d3linkmobility_debug' => 'Debug-Modus', + 'SHOP_MODULE_d3linkmobility_apitoken' => 'API-Token' +]; diff --git a/src/IntelliSenseHelper.php b/src/IntelliSenseHelper.php new file mode 100644 index 0000000..2d6636b --- /dev/null +++ b/src/IntelliSenseHelper.php @@ -0,0 +1,21 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\Linkmobility4OXID\Modules\Application\Controller +{ + class ContactController_parent extends ContactController {} + + class StartController_parent extends StartController {} +} \ No newline at end of file diff --git a/src/Modules/Application/Controller/ContactController.php b/src/Modules/Application/Controller/ContactController.php new file mode 100644 index 0000000..bd22372 --- /dev/null +++ b/src/Modules/Application/Controller/ContactController.php @@ -0,0 +1,49 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\Linkmobility4OXID\Modules\Application\Controller; + +use D3\LinkmobilityClient\Client; +use D3\LinkmobilityClient\SMS\Request; +use D3\LinkmobilityClient\ValueObject\Sender; +use D3\LinkmobilityClient\ValueObject\SmsMessage; +use OxidEsales\Eshop\Core\Registry; +use OxidEsales\EshopCommunity\Internal\Domain\Contact\Form\ContactFormBridgeInterface; + +class ContactController extends ContactController_parent +{ + public function send() + { + $contactFormBridge = $this->getContainer()->get(ContactFormBridgeInterface::class); + + $form = $contactFormBridge->getContactForm(); + $form->handleRequest($this->getMappedContactFormRequest()); + + if ($form->isValid()) { + $contactMessageSender = oxNew(contactMessageSender::class); + $contactMessageSender->send( + $form->email->getValue(), + $form->subject->getValue(), + $contactFormBridge->getContactFormMessage($form) + ); + } else { + foreach ($form->getErrors() as $error) { + Registry::getUtilsView()->addErrorToDisplay($error); + } + + return false; + } + } +} \ No newline at end of file diff --git a/src/Modules/Application/Controller/StartController.php b/src/Modules/Application/Controller/StartController.php new file mode 100644 index 0000000..d62150c --- /dev/null +++ b/src/Modules/Application/Controller/StartController.php @@ -0,0 +1,37 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\Linkmobility4OXID\Modules\Application\Controller; + +use D3\LinkmobilityClient\Client; +use D3\LinkmobilityClient\Request\RequestInterface; +use D3\LinkmobilityClient\SMS\Request; +use D3\LinkmobilityClient\ValueObject\Sender; +use D3\LinkmobilityClient\ValueObject\SmsMessage; +use OxidEsales\Eshop\Core\Registry; + +class StartController extends StartController_parent +{ + public function render() + { + $lmClient = oxNew(Client::class, trim(Registry::getConfig()->getConfigParam('d3linkmobility_apitoken'))); + $request = oxNew(Request::class, oxNew(Sender::class, 'sender'), oxNew(SmsMessage::class, $message)); + $request->setMethod(RequestInterface::METHOD_POST); + $response = $lmClient->request($request); + dumpvar($response); + + return parent::render(); + } +} \ No newline at end of file diff --git a/src/metadata.php b/src/metadata.php new file mode 100644 index 0000000..844d6d5 --- /dev/null +++ b/src/metadata.php @@ -0,0 +1,45 @@ + '; + +/** + * Module information + */ +$aModule = [ + 'id' => $sModuleId, + 'title' => $sD3Logo . ' Linkmobility', + 'description' => [ + 'de' => 'Anbiundung an die Linkmobility API ', + 'en' => '', + ], + 'thumbnail' => 'picture.png', + 'version' => '0.1', + 'author' => 'D³ Data Development (Inh.: Thomas Dartsch)', + 'email' => 'support@shopmodule.com', + 'url' => 'https://www.oxidmodule.com/', + 'extend' => [ + \OxidEsales\Eshop\Application\Controller\StartController::class => \D3\Linkmobility4OXID\Modules\Application\Controller\StartController::class, + \OxidEsales\Eshop\Application\Controller\ContactController::class => \D3\Linkmobility4OXID\Modules\Application\Controller\ContactController::class + ], + 'controllers' => [], + 'templates' => [], + 'events' => [], + 'settings' => [ + [ + 'group' => $sModuleId.'_general', + 'name' => $sModuleId.'_debug', + 'type' => 'bool', + 'value' => false + ], + [ + 'group' => $sModuleId.'_general', + 'name' => $sModuleId.'_apitoken', + 'type' => 'str', + 'value' => false + ] + ] +]; \ No newline at end of file