|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
// ------------------------------------------------------------------------- |
|
4
|
|
|
// OVIDENTIA http://www.ovidentia.org |
|
5
|
|
|
// Ovidentia is free software; you can redistribute it and/or modify |
|
6
|
|
|
// it under the terms of the GNU General Public License as published by |
|
7
|
|
|
// the Free Software Foundation; either version 2, or (at your option) |
|
8
|
|
|
// any later version. |
|
9
|
|
|
// |
|
10
|
|
|
// This program is distributed in the hope that it will be useful, but |
|
11
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
13
|
|
|
// See the GNU General Public License for more details. |
|
14
|
|
|
// |
|
15
|
|
|
// You should have received a copy of the GNU General Public License |
|
16
|
|
|
// along with this program; if not, write to the Free Software |
|
17
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
18
|
|
|
// USA. |
|
19
|
|
|
// ------------------------------------------------------------------------- |
|
20
|
|
|
/** |
|
21
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) |
|
22
|
|
|
* @copyright Copyright (c) 2022 by SI4YOU ({@link https://www.siforyou.com}) |
|
23
|
|
|
*/ |
|
24
|
|
|
namespace Capwelton\LibApp\Traits; |
|
25
|
|
|
|
|
26
|
|
|
use Capwelton\LibApp\Func_App; |
|
27
|
|
|
|
|
28
|
|
|
trait LocaleApp |
|
29
|
|
|
{ |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Returns the used app of the component, or null if not found |
|
33
|
|
|
* @return NULL|Func_App |
|
34
|
|
|
*/ |
|
35
|
|
|
public static function getLocaleApp() |
|
36
|
|
|
{ |
|
37
|
|
|
try{ |
|
38
|
|
|
$rc = new \ReflectionClass(static::class); |
|
39
|
|
|
$path = new \bab_Path($rc->getFileName()); |
|
40
|
|
|
for ($popLevel = 0; $popLevel < 7; $popLevel ++){ |
|
41
|
|
|
$path->pop(); |
|
42
|
|
|
} |
|
43
|
|
|
$path->push('composer.json'); |
|
44
|
|
|
if(! $path->fileExists()){ |
|
45
|
|
|
return null; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
$composer = file_get_contents($path->tostring()); |
|
49
|
|
|
$composerjson = json_decode($composer, true); |
|
50
|
|
|
if(!isset($composerjson['appFunctionality']) || empty($composerjson['appFunctionality'])){ |
|
51
|
|
|
return null; |
|
52
|
|
|
} |
|
53
|
|
|
return \bab_functionality::get($composerjson['appFunctionality']); |
|
54
|
|
|
} |
|
55
|
|
|
catch (\Exception $e){ |
|
56
|
|
|
return null; |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
} |