Bearsampp 2025.8.29
Loading...
Searching...
No Matches
class.bins.php
Go to the documentation of this file.
1<?php
2/*
3 *
4 * * Copyright (c) 2021-2024 Bearsampp
5 * * License: GNU General Public License version 3 or later; see LICENSE.txt
6 * * Website: https://bearsampp.com
7 * * Github: https://github.com/Bearsampp
8 *
9 */
10
16class Bins
17{
18 const TYPE = 'bins';
19
20 private $apache;
21 private $mailpit;
22 private $mariadb;
23 private $memcached;
24 private $mysql;
25 private $nodejs;
26 private $php;
27 private $postgresql;
28 private $xlight;
29
34 public function __construct()
35 {
36 Util::logInitClass($this);
37 }
38
43 public function reload()
44 {
45 Util::logInfo('Reload bins');
46 foreach ($this->getAll() as $bin) {
47 $bin->reload();
48 }
49 }
50
55 public function update()
56 {
57 Util::logInfo('Update bins config');
58 foreach ($this->getAll() as $bin) {
59 $bin->update();
60 }
61 }
62
68 public function getAll()
69 {
70 return array(
71 $this->getApache(),
72 $this->getMailpit(),
73 $this->getMemcached(),
74 $this->getMariadb(),
75 $this->getMysql(),
76 $this->getNodejs(),
77 $this->getPhp(),
78 $this->getPostgresql(),
79 $this->getXlight(),
80 );
81 }
82
89 public function getMailpit()
90 {
91 if ($this->mailpit == null) {
92 $this->mailpit = new BinMailpit('mailpit', self::TYPE);
93 }
94 return $this->mailpit;
95 }
96
103 public function getMemcached()
104 {
105 if ($this->memcached == null) {
106 $this->memcached = new BinMemcached('memcached', self::TYPE);
107 }
108 return $this->memcached;
109 }
110
117 public function getApache()
118 {
119 if ($this->apache == null) {
120 $this->apache = new BinApache('apache', self::TYPE);
121 }
122 return $this->apache;
123 }
124
131 public function getPhp()
132 {
133 if ($this->php == null) {
134 $this->php = new BinPhp('php', self::TYPE);
135 }
136 return $this->php;
137 }
138
145 public function getMysql()
146 {
147 if ($this->mysql == null) {
148 $this->mysql = new BinMysql('mysql', self::TYPE);
149 }
150 return $this->mysql;
151 }
152
159 public function getMariadb()
160 {
161 if ($this->mariadb == null) {
162 $this->mariadb = new BinMariadb('mariadb', self::TYPE);
163 }
164 return $this->mariadb;
165 }
166
173 public function getPostgresql()
174 {
175 if ($this->postgresql == null) {
176 $this->postgresql = new BinPostgresql('postgresql', self::TYPE);
177 }
178 return $this->postgresql;
179 }
180
187 public function getNodejs()
188 {
189 if ($this->nodejs == null) {
190 $this->nodejs = new BinNodejs('nodejs', self::TYPE);
191 }
192 return $this->nodejs;
193 }
194
201 public function getXlight()
202 {
203 if ($this->xlight == null) {
204 $this->xlight = new BinXlight('xlight', self::TYPE);
205 }
206 return $this->xlight;
207 }
208
214 public function getServices()
215 {
216 $result = array();
217
218 if ($this->getMailpit()->isEnable()) {
219 $result[BinMailpit::SERVICE_NAME] = $this->getMailpit()->getService();
220 }
221 if ($this->getMemcached()->isEnable()) {
222 $result[BinMemcached::SERVICE_NAME] = $this->getMemcached()->getService();
223 }
224 if ($this->getApache()->isEnable()) {
225 $result[BinApache::SERVICE_NAME] = $this->getApache()->getService();
226 }
227 if ($this->getMysql()->isEnable()) {
228 $result[BinMysql::SERVICE_NAME] = $this->getMysql()->getService();
229 }
230 if ($this->getMariadb()->isEnable()) {
231 $result[BinMariadb::SERVICE_NAME] = $this->getMariadb()->getService();
232 }
233 if ($this->getPostgresql()->isEnable()) {
234 $result[BinPostgresql::SERVICE_NAME] = $this->getPostgresql()->getService();
235 }
236 if ($this->getXlight()->isEnable()) {
237 $result[BinXlight::SERVICE_NAME] = $this->getXlight()->getService();
238 }
239
240 return $result;
241 }
242}
$result
const SERVICE_NAME
__construct()
getMysql()
getServices()
getXlight()
getPostgresql()
getMemcached()
getApache()
reload()
update()
const TYPE
getMailpit()
$postgresql
getAll()
getMariadb()
getNodejs()
static logInitClass($classInstance)
static logInfo($data, $file=null)