Bearsampp 2025.8.29
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
16class ToolComposer extends Module
17{
21 const ROOT_CFG_VERSION = 'composerVersion';
22
26 const LOCAL_CFG_EXE = 'composerExe';
27
33 private $exe;
34
41 public function __construct($id, $type) {
42 Util::logInitClass($this);
43 $this->reload($id, $type);
44 }
45
52 public function reload($id = null, $type = null) {
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
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
100 public function getExe() {
101 return $this->exe;
102 }
103}
global $bearsamppLang
const COMPOSER
const ERROR_EXE_NOT_FOUND
const ERROR_CONF_NOT_FOUND
const ERROR_FILE_NOT_FOUND
reload($id=null, $type=null)
__construct($id, $type)
static logError($data, $file=null)
static logInitClass($classInstance)
static logInfo($data, $file=null)
static logReloadClass($classInstance)
global $bearsamppConfig
Definition homepage.php:27