2024.8.23
Loading...
Searching...
No Matches
class.tool.yarn.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 ToolYarn
12
*
13
* This class represents the Yarn tool module in the Bearsampp application.
14
* It extends the abstract Module class and provides specific functionalities
15
* for managing the Yarn tool, including version management and executable path handling.
16
*/
17
class
ToolYarn
extends
Module
18
{
19
/**
20
* Configuration key for the Yarn version in the root configuration.
21
*/
22
const
ROOT_CFG_VERSION
=
'yarnVersion'
;
23
24
/**
25
* Configuration key for the Yarn executable in the local configuration.
26
*/
27
const
LOCAL_CFG_EXE
=
'yarnExe'
;
28
29
/**
30
* Path to the Yarn executable.
31
*
32
* @var string
33
*/
34
private
$exe
;
35
36
/**
37
* Constructor for the ToolYarn class.
38
*
39
* @param string $id The ID of the module.
40
* @param string $type The type of the module.
41
*/
42
public
function
__construct
(
$id
,
$type
) {
43
Util::logInitClass
($this);
44
$this->
reload
(
$id
,
$type
);
45
}
46
47
/**
48
* Reloads the Yarn module configuration based on the provided ID and type.
49
*
50
* @param string|null $id The ID of the module. If null, the current ID is used.
51
* @param string|null $type The type of the module. If null, the current type is used.
52
*/
53
public
function
reload
(
$id
=
null
,
$type
=
null
) {
54
global
$bearsamppConfig
,
$bearsamppLang
;
55
Util::logReloadClass
($this);
56
57
$this->name =
$bearsamppLang
->getValue(
Lang::YARN
);
58
$this->version =
$bearsamppConfig
->getRaw(self::ROOT_CFG_VERSION);
59
parent::reload(
$id
,
$type
);
60
61
if
($this->bearsamppConfRaw !==
false
) {
62
$this->exe = $this->symlinkPath .
'/'
. $this->bearsamppConfRaw[
self::LOCAL_CFG_EXE
];
63
}
64
65
if
(!$this->enable) {
66
Util::logInfo
($this->name .
' is not enabled!'
);
67
return
;
68
}
69
if
(!is_dir($this->currentPath)) {
70
Util::logError
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_FILE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->currentPath));
71
}
72
if
(!is_dir($this->symlinkPath)) {
73
Util::logError
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_FILE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->symlinkPath));
74
return
;
75
}
76
if
(!is_file($this->bearsamppConf)) {
77
Util::logError
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_CONF_NOT_FOUND
), $this->name .
' '
. $this->version, $this->bearsamppConf));
78
}
79
if
(!is_file($this->exe)) {
80
Util::logError
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_EXE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->exe));
81
}
82
}
83
84
/**
85
* Sets the version of the Yarn module and updates the configuration.
86
*
87
* @param string $version The version to set.
88
*/
89
public
function
setVersion
(
$version
) {
90
global
$bearsamppConfig
;
91
$this->version =
$version
;
92
$bearsamppConfig
->replace(self::ROOT_CFG_VERSION,
$version
);
93
$this->
reload
();
94
}
95
96
/**
97
* Gets the path to the Yarn executable.
98
*
99
* @return string The path to the Yarn executable.
100
*/
101
public
function
getExe
() {
102
return
$this->exe
;
103
}
104
}
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
Lang\ERROR_FILE_NOT_FOUND
const ERROR_FILE_NOT_FOUND
Definition
class.lang.php:160
Lang\YARN
const YARN
Definition
class.lang.php:155
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
ToolYarn
Definition
class.tool.yarn.php:18
ToolYarn\ROOT_CFG_VERSION
const ROOT_CFG_VERSION
Definition
class.tool.yarn.php:22
ToolYarn\setVersion
setVersion($version)
Definition
class.tool.yarn.php:89
ToolYarn\$exe
$exe
Definition
class.tool.yarn.php:34
ToolYarn\LOCAL_CFG_EXE
const LOCAL_CFG_EXE
Definition
class.tool.yarn.php:27
ToolYarn\__construct
__construct($id, $type)
Definition
class.tool.yarn.php:42
ToolYarn\getExe
getExe()
Definition
class.tool.yarn.php:101
ToolYarn\reload
reload($id=null, $type=null)
Definition
class.tool.yarn.php:53
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.yarn.php
Generated by
1.11.0