Bearsampp 2026.9.23
Loading...
Searching...
No Matches
class.bins.php
Go to the documentation of this file.
1<?php
2/*
3 *
4 * * Copyright (c) 2021-2026 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{
21 const TYPE = 'bins';
22
24 private $apache;
26 private $mailpit;
28 private $mariadb;
30 private $memcached;
32 private $mysql;
34 private $nodejs;
36 private $php;
38 private $postgresql;
40 private $xlight;
41
46 public function __construct()
47 {
48 Log::initClass($this);
49 }
50
55 public function reload()
56 {
57 Log::info('Reload bins');
58 foreach ($this->getAll() as $bin) {
59 $bin->reload();
60 }
61 }
62
67 public function update()
68 {
69 Log::info('Update bins config');
70 foreach ($this->getAll() as $bin) {
71 $bin->update();
72 }
73 }
74
80 public function getAll()
81 {
82 return array(
83 $this->getApache(),
84 $this->getMailpit(),
85 $this->getMemcached(),
86 $this->getMariadb(),
87 $this->getMysql(),
88 $this->getNodejs(),
89 $this->getPhp(),
90 $this->getPostgresql(),
91 $this->getXlight(),
92 );
93 }
94
101 public function getMailpit()
102 {
103 if ($this->mailpit == null) {
104 $this->mailpit = new BinMailpit('mailpit', self::TYPE);
105 }
106
107 return $this->mailpit;
108 }
109
116 public function getMemcached()
117 {
118 if ($this->memcached == null) {
119 $this->memcached = new BinMemcached('memcached', self::TYPE);
120 }
121
122 return $this->memcached;
123 }
124
131 public function getApache()
132 {
133 if ($this->apache == null) {
134 $this->apache = new BinApache('apache', self::TYPE);
135 }
136
137 return $this->apache;
138 }
139
146 public function getPhp()
147 {
148 if ($this->php == null) {
149 $this->php = new BinPhp('php', self::TYPE);
150 }
151
152 return $this->php;
153 }
154
161 public function getMysql()
162 {
163 if ($this->mysql == null) {
164 $this->mysql = new BinMysql('mysql', self::TYPE);
165 }
166
167 return $this->mysql;
168 }
169
176 public function getMariadb()
177 {
178 if ($this->mariadb == null) {
179 $this->mariadb = new BinMariadb('mariadb', self::TYPE);
180 }
181
182 return $this->mariadb;
183 }
184
191 public function getPostgresql()
192 {
193 if ($this->postgresql == null) {
194 $this->postgresql = new BinPostgresql('postgresql', self::TYPE);
195 }
196
197 return $this->postgresql;
198 }
199
206 public function getNodejs()
207 {
208 if ($this->nodejs == null) {
209 $this->nodejs = new BinNodejs('nodejs', self::TYPE);
210 }
211
212 return $this->nodejs;
213 }
214
221 public function getXlight()
222 {
223 if ($this->xlight == null) {
224 $this->xlight = new BinXlight('xlight', self::TYPE);
225 }
226
227 return $this->xlight;
228 }
229
241 public function getBinByName(string $name): ?object
242 {
243 foreach ($this->getAll() as $bin) {
244 if ($bin->getName() === $name) {
245 return $bin;
246 }
247 }
248
249 return null;
250 }
251
257 public function getServices()
258 {
259 $result = array();
260
261 if ($this->getMailpit()->isEnable()) {
262 $result[BinMailpit::SERVICE_NAME] = $this->getMailpit()->getService();
263 }
264 if ($this->getMemcached()->isEnable()) {
265 $result[BinMemcached::SERVICE_NAME] = $this->getMemcached()->getService();
266 }
267 if ($this->getApache()->isEnable()) {
268 $result[BinApache::SERVICE_NAME] = $this->getApache()->getService();
269 }
270 if ($this->getMysql()->isEnable()) {
271 $result[BinMysql::SERVICE_NAME] = $this->getMysql()->getService();
272 }
273 if ($this->getMariadb()->isEnable()) {
274 $result[BinMariadb::SERVICE_NAME] = $this->getMariadb()->getService();
275 }
276 if ($this->getPostgresql()->isEnable()) {
277 $result[BinPostgresql::SERVICE_NAME] = $this->getPostgresql()->getService();
278 }
279 if ($this->getXlight()->isEnable()) {
280 $result[BinXlight::SERVICE_NAME] = $this->getXlight()->getService();
281 }
282
283 return $result;
284 }
285}
286
$result
const SERVICE_NAME
__construct()
getMysql()
getServices()
getXlight()
getPostgresql()
getMemcached()
getApache()
reload()
update()
const TYPE
getMailpit()
$postgresql
getAll()
getMariadb()
getNodejs()
getBinByName(string $name)
static info($data, $file=null)
static initClass($classInstance)