|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Application\View\Helper; |
|
6
|
|
|
|
|
7
|
|
|
use Application\Enum\ProductType; |
|
8
|
|
|
use Application\Model\Order; |
|
9
|
|
|
use Application\Model\OrderLine; |
|
10
|
|
|
use Laminas\View\Helper\AbstractHelper; |
|
11
|
|
|
|
|
12
|
|
|
class OrderLines extends AbstractHelper |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* This is used for custom admin and customer emails, so links must be frontend, not backend. |
|
16
|
|
|
*/ |
|
17
|
11 |
|
public function __invoke(Order $order): string |
|
18
|
|
|
{ |
|
19
|
11 |
|
$result = '<ul>'; |
|
20
|
|
|
|
|
21
|
|
|
/** @var OrderLine $line */ |
|
22
|
11 |
|
foreach ($order->getOrderLines() as $line) { |
|
23
|
11 |
|
$label = $this->view->escapeHtml($line->getName()); |
|
|
|
|
|
|
24
|
11 |
|
$price = ' <strong>' . $line->getFormattedBalance() . '</strong>'; |
|
25
|
|
|
|
|
26
|
11 |
|
$type = ''; |
|
27
|
11 |
|
switch ($line->getType()) { |
|
28
|
11 |
|
case ProductType::Both: |
|
29
|
6 |
|
$type = ', papier et numérique'; |
|
30
|
|
|
|
|
31
|
6 |
|
break; |
|
32
|
10 |
|
case ProductType::Digital: |
|
33
|
9 |
|
$type = ', numérique'; |
|
34
|
|
|
|
|
35
|
9 |
|
break; |
|
36
|
7 |
|
case ProductType::Paper: |
|
37
|
7 |
|
$type = ', papier'; |
|
38
|
|
|
|
|
39
|
7 |
|
break; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
11 |
|
if ($line->getProduct()) { |
|
43
|
8 |
|
$url = $this->view->serverUrl . '/larevuedurable/article/' . $line->getProduct()->getId(); |
|
44
|
8 |
|
$label = '<a href="' . $url . '">' . $label . ', ' . $line->getProduct()->getCode() . '</a>'; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
11 |
|
if ($line->getSubscription()) { |
|
48
|
6 |
|
$url = $this->view->serverUrl . '/larevuedurable/abonnements'; |
|
49
|
6 |
|
$label = '<a href="' . $url . '">' . $label . '</a>'; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
11 |
|
$extra = ''; |
|
53
|
11 |
|
if ($line->getAdditionalEmails()) { |
|
54
|
6 |
|
$extra .= '<ul>'; |
|
55
|
6 |
|
foreach ($line->getAdditionalEmails() as $email) { |
|
56
|
6 |
|
$extra .= '<li>' . $this->view->escapeHtml($email) . '</li>'; |
|
57
|
|
|
} |
|
58
|
6 |
|
$extra .= '</ul>'; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
11 |
|
$result .= '<li>' . $label . $type . $price . $extra . '</li>'; |
|
62
|
|
|
} |
|
63
|
11 |
|
$result .= '</ul>'; |
|
64
|
|
|
|
|
65
|
11 |
|
return $result; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.