Commit 0571f007 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Code reviews, cgl and buggy stuff

parent bb5c3290
......@@ -70,15 +70,4 @@ class MailRepository extends AbstractRepository {
$query->setOrderings(['tstamp' => Query::ORDER_DESCENDING]);
return $query->matching($query->logicalAnd($constraintsAnd))->execute();
}
/**
* Find a mail in the queue by its uid
*
* @param int $uid
* @return array|QueryResultInterface
*/
public function findByUid($uid) {
$query = $this->createQuery();
return $query->matching($query->equals('uid', $uid))->execute();
}
}
......@@ -76,7 +76,7 @@ class Register implements RegisterInterface {
*/
public function init() {
$templateArray = [
'fistName' => 'Max',
'firstName' => 'Max',
'lastName' => 'Mustermann'
];
......@@ -85,19 +85,19 @@ class Register implements RegisterInterface {
'marker' => 'firstname',
'type' => \SGalinski\SgMail\Service\MailTemplateService::MARKER_TYPE_STRING,
'value' => 'Max',
'description' => 'The First Name of the Customer'
'description' => 'The first name of the customer'
],
[
'marker' => 'lastname',
'type' => \SGalinski\SgMail\Service\MailTemplateService::MARKER_TYPE_STRING,
'value' => 'Mustermann',
'description' => 'The Last Name of the Customer'
'description' => 'The last name of the customer'
],
[
'marker' => 'person',
'type' => \SGalinski\SgMail\Service\MailTemplateService::MARKER_TYPE_ARRAY,
'value' => $templateArray,
'description' => 'An array with the customer Data',
'description' => 'An array with the customer data',
'usage' => '{person.firstName}, {person.lastName}'
]
];
......
......@@ -443,19 +443,20 @@ class MailTemplateService {
public function sendMailFromQueue($uid) {
$mailRepository = $this->objectManager->get(MailRepository::class);
/** @var Mail $mailToSend */
$mailToSend = $mailRepository->findByUid($uid)->getFirst();
$mailToSend = $mailRepository->findOneByUid($uid);
if ($mailToSend) {
$this->mailMessage->setBody($mailToSend->getMailBody(), 'text/html');
$this->mailMessage->setTo($mailToSend->getToAddress());
$this->mailMessage->setFrom($mailToSend->getFromAddress(), $mailToSend->getFromName());
$this->mailMessage->setSubject($mailToSend->getMailSubject());
if ($mailToSend->getCcAddresses()) {
if ($mailToSend->getBccAddresses()) {
$this->mailMessage->setBcc(GeneralUtility::trimExplode(',', $mailToSend->getBccAddresses()));
}
if ($mailToSend->getBccAddresses()) {
if ($mailToSend->getCcAddresses()) {
$this->mailMessage->setCc(GeneralUtility::trimExplode(',', $mailToSend->getCcAddresses()));
}
......
......@@ -64,4 +64,3 @@ class InlineLanguageLabelsViewHelper extends AbstractViewHelper {
';
}
}
?>
\ No newline at end of file
......@@ -29,26 +29,16 @@ namespace SGalinski\SgMail\ViewHelpers;
/**
* Checks if a fluid variable is a standard type or not
*
* @package SGalinski\SgMail\ViewHelper
*/
class TypeCheckViewHelper extends AbstractViewHelper {
/**
* Arguments Initialization
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('value', 'mixed', 'value to check', TRUE);
}
class IsArrayViewHelper extends AbstractViewHelper {
/**
* Returns true when the type is an array
* @param array $arguments
*
* @param mixed $value
* @return bool
*/
protected static function evaluateCondition($arguments = NULL) {
return (isset($arguments['value']) && (TRUE === is_array($arguments['value'])));
public function render($value) {
return (isset($value) && (is_array($value)));
}
}
?>
\ No newline at end of file
......@@ -31,14 +31,17 @@
</f:if>
</td>
<td>
<f:if condition="<sgm:typeCheck val={marker.value} />">
<f:if condition="{marker.value}">
<f:if condition="{sgm:isArray(value: '{marker.value}')}">
<f:then>
<f:for each="{marker.value}" as="value" key="key">
{key}: {value}
<br />
</f:for>
</f:then>
<f:else>
<f:translate key="{marker.value}">{marker.value}</f:translate>
</f:if>
</f:else>
</f:if>
<f:else>
{marker.usage}
</f:else>
</td>
<td>
{marker.usage}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment