-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60b1c3c
commit 551ff92
Showing
72 changed files
with
3,932 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* MageSpecialist | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to info@magespecialist.it so we can send you a copy immediately. | ||
* | ||
* @copyright Copyright (c) 2018 Skeeller srl (http://www.magespecialist.it) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/** | ||
* Copyright © MageSpecialist - Skeeller srl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MSP\Notifier\Command; | ||
|
||
use MSP\NotifierApi\Api\SendMessageInterface; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class SendMessage extends Command | ||
{ | ||
/** | ||
* @var SendMessageInterface | ||
*/ | ||
private $sendMessage; | ||
|
||
/** | ||
* SendMessage constructor. | ||
* @param SendMessageInterface $cleanMessage | ||
*/ | ||
public function __construct( | ||
SendMessageInterface $cleanMessage | ||
) { | ||
$this->sendMessage = $cleanMessage; | ||
|
||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function configure() | ||
{ | ||
$this->setName('msp:notifier:send'); | ||
$this->setDescription('Send a notification message'); | ||
|
||
$this->addArgument('channel', InputArgument::REQUIRED, 'Channel'); | ||
$this->addArgument('message', InputArgument::REQUIRED, 'Message'); | ||
|
||
parent::configure(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
* @SuppressWarnings("PHPMD.UnusedFormalParameter") | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$channel = $input->getArgument('channel'); | ||
$message = $input->getArgument('message'); | ||
|
||
if ($this->sendMessage->execute($channel, $message)) { | ||
$output->writeln('Message sent'); | ||
} else { | ||
$output->writeln('Could not send message'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* Copyright © MageSpecialist - Skeeller srl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MSP\Notifier\Controller\Adminhtml\Channel; | ||
|
||
use Magento\Backend\App\Action; | ||
use Magento\Framework\Controller\ResultInterface; | ||
use MSP\NotifierApi\Api\ChannelRepositoryInterface; | ||
use MSP\NotifierApi\Api\Data\ChannelInterface; | ||
|
||
class Delete extends Action | ||
{ | ||
/** | ||
* @see _isAllowed() | ||
*/ | ||
const ADMIN_RESOURCE = 'MSP_Notifier::channel'; | ||
|
||
/** | ||
* @var ChannelRepositoryInterface | ||
*/ | ||
private $channelRepository; | ||
|
||
/** | ||
* Delete constructor. | ||
* @param Action\Context $context | ||
* @param ChannelRepositoryInterface $channelRepository | ||
*/ | ||
public function __construct( | ||
Action\Context $context, | ||
ChannelRepositoryInterface $channelRepository | ||
) { | ||
parent::__construct($context); | ||
$this->channelRepository = $channelRepository; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function execute(): ResultInterface | ||
{ | ||
$channelId = (int) $this->getRequest()->getParam(ChannelInterface::ID); | ||
|
||
try { | ||
$channel = $this->channelRepository->get($channelId); | ||
$this->channelRepository->deleteById($channel->getId()); | ||
$this->messageManager->addSuccessMessage(__('Channel "%1" deleted.', $channel->getName())); | ||
} catch (\Exception $e) { | ||
$this->messageManager->addErrorMessage(__('Could not delete channel: %1.', $e->getMessage())); | ||
} | ||
|
||
$result = $this->resultRedirectFactory->create(); | ||
$result->setPath('*/*/index'); | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
/** | ||
* Copyright © MageSpecialist - Skeeller srl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MSP\Notifier\Controller\Adminhtml\Channel; | ||
|
||
use Magento\Backend\App\Action; | ||
use Magento\Framework\Controller\ResultFactory; | ||
use Magento\Framework\Controller\ResultInterface; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use MSP\NotifierApi\Api\ChannelRepositoryInterface; | ||
use MSP\NotifierApi\Api\Data\ChannelInterface; | ||
|
||
class Edit extends Action | ||
{ | ||
/** | ||
* @see _isAllowed() | ||
*/ | ||
const ADMIN_RESOURCE = 'MSP_Notifier::channel'; | ||
|
||
/** | ||
* @var ChannelRepositoryInterface | ||
*/ | ||
private $channelRepository; | ||
|
||
/** | ||
* Edit constructor. | ||
* @param Action\Context $context | ||
* @param ChannelRepositoryInterface $channelRepository | ||
*/ | ||
public function __construct( | ||
Action\Context $context, | ||
ChannelRepositoryInterface $channelRepository | ||
) { | ||
parent::__construct($context); | ||
$this->channelRepository = $channelRepository; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function execute(): ResultInterface | ||
{ | ||
$channelId = (int) $this->getRequest()->getParam(ChannelInterface::ID); | ||
try { | ||
$channel = $this->channelRepository->get($channelId); | ||
$result = $this->resultFactory->create(ResultFactory::TYPE_PAGE); | ||
$result | ||
->setActiveMenu('MSP_Notifier::channel') | ||
->addBreadcrumb(__('Edit Channel'), __('Edit Channel')); | ||
|
||
$result->getConfig() | ||
->getTitle() | ||
->prepend(__('Edit Channel: %name', ['name' => $channel->getName()])); | ||
} catch (NoSuchEntityException $e) { | ||
$result = $this->resultRedirectFactory->create(); | ||
$this->messageManager->addErrorMessage( | ||
__('Channel with id "%value" does not exist.', ['value' => $channelId]) | ||
); | ||
$result->setPath('*/*'); | ||
} | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* Copyright © MageSpecialist - Skeeller srl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MSP\Notifier\Controller\Adminhtml\Channel; | ||
|
||
use Magento\Backend\App\Action; | ||
use Magento\Backend\Model\View\Result\Page; | ||
use Magento\Framework\Controller\ResultFactory; | ||
use Magento\Framework\Controller\ResultInterface; | ||
|
||
/** | ||
* Index Controller | ||
*/ | ||
class Index extends Action | ||
{ | ||
/** | ||
* @see _isAllowed() | ||
*/ | ||
const ADMIN_RESOURCE = 'MSP_Notifier::channel'; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function execute(): ResultInterface | ||
{ | ||
/** @var Page $resultPage */ | ||
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); | ||
$resultPage | ||
->setActiveMenu('MSP_Notifier::channel') | ||
->addBreadcrumb(__('Channels'), __('List')); | ||
$resultPage->getConfig()->getTitle()->prepend(__('Manage Channels')); | ||
|
||
return $resultPage; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* Copyright © MageSpecialist - Skeeller srl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MSP\Notifier\Controller\Adminhtml\Channel; | ||
|
||
use Magento\Backend\App\Action; | ||
use Magento\Backend\Model\View\Result\Page; | ||
use Magento\Framework\Controller\ResultFactory; | ||
use Magento\Framework\Controller\ResultInterface; | ||
|
||
/** | ||
* NewAction Controller | ||
*/ | ||
class NewAction extends Action | ||
{ | ||
/** | ||
* @see _isAllowed() | ||
*/ | ||
const ADMIN_RESOURCE = 'MSP_Notifier::channel'; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function execute(): ResultInterface | ||
{ | ||
/** @var Page $resultPage */ | ||
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); | ||
$resultPage->setActiveMenu('MSP_Notifier::channel'); | ||
$resultPage->getConfig()->getTitle()->prepend(__('New channel')); | ||
|
||
return $resultPage; | ||
} | ||
} |
Oops, something went wrong.