1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Starkerxp\CampagneBundle\Render; |
4
|
|
|
|
5
|
|
|
class OctosendTxtRender extends OctosendHtmlRender |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var AbstractRender |
9
|
|
|
*/ |
10
|
|
|
private $htmlToTxtService; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* OctosendTxtRender constructor. |
14
|
|
|
* |
15
|
|
|
* @param AbstractRender $htmlToTxtService |
16
|
|
|
*/ |
17
|
|
|
public function __construct(AbstractRender $htmlToTxtService) |
18
|
|
|
{ |
19
|
|
|
$this->htmlToTxtService = $htmlToTxtService; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function render() |
23
|
|
|
{ |
24
|
|
|
// Gestion des liens de desinscriptions. |
25
|
|
|
$contenu = $this->renderLien("unsub", $this->contenu); |
26
|
|
|
// Gestion des liens click:http:// |
27
|
|
|
$contenu = $this->renderLien("click", $contenu); |
28
|
|
|
|
29
|
|
|
$this->htmlToTxtService->setContenu($contenu); |
30
|
|
|
$contenu = $this->htmlToTxtService->render(); |
31
|
|
|
|
32
|
|
|
// Gestion des liens mirror |
33
|
|
|
$contenu = $this->renderMirror($contenu); |
34
|
|
|
// Gestion des liens pixels |
35
|
|
|
$contenu = $this->renderPixel($contenu); |
36
|
|
|
|
37
|
|
|
$contenu = str_replace(' ', ' ', str_replace(' ', ' ', $contenu)); |
38
|
|
|
|
39
|
|
|
return $contenu; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function getSupport($api, $version) |
43
|
|
|
{ |
44
|
|
|
return strtolower($api) == 'octosend' && $version == 'txt'; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
protected function retournerLaChaine($type, $lien, $texte, $style = null) |
48
|
|
|
{ |
49
|
|
View Code Duplication |
if ($type == "unsub") { |
|
|
|
|
50
|
|
|
return "<a href='{{unsubscribe:".$lien."}}' style='".$style."' title='Désinscription'>".$texte.'</a>'; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
return (!empty($texte) && $texte != 'Lien' ? '['.$texte.']' : '').' {{click:'.$lien.'}}'; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.