1
|
|
|
<?php |
2
|
|
|
namespace App\BxConsole\Bitrix; |
3
|
|
|
|
4
|
|
|
use Bitrix\Main\ModuleManager; |
|
|
|
|
5
|
|
|
|
6
|
|
|
class Loader { |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @return bool |
10
|
|
|
*/ |
11
|
|
|
public function initializeBitrix() { |
12
|
|
|
|
13
|
|
|
if($this->checkBitrix()) { |
14
|
|
|
|
15
|
|
|
if (defined('B_PROLOG_INCLUDED') && B_PROLOG_INCLUDED === true) { |
|
|
|
|
16
|
|
|
return true; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Declare global legacy variables |
21
|
|
|
* |
22
|
|
|
* Including kernel here makes them local by default but some modules depend on them in installation class |
23
|
|
|
*/ |
24
|
|
|
global |
25
|
|
|
/** @noinspection PhpUnusedLocalVariableInspection */ |
26
|
|
|
$DB, $DBType, $DBHost, $DBLogin, $DBPassword, $DBName, $DBDebug, $DBDebugToFile, $APPLICATION, $USER, $DBSQLServerType; |
27
|
|
|
|
28
|
|
|
define('SM_SAFE_MODE', true); |
29
|
|
|
define('NO_KEEP_STATISTIC', true); |
30
|
|
|
define('NO_AGENT_STATISTIC', true); |
31
|
|
|
define('NO_AGENT_CHECK', true); |
32
|
|
|
define('NOT_CHECK_PERMISSIONS', true); |
33
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php'; |
34
|
|
|
|
35
|
|
|
if(class_exists('\Bitrix\Main\Analytics\Counter')) { |
36
|
|
|
\Bitrix\Main\Analytics\Counter::disable(); |
|
|
|
|
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
if (defined('B_PROLOG_INCLUDED') && B_PROLOG_INCLUDED === true) { |
40
|
|
|
return true; |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return false; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Check if Bitrix kernel exists |
49
|
|
|
* @return bool |
50
|
|
|
*/ |
51
|
|
|
public function checkBitrix() { |
52
|
|
|
|
53
|
|
|
return is_file($_SERVER['DOCUMENT_ROOT'] . '/bitrix/.settings.php'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Load commands from specific cli.php |
58
|
|
|
* @return array |
59
|
|
|
* @throws \Bitrix\Main\LoaderException |
60
|
|
|
*/ |
61
|
|
|
public function getModulesCommands() |
62
|
|
|
{ |
63
|
|
|
$commands = []; |
64
|
|
|
|
65
|
|
|
foreach (ModuleManager::getInstalledModules() as $module) { |
66
|
|
|
|
67
|
|
|
$cliFile = getLocalPath('modules/' . $module['ID'] . '/.cli.php'); |
|
|
|
|
68
|
|
|
|
69
|
|
|
if(!$cliFile) { |
70
|
|
|
continue; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
\Bitrix\Main\Loader::includeModule($module['ID']); |
|
|
|
|
74
|
|
|
$config = include $_SERVER['DOCUMENT_ROOT'] . $cliFile; |
75
|
|
|
|
76
|
|
|
if (is_array($config['commands']) && count($config['commands']) > 0) { |
77
|
|
|
$commands = array_merge($commands, $config['commands']); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
return $commands; |
82
|
|
|
} |
83
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths