Bearsampp 2026.5.5
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 Log::initClass($this);
37 }
38
43 public function reload()
44 {
45 Log::info('Reload bins');
46 foreach ($this->getAll() as $bin) {
47 $bin->reload();
48 }
49 }
50
55 public function update()
56 {
57 Log::info('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
219 public function getBinByName(string $name): ?object
220 {
221 foreach ($this->getAll() as $bin) {
222 if ($bin->getName() === $name) {
223 return $bin;
224 }
225 }
226 return null;
227 }
228
234 public function getServices()
235 {
236 $result = array();
237
238 if ($this->getMailpit()->isEnable()) {
239 $result[BinMailpit::SERVICE_NAME] = $this->getMailpit()->getService();
240 }
241 if ($this->getMemcached()->isEnable()) {
242 $result[BinMemcached::SERVICE_NAME] = $this->getMemcached()->getService();
243 }
244 if ($this->getApache()->isEnable()) {
245 $result[BinApache::SERVICE_NAME] = $this->getApache()->getService();
246 }
247 if ($this->getMysql()->isEnable()) {
248 $result[BinMysql::SERVICE_NAME] = $this->getMysql()->getService();
249 }
250 if ($this->getMariadb()->isEnable()) {
251 $result[BinMariadb::SERVICE_NAME] = $this->getMariadb()->getService();
252 }
253 if ($this->getPostgresql()->isEnable()) {
254 $result[BinPostgresql::SERVICE_NAME] = $this->getPostgresql()->getService();
255 }
256 if ($this->getXlight()->isEnable()) {
257 $result[BinXlight::SERVICE_NAME] = $this->getXlight()->getService();
258 }
259
260 return $result;
261 }
262}
$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)