Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F32567762
PhabricatorConfigLocalSource.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
1 KB
Subscribers
None
PhabricatorConfigLocalSource.php
View Options
<?php
final
class
PhabricatorConfigLocalSource
extends
PhabricatorConfigProxySource
{
public
function
__construct
()
{
$config
=
$this
->
loadConfig
();
$this
->
setSource
(
new
PhabricatorConfigDictionarySource
(
$config
));
}
public
function
setKeys
(
array
$keys
)
{
$result
=
parent
::
setKeys
(
$keys
);
$this
->
saveConfig
();
return
$result
;
}
public
function
deleteKeys
(
array
$keys
)
{
$result
=
parent
::
deleteKeys
(
$keys
);
$this
->
saveConfig
();
return
parent
::
deleteKeys
(
$keys
);
}
private
function
loadConfig
()
{
$path
=
$this
->
getConfigPath
();
if
(@
file_exists
(
$path
))
{
$data
=
@
file_get_contents
(
$path
);
if
(
$data
)
{
$data
=
json_decode
(
$data
,
true
);
if
(
is_array
(
$data
))
{
return
$data
;
}
}
}
return
array
();
}
private
function
saveConfig
()
{
$config
=
$this
->
getSource
()->
getAllKeys
();
$json
=
new
PhutilJSON
();
$data
=
$json
->
encodeFormatted
(
$config
);
Filesystem
::
writeFile
(
$this
->
getConfigPath
(),
$data
);
}
private
function
getConfigPath
()
{
$root
=
dirname
(
phutil_get_library_root
(
'phabricator'
));
$path
=
$root
.
'/conf/local/local.json'
;
return
$path
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 14, 8:17 PM (1 h, 55 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ca/cb/7bc230fdaa2c351782a5aafd75cd
Attached To
rPHAB Phabricator
Event Timeline
Log In to Comment