2024.8.23
Loading...
Searching...
No Matches
class.tool.composer.php
Go to the documentation of this file.
1
<?php
2
/*
3
* Copyright (c) 2021-2024 Bearsampp
4
* License: GNU General Public License version 3 or later; see LICENSE.txt
5
* Author: Bear
6
* Website: https://bearsampp.com
7
* Github: https://github.com/Bearsampp
8
*/
9
10
/**
11
* Class ToolComposer
12
*
13
* This class represents the Composer tool module in the Bearsampp application.
14
* It extends the abstract Module class and provides functionalities specific to Composer.
15
*/
16
class
ToolComposer
extends
Module
17
{
18
/**
19
* Configuration key for the Composer version in the root configuration.
20
*/
21
const
ROOT_CFG_VERSION
=
'composerVersion'
;
22
23
/**
24
* Configuration key for the Composer executable in the local configuration.
25
*/
26
const
LOCAL_CFG_EXE
=
'composerExe'
;
27
28
/**
29
* Path to the Composer executable.
30
*
31
* @var string
32
*/
33
private
$exe
;
34
35
/**
36
* Constructor for the ToolComposer class.
37
*
38
* @param string $id The ID of the module.
39
* @param string $type The type of the module.
40
*/
41
public
function
__construct
(
$id
,
$type
) {
42
Util::logInitClass
($this);
43
$this->
reload
(
$id
,
$type
);
44
}
45
46
/**
47
* Reloads the Composer module configuration based on the provided ID and type.
48
*
49
* @param string|null $id The ID of the module. If null, the current ID is used.
50
* @param string|null $type The type of the module. If null, the current type is used.
51
*/
52
public
function
reload
(
$id
=
null
,
$type
=
null
) {
53
global
$bearsamppConfig
,
$bearsamppLang
;
54
Util::logReloadClass
($this);
55
56
$this->name =
$bearsamppLang
->getValue(
Lang::COMPOSER
);
57
$this->version =
$bearsamppConfig
->getRaw(self::ROOT_CFG_VERSION);
58
parent::reload(
$id
,
$type
);
59
60
if
($this->bearsamppConfRaw !==
false
) {
61
$this->exe = $this->symlinkPath .
'/'
. $this->bearsamppConfRaw[
self::LOCAL_CFG_EXE
];
62
}
63
64
if
(!$this->enable) {
65
Util::logInfo
($this->name .
' is not enabled!'
);
66
return
;
67
}
68
if
(!is_dir($this->currentPath)) {
69
Util::logError
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_FILE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->currentPath));
70
}
71
if
(!is_dir($this->symlinkPath)) {
72
Util::logError
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_FILE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->symlinkPath));
73
return
;
74
}
75
if
(!is_file($this->bearsamppConf)) {
76
Util::logError
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_CONF_NOT_FOUND
), $this->name .
' '
. $this->version, $this->bearsamppConf));
77
}
78
if
(!is_file($this->exe)) {
79
Util::logError
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_EXE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->exe));
80
}
81
}
82
83
/**
84
* Sets the version of the Composer module and updates the configuration.
85
*
86
* @param string $version The version to set.
87
*/
88
public
function
setVersion
(
$version
) {
89
global
$bearsamppConfig
;
90
$this->version =
$version
;
91
$bearsamppConfig
->replace(self::ROOT_CFG_VERSION,
$version
);
92
$this->
reload
();
93
}
94
95
/**
96
* Gets the path to the Composer executable.
97
*
98
* @return string The path to the Composer executable.
99
*/
100
public
function
getExe
() {
101
return
$this->exe
;
102
}
103
}
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
Lang\ERROR_FILE_NOT_FOUND
const ERROR_FILE_NOT_FOUND
Definition
class.lang.php:160
Lang\COMPOSER
const COMPOSER
Definition
class.lang.php:146
Lang\ERROR_CONF_NOT_FOUND
const ERROR_CONF_NOT_FOUND
Definition
class.lang.php:158
Lang\ERROR_EXE_NOT_FOUND
const ERROR_EXE_NOT_FOUND
Definition
class.lang.php:159
Module
Definition
class.module.php:15
Module\$type
$type
Definition
class.module.php:18
Module\$version
$version
Definition
class.module.php:22
Module\$id
$id
Definition
class.module.php:19
ToolComposer
Definition
class.tool.composer.php:17
ToolComposer\reload
reload($id=null, $type=null)
Definition
class.tool.composer.php:52
ToolComposer\LOCAL_CFG_EXE
const LOCAL_CFG_EXE
Definition
class.tool.composer.php:26
ToolComposer\getExe
getExe()
Definition
class.tool.composer.php:100
ToolComposer\__construct
__construct($id, $type)
Definition
class.tool.composer.php:41
ToolComposer\ROOT_CFG_VERSION
const ROOT_CFG_VERSION
Definition
class.tool.composer.php:21
ToolComposer\setVersion
setVersion($version)
Definition
class.tool.composer.php:88
ToolComposer\$exe
$exe
Definition
class.tool.composer.php:33
Util\logReloadClass
static logReloadClass($classInstance)
Definition
class.util.php:822
Util\logError
static logError($data, $file=null)
Definition
class.util.php:802
Util\logInitClass
static logInitClass($classInstance)
Definition
class.util.php:812
Util\logInfo
static logInfo($data, $file=null)
Definition
class.util.php:778
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:26
Bearsampp-development
sandbox
core
classes
tools
class.tool.composer.php
Generated by
1.11.0