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