Repository navigation
Expand file tree
/
Copy pathAboutController.php
More file actions
66 lines (56 loc) · 2.16 KB
/
Copy pathAboutController.php
File metadata and controls
66 lines (56 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace ProcessMaker\Http\Controllers;
use Exception;
use ProcessMaker\Models\Setting;
use Illuminate\Support\Facades\Log;
class AboutController extends Controller
{
/**
* Get the list of users.
*
* @return \Illuminate\View\View|\Illuminate\Contracts\View
*/
public function index()
{
$root = base_path('');
$vendor_path = base_path('vendor/processmaker');
// version from composer
$composer_json_path = json_decode(file_get_contents($root . '/composer.json'));
$version = 'ProcessMaker 4 v' . $composer_json_path->version ?? '4.0.0';
$package_json_path = json_decode(file_get_contents($root . '/package.json'));
$dependencies = $package_json_path->dependencies;
$vendor_directories = \File::directories($vendor_path);
$string = '@processmaker';
$setting = Setting::byKey('indexed-search');
if ($setting && $setting->config['enabled'] === true) {
$indexedSearch = true;
} else {
$indexedSearch = false;
}
$packages = array();
foreach($vendor_directories as $directory) {
$content = json_decode(file_get_contents($vendor_path . '/' . basename($directory) . '/composer.json'));
array_push($packages, $content);
}
foreach($dependencies as $key => $value) {
if (strpos($key, $string) !== false) {
$value = str_replace('^', '', $value);
$content = new \stdClass();
$content->name = $key;
$content->version = $value;
array_push($packages, $content);
}
}
$commit_hash = false;
try {
if (is_string($composer_json_path->extra->processmaker->build)) {
$commit_hash = $composer_json_path->extra->processmaker->build;
}
} catch (Exception $exception) {
Log::warning('Commit hash missing from composer.json', [
'composer.json' => $composer_json_path
]);
}
return view('about.index', compact('packages', 'indexedSearch', 'version', 'commit_hash'));
}
}