Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some refactoring for current rn_base support #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/phpci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.0"
- "7.1"
- "7.2"
- "7.3"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/var
composer.lock
.php_cs.cache
.php-cs-fixer.cache

### eclipse files
/.buildpath
Expand Down
20 changes: 20 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

$finder = PhpCsFixer\Finder::create()
->exclude('Resources')
->exclude('Documentation')
->exclude('phpmailer')
->in(__DIR__)
;

$config = new PhpCsFixer\Config();
return $config->setFinder($finder)
->setRules([
'@Symfony' => true,
'phpdoc_align' => false,
'no_superfluous_phpdoc_tags' => false,
'fully_qualified_strict_types' => false,
'php_unit_method_casing' => false,
])
->setLineEnding("\n")
;
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php

namespace DMK\MkMailer\Frontend\Action;

use Sys25\RnBase\Frontend\Controller\AbstractAction;
use Sys25\RnBase\Frontend\Request\RequestInterface;

/***************************************************************
* Copyright notice
*
Expand All @@ -22,8 +28,6 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

tx_rnbase::load('tx_rnbase_action_BaseIOC');

/**
* tx_mkmailer_actions_SendMails.
*
Expand All @@ -33,25 +37,25 @@
* @license http://www.gnu.org/licenses/lgpl.html
* GNU Lesser General Public License, version 3 or later
*/
class tx_mkmailer_actions_SendMails extends tx_rnbase_action_BaseIOC
class SendMails extends AbstractAction
{
/**
* (non-PHPdoc).
*
* @see tx_rnbase_action_BaseIOC::handleRequest()
* @see AbstractAction::handleRequest()
*/
protected function handleRequest(&$parameters, &$configurations, &$viewdata)
protected function handleRequest(RequestInterface $request)
{
$confId = $this->getConfId();
$mailSrv = tx_mkmailer_util_ServiceRegistry::getMailService();
$mailSrv = \tx_mkmailer_util_ServiceRegistry::getMailService();

return $mailSrv->executeQueue($configurations, $this->getConfId());
}

/**
* (non-PHPdoc).
*
* @see tx_rnbase_action_BaseIOC::getTemplateName()
* @see AbstractAction::getTemplateName()
*/
protected function getTemplateName()
{
Expand All @@ -61,14 +65,10 @@ protected function getTemplateName()
/**
* (non-PHPdoc).
*
* @see tx_rnbase_action_BaseIOC::getViewClassName()
* @see AbstractAction::getViewClassName()
*/
protected function getViewClassName()
{
return '';
}
}

if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/actions/class.tx_mkmailer_actions_SendMails.php']) {
include_once $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/actions/class.tx_mkmailer_actions_SendMails.php'];
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

namespace DMK\MkMailer\Mail;

/***************************************************************
* Copyright notice
*
Expand All @@ -22,20 +25,18 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

tx_rnbase::load('tx_mkmailer_mail_IAttachment');

/**
* tx_mkmailer_mail_Attachment.
*
* @license http://www.gnu.org/licenses/lgpl.html
* GNU Lesser General Public License, version 3 or later
*/
class tx_mkmailer_mail_Attachment implements tx_mkmailer_mail_IAttachment
class Attachment implements IAttachment
{
/**
* @var int
*/
private $type = tx_mkmailer_mail_IAttachment::TYPE_ATTACHMENT;
private $type = IAttachment::TYPE_ATTACHMENT;

/**
* @var string
Expand Down Expand Up @@ -73,7 +74,7 @@ public function __construct($type)
/**
* (non-PHPdoc).
*
* @see tx_mkmailer_mail_IAttachment::getPathOrContent()
* @see IAttachment::getPathOrContent()
*/
public function getPathOrContent()
{
Expand All @@ -91,7 +92,7 @@ public function setPathOrContent($pathOrContent)
/**
* (non-PHPdoc).
*
* @see tx_mkmailer_mail_IAttachment::getName()
* @see IAttachment::getName()
*/
public function getName()
{
Expand All @@ -109,7 +110,7 @@ public function setName($name)
/**
* (non-PHPdoc).
*
* @see tx_mkmailer_mail_IAttachment::getEmbedId()
* @see IAttachment::getEmbedId()
*/
public function getEmbedId()
{
Expand All @@ -127,7 +128,7 @@ public function setEmbedId($embedId)
/**
* (non-PHPdoc).
*
* @see tx_mkmailer_mail_IAttachment::getMimeType()
* @see IAttachment::getMimeType()
*/
public function getMimeType()
{
Expand All @@ -145,7 +146,7 @@ public function setMimeType($mimeType)
/**
* (non-PHPdoc).
*
* @see tx_mkmailer_mail_IAttachment::getEncoding()
* @see IAttachment::getEncoding()
*/
public function getEncoding()
{
Expand All @@ -163,7 +164,7 @@ public function setEncoding($encoding)
/**
* (non-PHPdoc).
*
* @see tx_mkmailer_mail_IAttachment::getAttachmentType()
* @see IAttachment::getAttachmentType()
*/
public function getAttachmentType()
{
Expand All @@ -178,7 +179,3 @@ public function setAttachmentType($type)
$this->type = $type;
}
}

if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/mail/class.tx_mkmailer_mail_Attachment.php']) {
include_once $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/mail/class.tx_mkmailer_mail_Attachment.php'];
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?php

namespace DMK\MkMailer\Mail;

use DMK\MkMailer\Model\Template;
use Sys25\RnBase\Utility\Files;
use Sys25\RnBase\Utility\T3General;
use tx_mkmailer_mail_MailJob as MailJob;
use tx_rnbase;

/***************************************************************
* Copyright notice
*
Expand All @@ -21,10 +30,6 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
tx_rnbase::load('tx_mkmailer_mail_IMailJob');
tx_rnbase::load('tx_mkmailer_mail_IAttachment');
tx_rnbase::load('tx_rnbase_util_Files');
tx_rnbase::load('Tx_Rnbase_Utility_T3General');

/**
* Mail Factory.
Expand All @@ -36,22 +41,22 @@
* @license http://www.gnu.org/licenses/lgpl.html
* GNU Lesser General Public License, version 3 or later
*/
class tx_mkmailer_mail_Factory
class Factory
{
/**
* Creates a mail job.
*
* @param array[tx_mkmailer_receiver_IMailReceiver] $receiver
* @param tx_mkmailer_models_Template $templateObj
* @param \tx_mkmailer_receiver_IMailReceiver[] $receiver
* @param Template $templateObj
*
* @return tx_mkmailer_mail_MailJob
* @return \tx_mkmailer_mail_MailJob
*/
public static function createMailJob(
array $receiver = [],
tx_mkmailer_models_Template &$templateObj = null
Template &$templateObj = null
) {
return tx_rnbase::makeInstance(
'tx_mkmailer_mail_MailJob',
MailJob::class,
$receiver,
$templateObj
);
Expand All @@ -66,7 +71,7 @@ public static function createMailJob(
* @param string $encoding
* @param string $mimeType
*
* @return tx_mkmailer_mail_IAttachment
* @return IAttachment
*/
public static function createAttachment(
$path,
Expand All @@ -75,7 +80,7 @@ public static function createAttachment(
$mimeType = false
) {
return self::createAttachmentInstance(
tx_mkmailer_mail_IAttachment::TYPE_ATTACHMENT,
IAttachment::TYPE_ATTACHMENT,
self::makeAbsPath($path),
$name,
'',
Expand All @@ -93,7 +98,7 @@ public static function createAttachment(
*/
protected static function getFileInfoMimeType($absPathOrContent)
{
$finfo = new finfo(FILEINFO_MIME_TYPE);
$finfo = new \finfo(FILEINFO_MIME_TYPE);

if (is_file($absPathOrContent)) {
$mimeType = $finfo->file($absPathOrContent);
Expand All @@ -117,9 +122,9 @@ protected static function getFileInfoMimeType($absPathOrContent)
*/
public static function makeAbsPath($path)
{
if (!tx_rnbase_util_Files::isAbsPath($path)) {
$path = tx_rnbase_util_Files::getFileAbsFileName(
Tx_Rnbase_Utility_T3General::fixWindowsFilePath($path)
if (!Files::isAbsPath($path)) {
$path = Files::getFileAbsFileName(
T3General::fixWindowsFilePath($path)
);
}

Expand All @@ -134,7 +139,7 @@ public static function makeAbsPath($path)
* @param string $encoding
* @param string $mimeType
*
* @return tx_mkmailer_mail_IAttachment
* @return IAttachment
*/
public static function createStringAttachment(
$content,
Expand All @@ -143,7 +148,7 @@ public static function createStringAttachment(
$mimeType = false
) {
return self::createAttachmentInstance(
tx_mkmailer_mail_IAttachment::TYPE_ATTACHMENT,
IAttachment::TYPE_ATTACHMENT,
$content,
$name,
'',
Expand All @@ -163,7 +168,7 @@ public static function createStringAttachment(
* @param string $encoding
* @param string $mimeType
*
* @return tx_mkmailer_mail_IAttachment
* @return IAttachment
*/
public static function createEmbeddedAttachment(
$path,
Expand All @@ -173,7 +178,7 @@ public static function createEmbeddedAttachment(
$mimeType = false
) {
return self::createAttachmentInstance(
tx_mkmailer_mail_IAttachment::TYPE_ATTACHMENT,
IAttachment::TYPE_ATTACHMENT,
self::makeAbsPath($path),
$name,
$embedId,
Expand All @@ -192,7 +197,7 @@ public static function createEmbeddedAttachment(
* @param string $encoding
* @param string $mimeType
*
* @return tx_mkmailer_mail_Attachment
* @return Attachment
*/
private static function createAttachmentInstance(
$type,
Expand All @@ -202,9 +207,9 @@ private static function createAttachmentInstance(
$encoding = 'base64',
$mimeType = false
) {
/* @var $attachment tx_mkmailer_mail_Attachment */
/* @var $attachment Attachment */
$attachment = tx_rnbase::makeInstance(
'tx_mkmailer_mail_Attachment',
Attachment::class,
$type
);

Expand All @@ -227,14 +232,14 @@ private static function createAttachmentInstance(
* @param string $address
* @param string $name
*
* @return tx_mkmailer_mail_Address
* @return MailAddress
*/
public static function createAddressInstance(
$address,
$name = ''
) {
return tx_rnbase::makeInstance(
'tx_mkmailer_mail_Address',
MailAddress::class,
$address,
$name
);
Expand Down
Loading