Issues (44)

Service/LangManager.php (1 issue)

1
<?php
2
3
namespace GGGGino\SkuskuCartBundle\Service;
4
5
use Doctrine\ORM\EntityManager;
6
use GGGGino\SkuskuCartBundle\Model\SkuskuCart;
7
use GGGGino\SkuskuCartBundle\Model\SkuskuCartProduct;
8
use GGGGino\SkuskuCartBundle\Model\SkuskuCustomerInterface;
9
use GGGGino\SkuskuCartBundle\Model\SkuskuLangInterface;
10
use GGGGino\SkuskuCartBundle\Model\SkuskuProductInterface;
11
use Symfony\Component\Form\Form;
12
use Symfony\Component\Form\FormInterface;
13
use Symfony\Component\HttpFoundation\Request;
14
use Symfony\Component\HttpFoundation\RequestStack;
15
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
16
17
class LangManager implements LangManagerInterface
18
{
19
    /**
20
     * @var EntityManager
21
     */
22
    private $em;
23
24
    /**
25
     * @var TokenStorage
26
     */
27
    private $tokenStorage;
28
29
    /**
30
     * @var RequestStack
31
     */
32
    private $requestStack;
33
34
    /**
35
     * CartExtension constructor.
36
     * @param EntityManager $em
37
     * @param TokenStorage $tokenStorage
38
     * @param RequestStack $requestStack
39
     */
40
    public function __construct(EntityManager $em, TokenStorage $tokenStorage, RequestStack $requestStack)
41
    {
42
        $this->em = $em;
43
        $this->tokenStorage = $tokenStorage;
44
        $this->requestStack = $requestStack;
45
    }
46
47
    /**
48
     * @return SkuskuLangInterface[]
49
     */
50
    public function getActiveLanguages()
51
    {
52
        return $this->em->getRepository(SkuskuLangInterface::class)->findAll();
53
    }
54
55
    /**
56
     * @return SkuskuLangInterface
57
     */
58
    public function getCurrentLanguage()
59
    {
60
        /** @var string $localeIdentifier */
61
        $localeIdentifier = $this->requestStack->getCurrentRequest()->getLocale();
62
63
        /** @var SkuskuLangInterface $locale */
64
        $locale = $this->em->getRepository(SkuskuLangInterface::class)->findOneByIdentifier($localeIdentifier);
0 ignored issues
show
The method findOneByIdentifier() does not exist on Doctrine\Common\Persistence\ObjectRepository. Did you maybe mean findOneBy()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

64
        $locale = $this->em->getRepository(SkuskuLangInterface::class)->/** @scrutinizer ignore-call */ findOneByIdentifier($localeIdentifier);

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.

Loading history...
65
66
        return $locale;
67
    }
68
69
    /**
70
     * @param EntityManager $em
71
     * @return LangManager
72
     */
73
    public function setEm($em)
74
    {
75
        $this->em = $em;
76
        return $this;
77
    }
78
}