Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F56958848
Service.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
Service.php
View Options
<?php
namespace
Nasqueron\Api\ServersLog
;
use
Dotenv\Dotenv
;
class
Service
extends
BaseService
{
///
/// Initialisation
///
public
function
__construct
()
{
$this
->
loadEnvironment
();
}
///
/// Controller
///
public
function
handle
()
:
void
{
$body
=
$this
->
getBodyObject
();
if
(
$_SERVER
[
'REQUEST_METHOD'
]
===
"PUT"
)
{
$this
->
put
(
$body
);
return
;
}
$this
->
sendInvalidMethodResponse
();
}
public
function
put
(
$data
)
:
void
{
Log
::
addEntryToJSONFile
(
self
::
getServersLogFile
(),
LogEntry
::
fromJSON
(
$data
)
);
$this
->
sendSuccessResponse
();
}
///
/// Helper methods
///
private
function
loadEnvironment
()
:
void
{
$env
=
new
Dotenv
(
__DIR__
);
if
(
file_exists
(
__DIR__
.
'/.env'
))
{
$env
->
load
();
}
$env
->
required
(
'SERVERS_LOG_FILE'
);
}
private
static
function
getServersLogFile
()
:
string
{
return
getenv
(
'SERVERS_LOG_FILE'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 13, 18:28 (1 d, 22 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4254519
Default Alt Text
Service.php (1 KB)
Attached To
Mode
rAPISRVLOGS Servers log :: Add new entries API
Attached
Detach File
Event Timeline
Log In to Comment