1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GGGGino\SkuskuCartBundle\Service; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityManager; |
6
|
|
|
use GGGGino\SkuskuCartBundle\Exception\CurrencyNotFoundException; |
7
|
|
|
use GGGGino\SkuskuCartBundle\Model\SkuskuCart; |
8
|
|
|
use GGGGino\SkuskuCartBundle\Model\SkuskuCartProduct; |
9
|
|
|
use GGGGino\SkuskuCartBundle\Model\SkuskuCurrencyInterface; |
10
|
|
|
use GGGGino\SkuskuCartBundle\Model\SkuskuCustomerInterface; |
11
|
|
|
use GGGGino\SkuskuCartBundle\Model\SkuskuProductInterface; |
12
|
|
|
use Symfony\Component\Form\Form; |
13
|
|
|
use Symfony\Component\Form\FormInterface; |
14
|
|
|
use Symfony\Component\HttpFoundation\Request; |
15
|
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
16
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; |
17
|
|
|
|
18
|
|
|
class CurrencyManager implements CurrencyManagerInterface |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var EntityManager |
22
|
|
|
*/ |
23
|
|
|
private $em; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var TokenStorage |
27
|
|
|
*/ |
28
|
|
|
private $tokenStorage; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var RequestStack |
32
|
|
|
*/ |
33
|
|
|
private $requestStack; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* CartExtension constructor. |
37
|
|
|
* @param EntityManager $em |
38
|
|
|
* @param TokenStorage $tokenStorage |
39
|
|
|
* @param RequestStack $requestStack |
40
|
|
|
*/ |
41
|
|
|
public function __construct(EntityManager $em, TokenStorage $tokenStorage, RequestStack $requestStack) |
42
|
|
|
{ |
43
|
|
|
$this->em = $em; |
44
|
|
|
$this->tokenStorage = $tokenStorage; |
45
|
|
|
$this->requestStack = $requestStack; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return SkuskuCurrencyInterface[] |
50
|
|
|
*/ |
51
|
|
|
public function getActiveCurrencies() |
52
|
|
|
{ |
53
|
|
|
return $this->em->getRepository(SkuskuCurrencyInterface::class)->findAll(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return SkuskuCurrencyInterface |
58
|
|
|
* @throws CurrencyNotFoundException |
59
|
|
|
*/ |
60
|
|
|
public function getCurrentCurrency() |
61
|
|
|
{ |
62
|
|
|
/** @var string $currencyIdentifier */ |
63
|
|
|
$currencyIdentifier = $this->requestStack->getCurrentRequest()->attributes->get('skusku_cu'); |
64
|
|
|
|
65
|
|
|
/** @var SkuskuCurrencyInterface $locale */ |
66
|
|
|
$locale = $this->em->getRepository(SkuskuCurrencyInterface::class)->findOneByIsoCode($currencyIdentifier); |
|
|
|
|
67
|
|
|
|
68
|
|
|
if( !$locale ) { |
|
|
|
|
69
|
|
|
throw new CurrencyNotFoundException(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return $locale; |
73
|
|
|
} |
74
|
|
|
} |
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.