Email6   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 40
c 4
b 0
f 0
dl 0
loc 77
rs 10
wmc 12

1 Method

Rating   Name   Duplication   Size   Complexity  
F execute() 0 56 12
1
<?php
2
3
/**
4
 * @license GPLv3, http://www.gnu.org/copyleft/gpl.html
5
 * @copyright Metaways Infosystems GmbH, 2014
6
 * @copyright Aimeos (aimeos.org), 2014-2016
7
 * @package TYPO3
8
 */
9
10
11
namespace Aimeos\Aimeos\Scheduler\Task;
12
13
use Aimeos\Aimeos\Base;
14
use Aimeos\Aimeos\Scheduler;
15
16
17
/**
18
 * Aimeos e-mail scheduler.
19
 *
20
 * @package TYPO3
21
 */
22
class Email6 extends \TYPO3\CMS\Scheduler\Task\AbstractTask
23
{
24
    private $fieldSite = 'aimeos_sitecode';
25
    private $fieldTSconfig = 'aimeos_config';
26
    private $fieldController = 'aimeos_controller';
27
    private $fieldSenderFrom = 'aimeos_sender_from';
28
    private $fieldSenderEmail = 'aimeos_sender_email';
29
    private $fieldReplyEmail = 'aimeos_reply_email';
30
    private $fieldPageLogin = 'aimeos_pageid_login';
31
    private $fieldPageDetail = 'aimeos_pageid_detail';
32
    private $fieldPageCatalog = 'aimeos_pageid_catalog';
33
    private $fieldPageDownload = 'aimeos_pageid_download';
34
    private $fieldTemplateBaseurl = 'aimeos_template_baseurl';
35
36
37
    /**
38
     * Executes the configured tasks.
39
     *
40
     * @return bool True if success
41
     * @throws Exception If an error occurs
42
     */
43
    public function execute()
44
    {
45
        $conf = [];
46
47
        if (!isset($conf['client']['html']['catalog']['detail']['url']['config']['absoluteUri'])) {
48
            $conf['client']['html']['catalog']['detail']['url']['config']['absoluteUri'] = 1;
49
        }
50
51
        if (!isset($conf['client']['html']['account']['download']['url']['config']['absoluteUri'])) {
52
            $conf['client']['html']['account']['download']['url']['config']['absoluteUri'] = 1;
53
        }
54
55
        if ($this->{$this->fieldSenderFrom} != '') {
56
            $conf['resource']['email']['from-name'] = $this->{$this->fieldSenderFrom};
57
        }
58
59
        if ($this->{$this->fieldSenderEmail} != '') {
60
            $conf['resource']['email']['from-email'] = $this->{$this->fieldSenderEmail};
61
        }
62
63
        if ($this->{$this->fieldReplyEmail} != '') {
64
            $conf['resource']['email']['reply-email'] = $this->{$this->fieldReplyEmail};
65
        }
66
67
        if ($this->{$this->fieldPageCatalog} != '') {
68
            $conf['client']['html']['catalog']['lists']['url']['target'] = $this->{$this->fieldPageCatalog};
69
        }
70
71
        if ($this->{$this->fieldPageDetail} != '') {
72
            $conf['client']['html']['catalog']['detail']['url']['target'] = $this->{$this->fieldPageDetail};
73
        }
74
75
        if ($this->{$this->fieldPageDownload} != '') {
76
            $conf['client']['html']['account']['download']['url']['target'] = $this->{$this->fieldPageDownload};
77
        }
78
79
        if ($this->{$this->fieldPageLogin} != '') {
80
            $conf['client']['html']['account']['index']['url']['target'] = $this->{$this->fieldPageLogin};
81
        }
82
83
        if ($this->{$this->fieldTemplateBaseurl} != '') {
84
            $themeDir = $this->{$this->fieldTemplateBaseurl};
85
86
            if ($themeDir[0] !== '/') {
87
                $themeDir = realpath(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/' . $themeDir);
88
            }
89
90
            $conf['resource']['fs-theme']['basedir'] = $themeDir;
91
        }
92
93
        $tsconf = Base::parseTS($this->{$this->fieldTSconfig});
94
        $jobs = (array) $this->{$this->fieldController};
95
96
        Scheduler\Base::execute($tsconf, $conf, $jobs, $this->{$this->fieldSite}, $this->{$this->fieldPageDetail});
97
98
        return true;
99
    }
100
}
101