Skip to content

Commit

Permalink
[TASK] psr-2 code formatting, MEQP2 code adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Derrick Heesbeen authored and Derrick Heesbeen committed Nov 15, 2017
1 parent e021309 commit 36b95ac
Show file tree
Hide file tree
Showing 21 changed files with 255 additions and 267 deletions.
6 changes: 1 addition & 5 deletions Block/Adminhtml/Forward/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@

class Edit extends \Magento\Backend\Block\Widget\Form\Container
{
protected function _construct()
private function _construct()
{
parent::_construct();

$this->_objectId = 'id';
$this->_controller = 'adminhtml_forward';
$this->_blockGroup = 'Experius_EmailCatcher';

$this->buttonList->remove('reset');

$this->buttonList->update('save', 'label', __('Send'));

}

}
4 changes: 2 additions & 2 deletions Block/Adminhtml/Forward/Edit/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ protected function _prepareLayout()

$emailCatcherId = $this->getRequest()->getParam('emailcatcher_id');

$emailCatcherIds = ($emailCatcherId) ? $emailCatcherId : implode(',',$this->getRequest()->getParam('selected'));
$emailCatcherIds = ($emailCatcherId) ? $emailCatcherId : implode(',', $this->getRequest()->getParam('selected'));

$form = $this->_formFactory->create();

Expand Down Expand Up @@ -41,7 +41,7 @@ protected function _prepareLayout()

$form->setUseContainer(true);
$form->setId('edit_form');
$form->setAction($this->getUrl('*/*/send',['emailcatcher_id'=>$this->getRequest()->getParam('emailcatcher_id')]));
$form->setAction($this->getUrl('*/*/send', ['emailcatcher_id'=>$this->getRequest()->getParam('emailcatcher_id')]));
$form->setMethod('post');
$this->setForm($form);
}
Expand Down
13 changes: 7 additions & 6 deletions Controller/Adminhtml/Emailcatcher/Cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,35 @@

namespace Experius\EmailCatcher\Controller\Adminhtml\Emailcatcher;


class Cleanup extends \Magento\Backend\App\Action {
class Cleanup extends \Magento\Backend\App\Action
{

protected $clean;

public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Experius\EmailCatcher\Cron\Clean $clean
){
) {
$this->clean = $clean;

parent::__construct($context);
}


public function execute(){
public function execute()
{

$resultRedirect = $this->resultRedirectFactory->create();

try {
$deleteCount = $this->clean->execute();
} catch (\Exception $e){
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
return $resultRedirect->setPath('*/*/');
}

$this->messageManager->addSuccessMessage(__('Removed %1 records from %2 days ago or older',$deleteCount,'30'));
$this->messageManager->addSuccessMessage(__('Removed %1 records from %2 days ago or older', $deleteCount, '30'));

return $resultRedirect->setPath('*/*/');
}
Expand Down
9 changes: 5 additions & 4 deletions Controller/Adminhtml/Emailcatcher/Forward.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@

namespace Experius\EmailCatcher\Controller\Adminhtml\Emailcatcher;


class Forward extends \Magento\Backend\App\Action {
class Forward extends \Magento\Backend\App\Action
{

protected $resultPageFactory;


public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
){
) {
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}


public function execute(){
public function execute()
{

$result = $this->resultPageFactory->create();
$result->getConfig()->getTitle()->prepend(__('Email Catcher'));
Expand Down
42 changes: 20 additions & 22 deletions Controller/Adminhtml/Emailcatcher/Index.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
<?php
<?php
/**
* A Magento 2 module named Experius/EmailCatcher
* Copyright (C) 2016 Derrick Heesbeen
*
*
* This file included in Experius/EmailCatcher is licensed under OSL 3.0
*
*
* http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* Please see LICENSE.txt for the full text of the OSL 3.0 license
*/

namespace Experius\EmailCatcher\Controller\Adminhtml\Emailcatcher;


class Index extends \Magento\Backend\App\Action {

protected $resultPageFactory;
class Index extends \Magento\Backend\App\Action
{


public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
){
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}
protected $resultPageFactory;


public function execute(){

$result = $this->resultPageFactory->create();
$result->getConfig()->getTitle()->prepend(__('Email Catcher'));
return $result;
}
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}

public function execute()
{
$result = $this->resultPageFactory->create();
$result->getConfig()->getTitle()->prepend(__('Email Catcher'));
return $result;
}
}
13 changes: 7 additions & 6 deletions Controller/Adminhtml/Emailcatcher/Send.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace Experius\EmailCatcher\Controller\Adminhtml\Emailcatcher;


class Send extends \Magento\Backend\App\Action {
class Send extends \Magento\Backend\App\Action
{

protected $mail;

Expand All @@ -21,14 +21,15 @@ public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Experius\EmailCatcher\Model\Mail $mail
){
) {
$this->mail = $mail;

parent::__construct($context);
}


public function execute(){
public function execute()
{

$resultRedirect = $this->resultRedirectFactory->create();

Expand All @@ -37,12 +38,12 @@ public function execute(){
$email = (isset($postData['email'])) ? $postData['email'] : false;
$emailCatcherId = (isset($postData['emailcatcher_id'])) ? $postData['emailcatcher_id'] : false;

if(!$emailCatcherId){
if (!$emailCatcherId) {
$this->messageManager->addError('Oops, something went wrong');
return $resultRedirect->setPath('*/*/');
}

$this->mail->sendMessage($emailCatcherId,$email);
$this->mail->sendMessage($emailCatcherId, $email);
$this->messageManager->addSuccessMessage('Email send to ' . $email);

return $resultRedirect->setPath('*/*/');
Expand Down
12 changes: 5 additions & 7 deletions Controller/Adminhtml/Emailcatcher/massDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,23 @@

namespace Experius\EmailCatcher\Controller\Adminhtml\Emailcatcher;


class massDelete extends \Magento\Backend\App\Action {
class massDelete extends \Magento\Backend\App\Action
{

protected $resultPageFactory;


public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
){
) {
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}


public function execute(){

die('Hello Delete');

public function execute()
{
$result = $this->resultPageFactory->create();
$result->getConfig()->getTitle()->prepend(__('Email Catcher'));
return $result;
Expand Down
61 changes: 29 additions & 32 deletions Controller/Adminhtml/Preview/Index.php
Original file line number Diff line number Diff line change
@@ -1,46 +1,43 @@
<?php
<?php
/**
* A Magento 2 module named Experius/EmailCatcher
* Copyright (C) 2016 Derrick Heesbeen
*
*
* This file included in Experius/EmailCatcher is licensed under OSL 3.0
*
*
* http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* Please see LICENSE.txt for the full text of the OSL 3.0 license
*/

namespace Experius\EmailCatcher\Controller\Adminhtml\Preview;


class Index extends \Magento\Backend\App\Action {

protected $resultPageFactory;
class Index extends \Magento\Backend\App\Action
{

protected $_emailCatcher;

public function __construct(
protected $resultRawFactory;

protected $emailCatcher;

public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Experius\EmailCatcher\Model\EmailcatcherFactory $emailCatcher
){

$this->resultPageFactory = $resultPageFactory;

$this->_emailCatcher = $emailCatcher;

parent::__construct($context);
}


public function execute(){

$id = $this->getRequest()->getParam('emailcatcher_id');
if($id){

$model = $this->_emailCatcher->create();
\Magento\Framework\Controller\Result\RawFactory $resultRawFactory,
\Experius\EmailCatcher\Model\EmailcatcherFactory $emailCatcher
) {

$this->resultRawFactory = $resultRawFactory;
$this->emailCatcher = $emailCatcher;

parent::__construct($context);
}

public function execute()
{
$id = $this->getRequest()->getParam('emailcatcher_id');
if ($id) {
$model = $this->emailCatcher->create();
$email = $model->load($id);
echo $email->getBody();
}
}
$resultRaw = $this->resultRawFactory->create();
return $resultRaw->setContents($email->getBody());
}
}
}
8 changes: 3 additions & 5 deletions Cron/Clean.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Clean
public function __construct(
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\App\ResourceConnection $resourceConnection
){
) {
$this->logger = $logger;
$this->resourceConnection = $resourceConnection;
$this->connection = $this->resourceConnection->getConnection();
Expand All @@ -41,10 +41,8 @@ public function execute()
$where
);

$this->logger->addInfo(__('Experius EmailCatcher Cleanup: Removed %1 records',$deleteCount));
$this->logger->addInfo(__('Experius EmailCatcher Cleanup: Removed %1 records', $deleteCount));

return $deleteCount;
}


}
}
11 changes: 4 additions & 7 deletions Mail/Transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Magento\Framework\Mail\TransportInterface;
use Magento\Store\Model\ScopeInterface;


class Transport implements TransportInterface
{

Expand Down Expand Up @@ -50,26 +49,25 @@ public function __construct(
$this->emailCatcher = $emailCatcher;
}

public function sendMessage(\Magento\Framework\Mail\Message $message = Null)
public function sendMessage(\Magento\Framework\Mail\Message $message = null)
{

$message = (is_null($message)) ? $this->message : $message;

if($this->scopeConfig->getValue('emailcatcher/general/enabled',\Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
if ($this->scopeConfig->getValue('emailcatcher/general/enabled', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
$this->emailCatcher->create()->saveMessage($message);
}

if($this->scopeConfig->getValue('system/smtp/disable',\Magento\Store\Model\ScopeInterface::SCOPE_STORE)){
if ($this->scopeConfig->getValue('system/smtp/disable', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
return;
}


if($this->scopeConfig->getValue('emailcatcher/general/smtp_disable',\Magento\Store\Model\ScopeInterface::SCOPE_STORE)){
if ($this->scopeConfig->getValue('emailcatcher/general/smtp_disable', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
return;
}

try {

$isSetReturnPath = $this->scopeConfig->getValue(
self::XML_PATH_SENDING_SET_RETURN_PATH,
ScopeInterface::SCOPE_STORE
Expand All @@ -88,7 +86,6 @@ public function sendMessage(\Magento\Framework\Mail\Message $message = Null)
} catch (\Exception $e) {
throw new MailException(__($e->getMessage()), $e);
}

}

public function getMessage()
Expand Down
Loading

0 comments on commit 36b95ac

Please sign in to comment.