1 | <?php |
||
16 | class VersionChecker |
||
17 | { |
||
18 | /** |
||
19 | * @var ContainerInterface |
||
20 | */ |
||
21 | private $container; |
||
22 | |||
23 | /** |
||
24 | * @var Cache |
||
25 | */ |
||
26 | private $cache; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $webserviceUrl; |
||
32 | |||
33 | /** |
||
34 | * @var int |
||
35 | */ |
||
36 | private $cacheTimeframe; |
||
37 | |||
38 | /** |
||
39 | * @var bool |
||
40 | */ |
||
41 | private $enabled; |
||
42 | |||
43 | /** |
||
44 | * @var Client |
||
45 | */ |
||
46 | private $client; |
||
47 | |||
48 | /** |
||
49 | * @var TranslatorInterface|LegacyTranslatorInterface |
||
50 | */ |
||
51 | private $translator; |
||
52 | |||
53 | /** |
||
54 | * Constructor |
||
55 | * |
||
56 | * @param ContainerInterface $container |
||
57 | * @param Cache $cache |
||
58 | */ |
||
59 | 7 | public function __construct(ContainerInterface $container, Cache $cache, $translator) |
|
60 | { |
||
61 | 7 | $this->container = $container; |
|
62 | 7 | $this->cache = $cache; |
|
63 | |||
64 | // NEXT_MAJOR Add "Symfony\Contracts\Translation\TranslatorInterface" typehint when sf <4.4 support is removed. |
||
65 | 7 | if (!$translator instanceof TranslatorInterface && !$translator instanceof LegacyTranslatorInterface) { |
|
66 | throw new \InvalidArgumentException(sprintf('The "$translator" parameter should be instance of "%s" or "%s"', Symfony\Contracts\Translation\TranslatorInterface::class, LegacyTranslatorInterface::class)); |
||
67 | } |
||
68 | |||
69 | 7 | $this->translator = $translator; |
|
70 | |||
71 | 7 | $this->webserviceUrl = $this->container->getParameter('version_checker.url'); |
|
72 | 7 | $this->cacheTimeframe = $this->container->getParameter('version_checker.timeframe'); |
|
73 | 7 | $this->enabled = $this->container->getParameter('version_checker.enabled'); |
|
74 | 7 | } |
|
75 | |||
76 | /** |
||
77 | * Check that the version check is enabled. |
||
78 | * |
||
79 | * @return bool |
||
80 | */ |
||
81 | 7 | public function isEnabled() |
|
85 | |||
86 | /** |
||
87 | * Check if we recently did a version check, if not do one now. |
||
88 | * |
||
89 | * @throws ParseException |
||
90 | */ |
||
91 | 1 | public function periodicallyCheck() |
|
102 | |||
103 | /** |
||
104 | * Get the version details via webservice. |
||
105 | * |
||
106 | * @return mixed a list of bundles if available |
||
107 | * |
||
108 | * @throws ParseException |
||
109 | */ |
||
110 | 5 | public function check() |
|
148 | |||
149 | /** |
||
150 | * @return Client |
||
151 | */ |
||
152 | 1 | public function getClient() |
|
160 | |||
161 | /** |
||
162 | * @param Client $client |
||
163 | */ |
||
164 | public function setClient($client) |
||
168 | |||
169 | /** |
||
170 | * Returns the absolute path to the composer.lock file. |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | protected function getLockPath() |
||
181 | |||
182 | /** |
||
183 | * Returns a list of composer packages. |
||
184 | * |
||
185 | * @return array |
||
186 | * |
||
187 | * @throws ParseException |
||
188 | */ |
||
189 | 4 | protected function getPackages() |
|
213 | |||
214 | /** |
||
215 | * Parse the composer.lock file to get the currently used versions of the kunstmaan bundles. |
||
216 | * |
||
217 | * @return array |
||
218 | * |
||
219 | * @throws ParseException |
||
220 | */ |
||
221 | 4 | protected function parseComposer() |
|
236 | } |
||
237 |