diff --git a/CHANGELOG.md b/CHANGELOG.md index bc3cc42..2051e9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## 2.1.3 - 2019/08/08 +* Fixed false rendering of forms +* Fixed channel tree view showing the wrong virtual server after selection +* Minor code refactor + ## 2.1.2 - 2019/08/07 * Minor refactoring * Update documentation diff --git a/config/EnvConstants.php b/config/EnvConstants.php index 5e06e57..41998b2 100644 --- a/config/EnvConstants.php +++ b/config/EnvConstants.php @@ -5,6 +5,11 @@ */ class EnvConstants { + /** + * Example env file + */ + const ENV_FILE_EXAMPLE = "env.example"; + /** * Custom env file */ diff --git a/src/Control/Actions/AuthLoginAction.php b/src/Control/Actions/AuthLoginAction.php index e86e99a..e59a7f3 100644 --- a/src/Control/Actions/AuthLoginAction.php +++ b/src/Control/Actions/AuthLoginAction.php @@ -41,7 +41,6 @@ final class AuthLoginAction extends AbstractAction } } - // render GET $this->view->render($response, 'login.twig', [ 'title' => $this->translator->trans('login.title'), ]); diff --git a/src/Control/Actions/BanDeleteAction.php b/src/Control/Actions/BanDeleteAction.php index e89aae8..ce82806 100644 --- a/src/Control/Actions/BanDeleteAction.php +++ b/src/Control/Actions/BanDeleteAction.php @@ -11,10 +11,8 @@ final class BanDeleteAction extends AbstractAction $banId = $args['banId']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $banDeleteResult = $this->ts->getInstance()->banDelete($banId); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->banDelete($banId); $this->flash->addMessage('success', $this->translator->trans('done')); return $response->withRedirect('/bans/' . $sid); diff --git a/src/Control/Actions/BansAction.php b/src/Control/Actions/BansAction.php index d0911a3..59c2cf2 100644 --- a/src/Control/Actions/BansAction.php +++ b/src/Control/Actions/BansAction.php @@ -11,11 +11,10 @@ final class BansAction extends AbstractAction $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $banListResult = $this->ts->getInstance()->banList(); - // render GET $this->view->render($response, 'bans.twig', [ 'title' => $this->translator->trans('bans.title'), 'data' => $this->ts->getInstance()->getElement('data', $banListResult), diff --git a/src/Control/Actions/ChannelCreateAction.php b/src/Control/Actions/ChannelCreateAction.php index fd5f525..f41b73c 100644 --- a/src/Control/Actions/ChannelCreateAction.php +++ b/src/Control/Actions/ChannelCreateAction.php @@ -13,7 +13,7 @@ final class ChannelCreateAction extends AbstractAction $inherit = $body['inherit']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); if (!$inherit) { unset($body['cpid']); diff --git a/src/Control/Actions/ChannelDeleteAction.php b/src/Control/Actions/ChannelDeleteAction.php index ae4b9c1..0e58c1a 100644 --- a/src/Control/Actions/ChannelDeleteAction.php +++ b/src/Control/Actions/ChannelDeleteAction.php @@ -11,10 +11,8 @@ final class ChannelDeleteAction extends AbstractAction $cid = $args['cid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $channelDeleteResult = $this->ts->getInstance()->channelDelete($cid); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->channelDelete($cid); $this->flash->addMessage('success', $this->translator->trans('done')); return $response->withRedirect('/channels/' . $sid); diff --git a/src/Control/Actions/ChannelEditAction.php b/src/Control/Actions/ChannelEditAction.php index da7b32d..9c9d8cd 100644 --- a/src/Control/Actions/ChannelEditAction.php +++ b/src/Control/Actions/ChannelEditAction.php @@ -13,10 +13,8 @@ final class ChannelEditAction extends AbstractAction $body = $request->getParsedBody(); $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $channelResult = $this->ts->getInstance()->channelEdit($cid, $body); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->channelEdit($cid, $body); $this->flash->addMessage('success', $this->translator->trans('done')); return $response->withRedirect('/channels/' . $sid . '/' . $cid); diff --git a/src/Control/Actions/ChannelGroupCreateAction.php b/src/Control/Actions/ChannelGroupCreateAction.php index b266dff..f9b75f5 100644 --- a/src/Control/Actions/ChannelGroupCreateAction.php +++ b/src/Control/Actions/ChannelGroupCreateAction.php @@ -18,10 +18,10 @@ final class ChannelGroupCreateAction extends AbstractAction $this->logger->debug('Body', $body); $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); - if ($copy) $groupCreateResult = $this->ts->getInstance()->channelGroupAdd($name, $type); - else $groupCreateResult = $this->ts->getInstance()->channelGroupCopy($template, 0, $name, $type); + if ($copy) $this->ts->getInstance()->channelGroupAdd($name, $type); + else $this->ts->getInstance()->channelGroupCopy($template, 0, $name, $type); $this->flash->addMessage('success', $this->translator->trans('done')); diff --git a/src/Control/Actions/ChannelGroupDeleteAction.php b/src/Control/Actions/ChannelGroupDeleteAction.php index b5d1c45..6baf218 100644 --- a/src/Control/Actions/ChannelGroupDeleteAction.php +++ b/src/Control/Actions/ChannelGroupDeleteAction.php @@ -11,10 +11,8 @@ final class ChannelGroupDeleteAction extends AbstractAction $cgid = $args['cgid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $groupDeleteResult = $this->ts->getInstance()->channelGroupDelete($cgid); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->channelGroupDelete($cgid); $this->flash->addMessage('success', $this->translator->trans('done')); return $response->withRedirect('/groups/' . $sid); diff --git a/src/Control/Actions/ChannelGroupInfoAction.php b/src/Control/Actions/ChannelGroupInfoAction.php index a62b7f5..04ed3d3 100644 --- a/src/Control/Actions/ChannelGroupInfoAction.php +++ b/src/Control/Actions/ChannelGroupInfoAction.php @@ -11,13 +11,11 @@ final class ChannelGroupInfoAction extends AbstractAction $cgid = $args['cgid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $clientsResult = $this->ts->getInstance()->channelGroupClientList(null, null, $cgid); - $permissionsResult = $this->ts->getInstance()->channelGroupPermList($cgid, true); - // render GET $this->view->render($response, 'channelgroup_info.twig', [ 'title' => $this->translator->trans('channelgroup_info.title') . ' ' . $cgid, 'clients' => $this->ts->getInstance()->getElement('data', $clientsResult), diff --git a/src/Control/Actions/ChannelGroupRenameAction.php b/src/Control/Actions/ChannelGroupRenameAction.php index 362db54..d164795 100644 --- a/src/Control/Actions/ChannelGroupRenameAction.php +++ b/src/Control/Actions/ChannelGroupRenameAction.php @@ -14,10 +14,8 @@ final class ChannelGroupRenameAction extends AbstractAction $name = $body['name']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $groupRenameResult = $this->ts->getInstance()->channelGroupRename($cgid, $name); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->channelGroupRename($cgid, $name); $this->flash->addMessage('success', $this->translator->trans('done')); return $response->withRedirect('/groups/' . $sid); diff --git a/src/Control/Actions/ChannelInfoAction.php b/src/Control/Actions/ChannelInfoAction.php index a9ca161..f3f5f5f 100644 --- a/src/Control/Actions/ChannelInfoAction.php +++ b/src/Control/Actions/ChannelInfoAction.php @@ -11,16 +11,13 @@ final class ChannelInfoAction extends AbstractAction $cid = $args['cid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); $channelResult = $this->ts->getInstance()->channelInfo($cid); - $clientsResult = $this->ts->getInstance()->channelClientList($cid); $files = []; $files['data'] = $this->getAllFilesIn($sid, $cid, '/'); - // render GET $this->view->render($response, 'channel_info.twig', [ 'title' => $this->translator->trans('channel_info.title') . ' ' . $cid, 'files' => $this->ts->getInstance()->getElement('data', $files), @@ -36,10 +33,8 @@ final class ChannelInfoAction extends AbstractAction private function getAllFilesIn($sid, $cid, $path, &$files = []) { $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); $fileResult = $this->ts->getInstance()->ftGetFileList($cid, '', $path); - $foundFiles = $fileResult['data']; if (!empty($foundFiles)) { diff --git a/src/Control/Actions/ChannelSendAction.php b/src/Control/Actions/ChannelSendAction.php index dd46b39..5415eec 100644 --- a/src/Control/Actions/ChannelSendAction.php +++ b/src/Control/Actions/ChannelSendAction.php @@ -12,11 +12,10 @@ final class ChannelSendAction extends AbstractAction $body = $request->getParsedBody(); $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $dataResult = $this->ts->getInstance()->sendMessage(ts3admin::TextMessageTarget_CHANNEL, $cid, $body['message']); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->sendMessage(ts3admin::TextMessageTarget_CHANNEL, $cid, $body['message']); $this->flash->addMessage('success', $this->translator->trans('done')); + return $response->withRedirect('/channels/' . $sid . '/' . $cid); } } \ No newline at end of file diff --git a/src/Control/Actions/ChannelsAction.php b/src/Control/Actions/ChannelsAction.php index 3dc3cd3..6f06c18 100644 --- a/src/Control/Actions/ChannelsAction.php +++ b/src/Control/Actions/ChannelsAction.php @@ -10,7 +10,7 @@ final class ChannelsAction extends AbstractAction $sid = $args['sid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $dataResult = $this->ts->getInstance()->channelList(); $channels = $this->ts->getInstance()->getElement('data', $dataResult); @@ -24,7 +24,6 @@ final class ChannelsAction extends AbstractAction $channelOrders[$channel['channel_name']] = $channel['cid']; } - // render GET $this->view->render($response, 'channels.twig', [ 'title' => $this->translator->trans('channels.title'), 'channels' => $channels, diff --git a/src/Control/Actions/ClientBanAction.php b/src/Control/Actions/ClientBanAction.php index d0d0e5b..e0786cc 100644 --- a/src/Control/Actions/ClientBanAction.php +++ b/src/Control/Actions/ClientBanAction.php @@ -13,11 +13,9 @@ final class ClientBanAction extends AbstractAction $body = $request->getParsedBody(); $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); $getResult = $this->ts->getInstance()->clientGetNameFromDbid($cldbid); - - $dataResult = $this->ts->getInstance()->banAddByUid( + $this->ts->getInstance()->banAddByUid( $this->ts->getInstance()->getElement('data', $getResult)['cluid'], (!empty($body['time']) ? $body['time'] : 0), $body['reason'] diff --git a/src/Control/Actions/ClientDeleteAction.php b/src/Control/Actions/ClientDeleteAction.php index bad3e59..097973d 100644 --- a/src/Control/Actions/ClientDeleteAction.php +++ b/src/Control/Actions/ClientDeleteAction.php @@ -11,7 +11,7 @@ final class ClientDeleteAction extends AbstractAction $cldbid = $args['cldbid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $clientDeleteResult = $this->ts->getInstance()->clientDbDelete($cldbid); diff --git a/src/Control/Actions/ClientInfoAction.php b/src/Control/Actions/ClientInfoAction.php index f6a8cf2..c59f105 100644 --- a/src/Control/Actions/ClientInfoAction.php +++ b/src/Control/Actions/ClientInfoAction.php @@ -11,7 +11,7 @@ final class ClientInfoAction extends AbstractAction $cldbid = $args['cldbid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $detailsResult = $this->ts->getInstance()->clientDbInfo($cldbid); @@ -21,7 +21,6 @@ final class ClientInfoAction extends AbstractAction $permissionsResult = $this->ts->getInstance()->clientPermList($cldbid, true); - // render GET $this->view->render($response, 'client_info.twig', [ 'title' => $this->translator->trans('client_info.title') . ' ' . $cldbid, 'details' => $this->ts->getInstance()->getElement('data', $detailsResult), diff --git a/src/Control/Actions/ClientSendAction.php b/src/Control/Actions/ClientSendAction.php index 3ad6a74..d579d53 100644 --- a/src/Control/Actions/ClientSendAction.php +++ b/src/Control/Actions/ClientSendAction.php @@ -13,11 +13,11 @@ final class ClientSendAction extends AbstractAction $body = $request->getParsedBody(); $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $getResult = $this->ts->getInstance()->clientGetNameFromDbid($cldbid); - $dataResult = $this->ts->getInstance()->messageAdd( + $this->ts->getInstance()->messageAdd( $this->ts->getInstance()->getElement('data', $getResult)['cluid'], $body['subject'], $body['message'] diff --git a/src/Control/Actions/ClientsAction.php b/src/Control/Actions/ClientsAction.php index 66796e8..3856c78 100644 --- a/src/Control/Actions/ClientsAction.php +++ b/src/Control/Actions/ClientsAction.php @@ -10,11 +10,10 @@ final class ClientsAction extends AbstractAction $sid = $args['sid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $dataResult = $this->ts->getInstance()->clientDbList(); - // render GET $this->view->render($response, 'clients.twig', [ 'title' => $this->translator->trans('clients.title'), 'data' => $this->ts->getInstance()->getElement('data', $dataResult), diff --git a/src/Control/Actions/ComplainDeleteAction.php b/src/Control/Actions/ComplainDeleteAction.php index d31c05e..8533e88 100644 --- a/src/Control/Actions/ComplainDeleteAction.php +++ b/src/Control/Actions/ComplainDeleteAction.php @@ -11,7 +11,7 @@ final class ComplainDeleteAction extends AbstractAction $tcldbid = $args['tcldbid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); // search fcldbid $fcldbid = null; diff --git a/src/Control/Actions/ComplainsAction.php b/src/Control/Actions/ComplainsAction.php index cbd9325..fa9d8a4 100644 --- a/src/Control/Actions/ComplainsAction.php +++ b/src/Control/Actions/ComplainsAction.php @@ -10,11 +10,9 @@ final class ComplainsAction extends AbstractAction $sid = $args['sid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); $dataResult = $this->ts->getInstance()->complainList(); - // render GET $this->view->render($response, 'complains.twig', [ 'title' => $this->translator->trans('complains.title'), 'data' => $this->ts->getInstance()->getElement('data', $dataResult), diff --git a/src/Control/Actions/GroupsAction.php b/src/Control/Actions/GroupsAction.php index 0271616..f16b459 100644 --- a/src/Control/Actions/GroupsAction.php +++ b/src/Control/Actions/GroupsAction.php @@ -10,7 +10,7 @@ final class GroupsAction extends AbstractAction $sid = $args['sid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $serverGroupsResult = $this->ts->getInstance()->serverGroupList(); $serverGroups = $this->ts->getInstance()->getElement('data', $serverGroupsResult); @@ -28,7 +28,6 @@ final class GroupsAction extends AbstractAction $channelGroupsTemplate[$channelGroup['name']] = $channelGroup['cgid']; } - // render GET $this->view->render($response, 'groups.twig', [ 'title' => $this->translator->trans('groups.title'), 'serverGroups' => $serverGroups, diff --git a/src/Control/Actions/InstanceAction.php b/src/Control/Actions/InstanceAction.php index 3d540cd..cd3f2e1 100644 --- a/src/Control/Actions/InstanceAction.php +++ b/src/Control/Actions/InstanceAction.php @@ -13,7 +13,6 @@ final class InstanceAction extends AbstractAction $data['data'] = array_merge($hostResult['data'], $instanceResult['data']); - // render GET $this->view->render($response, 'instance.twig', [ 'title' => $this->translator->trans('instance.title'), 'data' => $this->ts->getInstance()->getElement('data', $data) diff --git a/src/Control/Actions/LogsAction.php b/src/Control/Actions/LogsAction.php index 7270c9b..ed139de 100644 --- a/src/Control/Actions/LogsAction.php +++ b/src/Control/Actions/LogsAction.php @@ -17,11 +17,10 @@ final class LogsAction extends AbstractAction $dataResult = $this->ts->getInstance()->logView(getenv(EnvConstants::TEAMSPEAK_LOG_LINES), 1, 1); $appLog = explode("\n", file_get_contents(BootstrapHelper::getLogFile())); } else { - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $dataResult = $this->ts->getInstance()->logView(getenv(EnvConstants::TEAMSPEAK_LOG_LINES), 1, 0); } - // render GET $this->view->render($response, 'logs.twig', [ 'title' => empty($sid) ? $this->translator->trans('instance_logs.title') : $this->translator->trans('server_logs.title'), 'log' => $this->ts->getInstance()->getElement('data', $dataResult), diff --git a/src/Control/Actions/OnlineAction.php b/src/Control/Actions/OnlineAction.php index ff97867..db8021e 100644 --- a/src/Control/Actions/OnlineAction.php +++ b/src/Control/Actions/OnlineAction.php @@ -10,13 +10,20 @@ final class OnlineAction extends AbstractAction $sid = $args['sid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); $dataResult = $this->ts->getInstance()->clientList('-ip -times -info'); - $this->ts->getInstance()->logout(); // avoid showing currently used user twice + $serverInfoResult = $this->ts->getInstance()->serverInfo(); $treeView = null; - $serverPort = $this->session->get("sport"); + $serverPort = null; + if ($this->ts->getInstance()->succeeded($serverInfoResult)) { + $serverInfoDataResult = $this->ts->getInstance()->getElement('data', $serverInfoResult); + if (array_key_exists('virtualserver_port', $serverInfoDataResult)) { + $serverPort = $serverInfoDataResult['virtualserver_port']; + } + } + + $this->ts->getInstance()->logout(); // avoid showing currently used user twice if ($serverPort) { $uri = sprintf('serverquery://%s:%s@%s:%s/?server_port=%s', @@ -31,7 +38,6 @@ final class OnlineAction extends AbstractAction $treeView = $tsServer->getViewer(new TeamSpeak3_Viewer_Html("/images/viewer/", "/images/flags/", "data:image")); } - // render GET $this->view->render($response, 'online.twig', [ 'title' => $this->translator->trans('online.title'), 'data' => $this->ts->getInstance()->getElement('data', $dataResult), diff --git a/src/Control/Actions/OnlineBanAction.php b/src/Control/Actions/OnlineBanAction.php index 602e87b..07c0e7d 100644 --- a/src/Control/Actions/OnlineBanAction.php +++ b/src/Control/Actions/OnlineBanAction.php @@ -13,11 +13,10 @@ final class OnlineBanAction extends AbstractAction $body = $request->getParsedBody(); $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $dataResult = $this->ts->getInstance()->banClient($clid, (!empty($body['time']) ? $body['time'] : 0), $body['reason']); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->banClient($clid, (!empty($body['time']) ? $body['time'] : 0), $body['reason']); $this->flash->addMessage('success', $this->translator->trans('online.banned.success', ['%clid%' => $clid])); + return $response->withRedirect('/online/' . $sid . '/' . $clid); } } \ No newline at end of file diff --git a/src/Control/Actions/OnlineInfoAction.php b/src/Control/Actions/OnlineInfoAction.php index d2691a2..717ca79 100644 --- a/src/Control/Actions/OnlineInfoAction.php +++ b/src/Control/Actions/OnlineInfoAction.php @@ -11,7 +11,7 @@ final class OnlineInfoAction extends AbstractAction $clid = $args['clid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $dataResult = $this->ts->getInstance()->clientInfo($clid); @@ -23,7 +23,6 @@ final class OnlineInfoAction extends AbstractAction $channels[$channel['channel_name']] = $channel['cid']; } - // render GET $this->view->render($response, 'online_info.twig', [ 'title' => $this->translator->trans('online_info.title') . ' ' . $clid, 'data' => $this->ts->getInstance()->getElement('data', $dataResult), diff --git a/src/Control/Actions/OnlineKickAction.php b/src/Control/Actions/OnlineKickAction.php index 700498f..33d608b 100644 --- a/src/Control/Actions/OnlineKickAction.php +++ b/src/Control/Actions/OnlineKickAction.php @@ -13,11 +13,10 @@ final class OnlineKickAction extends AbstractAction $body = $request->getParsedBody(); $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $dataResult = $this->ts->getInstance()->clientKick($clid, 'server', $body['reason']); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->clientKick($clid, 'server', $body['reason']); $this->flash->addMessage('success', $this->translator->trans('online.kicked.success', ['%clid%' => $clid])); + return $response->withRedirect('/online/' . $sid); } } \ No newline at end of file diff --git a/src/Control/Actions/OnlineMoveAction.php b/src/Control/Actions/OnlineMoveAction.php index 3c06444..9bf249c 100644 --- a/src/Control/Actions/OnlineMoveAction.php +++ b/src/Control/Actions/OnlineMoveAction.php @@ -17,10 +17,10 @@ final class OnlineMoveAction extends AbstractAction if (array_key_exists('channel_password', $body)) $channelPassword = $body['channel_password']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); - if (empty($channelPassword)) $dataResult = $this->ts->getInstance()->clientMove($clid, $channel); - else $dataResult = $this->ts->getInstance()->clientMove($clid, $channel, $channelPassword); + if (empty($channelPassword)) $this->ts->getInstance()->clientMove($clid, $channel); + else $this->ts->getInstance()->clientMove($clid, $channel, $channelPassword); $this->flash->addMessage('success', $this->translator->trans('online.moved.success', ['%clid%' => $clid])); diff --git a/src/Control/Actions/OnlinePokeAction.php b/src/Control/Actions/OnlinePokeAction.php index e55f55a..4e28458 100644 --- a/src/Control/Actions/OnlinePokeAction.php +++ b/src/Control/Actions/OnlinePokeAction.php @@ -13,9 +13,8 @@ final class OnlinePokeAction extends AbstractAction $body = $request->getParsedBody(); $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $dataResult = $this->ts->getInstance()->clientPoke($clid, $body['message']); + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->clientPoke($clid, $body['message']); $this->flash->addMessage('success', $this->translator->trans('online.poked.success', ['%clid%' => $clid])); return $response->withRedirect('/online/' . $sid . '/' . $clid); diff --git a/src/Control/Actions/OnlineSendAction.php b/src/Control/Actions/OnlineSendAction.php index 0c0d3a9..8844718 100644 --- a/src/Control/Actions/OnlineSendAction.php +++ b/src/Control/Actions/OnlineSendAction.php @@ -13,9 +13,8 @@ final class OnlineSendAction extends AbstractAction $body = $request->getParsedBody(); $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $dataResult = $this->ts->getInstance()->sendMessage(ts3admin::TextMessageTarget_CLIENT, $clid, $body['message']); + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->sendMessage(ts3admin::TextMessageTarget_CLIENT, $clid, $body['message']); $this->flash->addMessage('success', $this->translator->trans('done')); return $response->withRedirect('/online/' . $sid . '/' . $clid); diff --git a/src/Control/Actions/PasswordAddAction.php b/src/Control/Actions/PasswordAddAction.php index b587755..22d150c 100644 --- a/src/Control/Actions/PasswordAddAction.php +++ b/src/Control/Actions/PasswordAddAction.php @@ -17,9 +17,9 @@ final class PasswordAddAction extends AbstractAction $channelPassword = $body['channel_password']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); - $passwordAddResult = $this->ts->getInstance()->serverTempPasswordAdd( + $this->ts->getInstance()->serverTempPasswordAdd( $password, $duration, $description, diff --git a/src/Control/Actions/PasswordDeleteAction.php b/src/Control/Actions/PasswordDeleteAction.php index 5f1d6e9..78fcbfb 100644 --- a/src/Control/Actions/PasswordDeleteAction.php +++ b/src/Control/Actions/PasswordDeleteAction.php @@ -12,7 +12,7 @@ final class PasswordDeleteAction extends AbstractAction $password = $body['pw_clear']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $passwordDeleteResult = $this->ts->getInstance()->serverTempPasswordDel($password); diff --git a/src/Control/Actions/PasswordsAction.php b/src/Control/Actions/PasswordsAction.php index 9fb24c7..8f89dcc 100644 --- a/src/Control/Actions/PasswordsAction.php +++ b/src/Control/Actions/PasswordsAction.php @@ -10,7 +10,7 @@ final class PasswordsAction extends AbstractAction $sid = $args['sid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $dataResult = $this->ts->getInstance()->serverTempPasswordList(); $channelsResult = $this->ts->getInstance()->channelList(); @@ -22,7 +22,6 @@ final class PasswordsAction extends AbstractAction $channels[$channel['channel_name']] = $channel['cid']; } - // render GET $this->view->render($response, 'passwords.twig', [ 'title' => $this->translator->trans('passwords.title'), 'data' => $this->ts->getInstance()->getElement('data', $dataResult), diff --git a/src/Control/Actions/ProfileAction.php b/src/Control/Actions/ProfileAction.php index 4f57333..1f2ce0a 100644 --- a/src/Control/Actions/ProfileAction.php +++ b/src/Control/Actions/ProfileAction.php @@ -10,12 +10,11 @@ final class ProfileAction extends AbstractAction $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); if ($this->session->exists('sid')) { - $selectResult = $this->ts->getInstance()->selectServer($this->session->get('sid'), 'serverId'); + $this->ts->getInstance()->selectServer($this->session->get('sid'), 'serverId'); } $whoisResult = $this->ts->getInstance()->whoAmI(); - // render GET $this->view->render($response, 'profile.twig', [ 'title' => $this->translator->trans('profile.title'), 'whois' => $this->ts->getInstance()->getElement('data', $whoisResult), diff --git a/src/Control/Actions/ServerEditAction.php b/src/Control/Actions/ServerEditAction.php index c4e1396..53743df 100644 --- a/src/Control/Actions/ServerEditAction.php +++ b/src/Control/Actions/ServerEditAction.php @@ -11,11 +11,10 @@ final class ServerEditAction extends AbstractAction $body = $request->getParsedBody(); $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $dataResult = $this->ts->getInstance()->serverEdit($body); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->serverEdit($body); $this->flash->addMessage('success', $this->translator->trans('server_edit.edited.success', ['%sid%' => $sid])); + return $response->withRedirect('/servers/' . $sid); } } \ No newline at end of file diff --git a/src/Control/Actions/ServerGroupAddAction.php b/src/Control/Actions/ServerGroupAddAction.php index f26891d..9d93d55 100644 --- a/src/Control/Actions/ServerGroupAddAction.php +++ b/src/Control/Actions/ServerGroupAddAction.php @@ -14,9 +14,8 @@ final class ServerGroupAddAction extends AbstractAction $cldbid = $body['cldbid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $groupAddResult = $this->ts->getInstance()->serverGroupAddClient($sgid, $cldbid); + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->serverGroupAddClient($sgid, $cldbid); $this->flash->addMessage('success', $this->translator->trans('added')); diff --git a/src/Control/Actions/ServerGroupCreateAction.php b/src/Control/Actions/ServerGroupCreateAction.php index f931d3c..5dca950 100644 --- a/src/Control/Actions/ServerGroupCreateAction.php +++ b/src/Control/Actions/ServerGroupCreateAction.php @@ -18,10 +18,10 @@ final class ServerGroupCreateAction extends AbstractAction $this->logger->debug('Body', $body); $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); - if ($copy) $groupCreateResult = $this->ts->getInstance()->serverGroupAdd($name, $type); - else $groupCreateResult = $this->ts->getInstance()->serverGroupCopy($template, 0, $name, $type); + if ($copy) $this->ts->getInstance()->serverGroupAdd($name, $type); + else $this->ts->getInstance()->serverGroupCopy($template, 0, $name, $type); $this->flash->addMessage('success', $this->translator->trans('done')); diff --git a/src/Control/Actions/ServerGroupDeleteAction.php b/src/Control/Actions/ServerGroupDeleteAction.php index 9a1938d..ca8dbe6 100644 --- a/src/Control/Actions/ServerGroupDeleteAction.php +++ b/src/Control/Actions/ServerGroupDeleteAction.php @@ -11,10 +11,8 @@ final class ServerGroupDeleteAction extends AbstractAction $sgid = $args['sgid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $groupDeleteResult = $this->ts->getInstance()->serverGroupDelete($sgid); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->serverGroupDelete($sgid); $this->flash->addMessage('success', $this->translator->trans('done')); return $response->withRedirect('/groups/' . $sid); diff --git a/src/Control/Actions/ServerGroupInfoAction.php b/src/Control/Actions/ServerGroupInfoAction.php index e563e27..76e52f9 100644 --- a/src/Control/Actions/ServerGroupInfoAction.php +++ b/src/Control/Actions/ServerGroupInfoAction.php @@ -11,13 +11,10 @@ final class ServerGroupInfoAction extends AbstractAction $sgid = $args['sgid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); $clientsResult = $this->ts->getInstance()->serverGroupClientList($sgid, true); - $permissionsResult = $this->ts->getInstance()->serverGroupPermList($sgid, true); - // render GET $this->view->render($response, 'servergroup_info.twig', [ 'title' => $this->translator->trans('servergroup_info.title') . ' ' . $sgid, 'clients' => $this->ts->getInstance()->getElement('data', $clientsResult), diff --git a/src/Control/Actions/ServerGroupRemoveAction.php b/src/Control/Actions/ServerGroupRemoveAction.php index a61f6eb..d873d9b 100644 --- a/src/Control/Actions/ServerGroupRemoveAction.php +++ b/src/Control/Actions/ServerGroupRemoveAction.php @@ -12,9 +12,9 @@ final class ServerGroupRemoveAction extends AbstractAction $cldbid = $args['cldbid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); - $groupRemoveResult = $this->ts->getInstance()->serverGroupDeleteClient($sgid, $cldbid); + $this->ts->getInstance()->serverGroupDeleteClient($sgid, $cldbid); $this->flash->addMessage('success', $this->translator->trans('removed')); diff --git a/src/Control/Actions/ServerGroupRenameAction.php b/src/Control/Actions/ServerGroupRenameAction.php index 40be718..f07b4d9 100644 --- a/src/Control/Actions/ServerGroupRenameAction.php +++ b/src/Control/Actions/ServerGroupRenameAction.php @@ -14,10 +14,8 @@ final class ServerGroupRenameAction extends AbstractAction $name = $body['name']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $groupRenameResult = $this->ts->getInstance()->serverGroupRename($sgid, $name); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->serverGroupRename($sgid, $name); $this->flash->addMessage('success', $this->translator->trans('done')); return $response->withRedirect('/groups/' . $sid); diff --git a/src/Control/Actions/ServerInfoAction.php b/src/Control/Actions/ServerInfoAction.php index a4a9e14..28080d8 100644 --- a/src/Control/Actions/ServerInfoAction.php +++ b/src/Control/Actions/ServerInfoAction.php @@ -10,13 +10,11 @@ final class ServerInfoAction extends AbstractAction $sid = $args['sid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $infoResult = $this->ts->getInstance()->serverInfo(); - $uploadsResult = $this->ts->getInstance()->ftList(); - // render GET $this->view->render($response, 'server_info.twig', [ 'title' => $this->translator->trans('server_info.title') . ' ' . $sid, 'info' => $this->ts->getInstance()->getElement('data', $infoResult), diff --git a/src/Control/Actions/ServerSelectAction.php b/src/Control/Actions/ServerSelectAction.php index 2657f51..9b70d0c 100644 --- a/src/Control/Actions/ServerSelectAction.php +++ b/src/Control/Actions/ServerSelectAction.php @@ -10,7 +10,7 @@ final class ServerSelectAction extends AbstractAction $sid = $args['sid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $dataResult = $this->ts->getInstance()->serverInfo(); $this->session->set('sid', $sid); diff --git a/src/Control/Actions/ServerSendAction.php b/src/Control/Actions/ServerSendAction.php index eff1a52..6362556 100644 --- a/src/Control/Actions/ServerSendAction.php +++ b/src/Control/Actions/ServerSendAction.php @@ -11,9 +11,8 @@ final class ServerSendAction extends AbstractAction $body = $request->getParsedBody(); $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $dataResult = $this->ts->getInstance()->sendMessage(ts3admin::TextMessageTarget_SERVER, $sid, $body['message']); + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->sendMessage(ts3admin::TextMessageTarget_SERVER, $sid, $body['message']); $this->flash->addMessage('success', $this->translator->trans('done')); return $response->withRedirect('/servers/' . $sid); diff --git a/src/Control/Actions/ServersAction.php b/src/Control/Actions/ServersAction.php index fd7abe3..1fd89b6 100644 --- a/src/Control/Actions/ServersAction.php +++ b/src/Control/Actions/ServersAction.php @@ -10,7 +10,6 @@ final class ServersAction extends AbstractAction $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); $dataResult = $this->ts->getInstance()->serverList(); - // render GET $this->view->render($response, 'servers.twig', [ 'title' => $this->translator->trans('servers.title'), 'data' => $this->ts->getInstance()->getElement('data', $dataResult) diff --git a/src/Control/Actions/SnapshotCreateAction.php b/src/Control/Actions/SnapshotCreateAction.php index cd2c4eb..89abeb3 100644 --- a/src/Control/Actions/SnapshotCreateAction.php +++ b/src/Control/Actions/SnapshotCreateAction.php @@ -13,7 +13,7 @@ final class SnapshotCreateAction extends AbstractAction $sid = $args['sid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $snapshotCreateResult = $this->ts->getInstance()->serverSnapshotCreate(); diff --git a/src/Control/Actions/SnapshotDeleteAction.php b/src/Control/Actions/SnapshotDeleteAction.php index 5d4d981..98643a6 100644 --- a/src/Control/Actions/SnapshotDeleteAction.php +++ b/src/Control/Actions/SnapshotDeleteAction.php @@ -14,7 +14,7 @@ final class SnapshotDeleteAction extends AbstractAction $name = $args['name']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $fileSystem = new Filesystem(); $path = FileHelper::SNAPSHOTS_PATH . DIRECTORY_SEPARATOR . $sid . DIRECTORY_SEPARATOR . $name; diff --git a/src/Control/Actions/SnapshotDeployAction.php b/src/Control/Actions/SnapshotDeployAction.php index 2fe8ea8..62909c1 100644 --- a/src/Control/Actions/SnapshotDeployAction.php +++ b/src/Control/Actions/SnapshotDeployAction.php @@ -12,7 +12,7 @@ final class SnapshotDeployAction extends AbstractAction $name = $args['name']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $fileSystem = new Filesystem(); $path = FileHelper::SNAPSHOTS_PATH . DIRECTORY_SEPARATOR . $sid . DIRECTORY_SEPARATOR . $name; diff --git a/src/Control/Actions/SnapshotsAction.php b/src/Control/Actions/SnapshotsAction.php index a48cbdb..ed41134 100644 --- a/src/Control/Actions/SnapshotsAction.php +++ b/src/Control/Actions/SnapshotsAction.php @@ -10,11 +10,10 @@ final class SnapshotsAction extends AbstractAction $sid = $args['sid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->selectServer($sid, 'serverId'); $snapshots = FileHelper::getFiles(FileHelper::SNAPSHOTS_PATH . DIRECTORY_SEPARATOR . $sid); - // render GET $this->view->render($response, 'snapshots.twig', [ 'title' => $this->translator->trans('snapshots.title'), 'data' => $snapshots, diff --git a/src/Control/Actions/TokenAddAction.php b/src/Control/Actions/TokenAddAction.php index 7095bf0..ce2632e 100644 --- a/src/Control/Actions/TokenAddAction.php +++ b/src/Control/Actions/TokenAddAction.php @@ -16,13 +16,9 @@ final class TokenAddAction extends AbstractAction $channel = $body['channel']; $description = $body['description']; - $this->logger->debug('Body', $body); - $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - - $tokenAddResult = $this->ts->getInstance()->tokenAdd( + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->tokenAdd( $type, ($type == ts3admin::TokenServerGroup ? $serverGroup : $channelGroup), $channel, diff --git a/src/Control/Actions/TokenDeleteAction.php b/src/Control/Actions/TokenDeleteAction.php index 017651c..4d81052 100644 --- a/src/Control/Actions/TokenDeleteAction.php +++ b/src/Control/Actions/TokenDeleteAction.php @@ -11,10 +11,8 @@ final class TokenDeleteAction extends AbstractAction $token = rawurldecode($args['token']); $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - - $tokenDeleteResult = $this->ts->getInstance()->tokenDelete($token); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); + $this->ts->getInstance()->tokenDelete($token); $this->flash->addMessage('success', $this->translator->trans('done')); return $response->withRedirect('/tokens/' . $sid); diff --git a/src/Control/Actions/TokensAction.php b/src/Control/Actions/TokensAction.php index ac6dda9..e85ad85 100644 --- a/src/Control/Actions/TokensAction.php +++ b/src/Control/Actions/TokensAction.php @@ -10,8 +10,7 @@ final class TokensAction extends AbstractAction $sid = $args['sid']; $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); - $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); - + $this->ts->getInstance()->selectServer($sid, 'serverId'); $dataResult = $this->ts->getInstance()->tokenList(); // channels @@ -42,7 +41,6 @@ final class TokensAction extends AbstractAction } arsort($channelGroups); - // render GET $this->view->render($response, 'tokens.twig', [ 'title' => $this->translator->trans('tokens.title'), 'data' => $this->ts->getInstance()->getElement('data', $dataResult), diff --git a/src/Util/BootstrapHelper.php b/src/Util/BootstrapHelper.php index 5c87287..65b40c8 100644 --- a/src/Util/BootstrapHelper.php +++ b/src/Util/BootstrapHelper.php @@ -23,22 +23,28 @@ class BootstrapHelper public static function bootEnvironment() { $envPath = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'config'; + $envFileExample = $envPath . DIRECTORY_SEPARATOR . EnvConstants::ENV_FILE_EXAMPLE; $envFile = $envPath . DIRECTORY_SEPARATOR . EnvConstants::ENV_FILE; - if (file_exists($envFile)) { - $env = new Dotenv(realpath($envPath), EnvConstants::ENV_FILE); - $res = $env->load(); - - try { - $env->required(EnvConstants::ENV_REQUIRED); - } catch (ValidationException $e) { - die($e->getMessage()); + try { + $fileSystem = new Filesystem(); + if (!$fileSystem->exists($envFile)) { + $fileSystem->copy($envFileExample, $envFile); } - - return $res; - } else { - die('No environment file found in ' . realpath($envFile)); + } catch (IOException $e) { + die('Could not copy example env file ' . $envFileExample . ' to ' . $envFile); } + + $env = new Dotenv($envPath, EnvConstants::ENV_FILE); + $res = $env->load(); + + try { + $env->required(EnvConstants::ENV_REQUIRED); + } catch (ValidationException $e) { + die($e->getMessage()); + } + + return $res; } /** @@ -134,7 +140,8 @@ class BootstrapHelper * * @return string */ - public static function getLogDir() { + public static function getLogDir() + { return __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'log'; } @@ -143,7 +150,8 @@ class BootstrapHelper * * @return string */ - public static function getLogFile() { + public static function getLogFile() + { return self::getLogDir() . DIRECTORY_SEPARATOR . 'application.log'; } } \ No newline at end of file diff --git a/src/View/bootstrap4/form.twig b/src/View/bootstrap4/form.twig index aecc97d..725952c 100644 --- a/src/View/bootstrap4/form.twig +++ b/src/View/bootstrap4/form.twig @@ -47,7 +47,6 @@ {% endif %} - {% endfor %}