Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F10190405
Environment.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
Environment.php
View Options
<?php
namespace
Nasqueron\SAAS\MediaWiki
;
use
Dotenv\Dotenv
;
use
Dotenv\Exception\ValidationException
;
class
Environment
{
/**
* @var bool
*/
static
private
$isLoaded
=
false
;
/**
* Loads the environment, if it hasn't been loaded before.
*/
public
static
function
load
()
:
void
{
if
(!
self
::
$isLoaded
)
{
$directory
=
self
::
getDirectory
();
$dotenv
=
new
Dotenv
(
$directory
);
$dotenv
->
safeLoad
();
try
{
$dotenv
->
required
(
self
::
getRequiredVariables
());
}
catch
(
ValidationException
$exception
)
{
Service
::
serveInternalErrorResponse
(
$exception
);
}
self
::
$isLoaded
=
true
;
}
}
public
static
function
isLoaded
()
:
bool
{
return
self
::
$isLoaded
;
}
public
static
function
get
(
$variableName
,
$defaultValue
=
""
)
:
string
{
return
$_ENV
[
$variableName
]
??
$defaultValue
;
}
private
static
function
getDirectory
()
:
string
{
return
dirname
(
__DIR__
);
}
private
static
function
getRequiredVariables
()
:
array
{
return
[
'MEDIAWIKI_ENTRY_POINT'
,
'MEDIAWIKI_SECRET_KEY'
,
'DB_HOST'
,
'DB_USER'
,
'DB_PASS'
,
];
}
public
static
function
isBSD
()
:
bool
{
static
$system
;
$system
=
php_uname
(
"s"
);
return
substr
(
$system
,
-
3
)
===
"BSD"
||
$system
===
"DragonFly"
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, Jun 26, 05:20 (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2752734
Default Alt Text
Environment.php (1 KB)
Attached To
Mode
rSAASMW SaaS MediaWiki
Attached
Detach File
Event Timeline
Log In to Comment