Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix128 committed Mar 2, 2018
0 parents commit 378c447
Show file tree
Hide file tree
Showing 77 changed files with 3,697 additions and 0 deletions.
16 changes: 16 additions & 0 deletions COPYING.txt
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)
*/
61 changes: 61 additions & 0 deletions Controller/Adminhtml/Rule/Delete.php
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\NotifierEvent\Controller\Adminhtml\Rule;

use Magento\Backend\App\Action;
use Magento\Framework\Controller\ResultInterface;
use MSP\NotifierEventApi\Api\RuleRepositoryInterface;
use MSP\NotifierEventApi\Api\Data\RuleInterface;

class Delete extends Action
{
/**
* @see _isAllowed()
*/
const ADMIN_RESOURCE = 'MSP_NotifierEvent::rule';

/**
* @var RuleRepositoryInterface
*/
private $ruleRepository;

/**
* Delete constructor.
* @param Action\Context $context
* @param RuleRepositoryInterface $ruleRepository
*/
public function __construct(
Action\Context $context,
RuleRepositoryInterface $ruleRepository
) {
parent::__construct($context);
$this->ruleRepository = $ruleRepository;
}

/**
* @inheritdoc
*/
public function execute(): ResultInterface
{
$ruleId = (int) $this->getRequest()->getParam(RuleInterface::ID);

try {
$rule = $this->ruleRepository->get($ruleId);
$this->ruleRepository->deleteById($rule->getId());
$this->messageManager->addSuccessMessage(__('Rule "%1" deleted.', $rule->getName()));
} catch (\Exception $e) {
$this->messageManager->addErrorMessage(__('Could not delete rule: %1.', $e->getMessage()));
}

$result = $this->resultRedirectFactory->create();
$result->setPath('*/*/index');

return $result;
}
}
69 changes: 69 additions & 0 deletions Controller/Adminhtml/Rule/Edit.php
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\NotifierEvent\Controller\Adminhtml\Rule;

use Magento\Backend\App\Action;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use MSP\NotifierEventApi\Api\RuleRepositoryInterface;
use MSP\NotifierEventApi\Api\Data\RuleInterface;

class Edit extends Action
{
/**
* @see _isAllowed()
*/
const ADMIN_RESOURCE = 'MSP_NotifierEvent::rule';

/**
* @var RuleRepositoryInterface
*/
private $ruleRepository;

/**
* Edit constructor.
* @param Action\Context $context
* @param RuleRepositoryInterface $ruleRepository
*/
public function __construct(
Action\Context $context,
RuleRepositoryInterface $ruleRepository
) {
parent::__construct($context);
$this->ruleRepository = $ruleRepository;
}

/**
* @inheritdoc
*/
public function execute(): ResultInterface
{
$ruleId = (int) $this->getRequest()->getParam(RuleInterface::ID);
try {
$rule = $this->ruleRepository->get($ruleId);
$result = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$result
->setActiveMenu('MSP_NotifierEvent::rule')
->addBreadcrumb(__('Edit Rule'), __('Edit Rule'));

$result->getConfig()
->getTitle()
->prepend(__('Edit Rule: %name', ['name' => $rule->getName()]));
} catch (NoSuchEntityException $e) {
$result = $this->resultRedirectFactory->create();
$this->messageManager->addErrorMessage(
__('Rule with id "%value" does not exist.', ['value' => $ruleId])
);
$result->setPath('*/*');
}

return $result;
}
}
40 changes: 40 additions & 0 deletions Controller/Adminhtml/Rule/Index.php
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\NotifierEvent\Controller\Adminhtml\Rule;

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_NotifierEvent::rule';

/**
* @inheritdoc
*/
public function execute(): ResultInterface
{
/** @var Page $resultPage */
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$resultPage
->setActiveMenu('MSP_NotifierEvent::rule')
->addBreadcrumb(__('Rules'), __('List'));
$resultPage->getConfig()->getTitle()->prepend(__('Manage Rules'));

return $resultPage;
}
}
38 changes: 38 additions & 0 deletions Controller/Adminhtml/Rule/NewAction.php
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\NotifierEvent\Controller\Adminhtml\Rule;

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_NotifierEvent::rule';

/**
* @inheritdoc
*/
public function execute(): ResultInterface
{
/** @var Page $resultPage */
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$resultPage->setActiveMenu('MSP_NotifierEvent::rule');
$resultPage->getConfig()->getTitle()->prepend(__('New Rule'));

return $resultPage;
}
}
Loading

0 comments on commit 378c447

Please sign in to comment.