2024.8.23
Loading...
Searching...
No Matches
class.action.exec.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 ActionExec
12 *
13 * This class handles the execution of specific actions based on the content of a file.
14 * The actions include quitting the application or restarting it. The actions are read
15 * from a file whose path is provided by the global `$bearsamppCore` object.
16 */
18{
19 /**
20 * Constant representing the 'quit' action.
21 */
22 const QUIT = 'quit';
23
24 /**
25 * Constant representing the 'restart' action.
26 */
27 const RESTART = 'restart';
28
29 /**
30 * ActionExec constructor.
31 *
32 * This constructor reads the action from a file specified by `$bearsamppCore->getExec()`.
33 * If the action is 'quit', it calls `Batch::exitApp()`. If the action is 'restart', it calls
34 * `Batch::restartApp()`. After executing the action, it deletes the action file.
35 *
36 * @param array $args Arguments passed to the constructor (not used in the current implementation).
37 */
38 public function __construct($args)
39 {
40 global $bearsamppCore;
41
42 if (file_exists($bearsamppCore->getExec())) {
43 $action = file_get_contents($bearsamppCore->getExec());
44 if ($action == self::QUIT) {
46 } elseif ($action == self::RESTART) {
48 }
49 @unlink($bearsamppCore->getExec());
50 }
51 }
52}
global $bearsamppCore
static exitApp($restart=false)
static restartApp()