1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Copyright 2020 SURFnet B.V. |
7
|
|
|
* |
8
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
9
|
|
|
* you may not use this file except in compliance with the License. |
10
|
|
|
* You may obtain a copy of the License at |
11
|
|
|
* |
12
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
13
|
|
|
* |
14
|
|
|
* Unless required by applicable law or agreed to in writing, software |
15
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
16
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17
|
|
|
* See the License for the specific language governing permissions and |
18
|
|
|
* limitations under the License. |
19
|
|
|
*/ |
|
|
|
|
20
|
|
|
|
21
|
|
|
namespace Surfnet\StepupSelfService\SelfServiceBundle\Service; |
22
|
|
|
|
23
|
|
|
use Surfnet\StepupSelfService\SelfServiceBundle\Assert; |
24
|
|
|
|
25
|
|
|
class ApplicationHelper |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
private $kernelProjectDir; |
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
|
|
|
|
30
|
|
|
* @param string $kernelProjectDir |
|
|
|
|
31
|
|
|
*/ |
32
|
|
|
public function __construct($kernelProjectDir) |
33
|
|
|
{ |
34
|
|
|
Assert::string($kernelProjectDir, 'Kernel project directory must have a string value'); |
35
|
|
|
$this->kernelProjectDir = $kernelProjectDir; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* In stepup application, the installation path includes the software version. This is the version that can be |
40
|
|
|
* read on the `/info` endpoint. |
41
|
|
|
* |
42
|
|
|
* For development builds, this will probably simply be Stepup-SelfService |
43
|
|
|
* |
44
|
|
|
* @return string |
45
|
|
|
*/ |
46
|
|
|
public function getApplicationVersion(): string |
47
|
|
|
{ |
48
|
|
|
// The buildPath (version string) is the installation directory of the project. And is derived from the |
49
|
|
|
// kernel.project_dir (which is the app folder). |
50
|
|
|
return basename(realpath($this->kernelProjectDir)); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|