improvements
This commit is contained in:
@@ -98,13 +98,18 @@ class Application
|
||||
$cronManager->run();
|
||||
}
|
||||
|
||||
public function isInstalled()
|
||||
public function isInstalled($useRedirect = true)
|
||||
{
|
||||
$configFile = $this->getContainer()->get('config')->get('configPath');
|
||||
if (!file_exists($configFile)) {
|
||||
$configFile = $this->getContainer()->get('config')->get('configPath');
|
||||
|
||||
$result = file_exists($configFile) ? true : false;
|
||||
|
||||
if ($useRedirect && !$result) {
|
||||
header("Location: install/");
|
||||
exit;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function routeHooks()
|
||||
|
||||
@@ -76,6 +76,10 @@ class Config
|
||||
*/
|
||||
public function set($name, $value='')
|
||||
{
|
||||
if (is_array($name)) {
|
||||
return $this->setArray($name);
|
||||
}
|
||||
|
||||
if (Json::isJSON($value)) {
|
||||
$value= Json::decode($value);
|
||||
}
|
||||
@@ -94,7 +98,7 @@ class Config
|
||||
* @param array $values
|
||||
* @return bool
|
||||
*/
|
||||
public function setArray($values)
|
||||
protected function setArray($values)
|
||||
{
|
||||
if (Json::isJSON($values)) {
|
||||
$values = Json::decode($values);
|
||||
@@ -162,10 +166,8 @@ class Config
|
||||
* @param $isAdmin
|
||||
* @return bool
|
||||
*/
|
||||
//HERE
|
||||
public function setData($data, $isAdmin=false)
|
||||
{
|
||||
|
||||
$restrictItems = $this->getRestrictItems($isAdmin);
|
||||
|
||||
$values= array();
|
||||
|
||||
@@ -14,10 +14,14 @@ class Json
|
||||
*/
|
||||
public static function encode($value, $options = 0, $depth = 512)
|
||||
{
|
||||
if(version_compare(phpversion(), '5.5.0', '>=')) {
|
||||
if ($options == 0) {
|
||||
$options = JSON_PRETTY_PRINT;
|
||||
}
|
||||
|
||||
if (version_compare(phpversion(), '5.5.0', '>=')) {
|
||||
$json = json_encode($value, $options, $depth);
|
||||
}
|
||||
elseif(version_compare(phpversion(), '5.3.0', '>=')) {
|
||||
elseif (version_compare(phpversion(), '5.3.0', '>=')) {
|
||||
/*Check if options are supported for this version of PHP*/
|
||||
if (is_int($options)) {
|
||||
$json = json_encode($value, $options);
|
||||
|
||||
@@ -202,7 +202,7 @@ class Metadata
|
||||
$path = str_replace('{*}', $moduleName, $this->paths['modulePath']);
|
||||
}
|
||||
|
||||
$result= $this->getFileManager()->putContents(array($path, $type, $scope.'.json'), $data);
|
||||
$result= $this->getFileManager()->mergeContents(array($path, $type, $scope.'.json'), $data, true);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -67,4 +67,25 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($this->object->set($setKey, 'Another Wrong Value'));
|
||||
}
|
||||
|
||||
function testSetArray()
|
||||
{
|
||||
$this->reflection->setProperty('defaultConfigPath', 'tests/testData/Utils/Config/defaultConfigArray.php');
|
||||
|
||||
$values = array(
|
||||
'testOption' => 'Test',
|
||||
'testOption2' => 'Test2',
|
||||
);
|
||||
|
||||
$this->assertTrue($this->object->set($values));
|
||||
$this->assertEquals('Test', $this->object->get('testOption'));
|
||||
$this->assertEquals('Test2', $this->object->get('testOption2'));
|
||||
|
||||
$wrongArray = array(
|
||||
'testOption' => 'Another Wrong Value',
|
||||
);
|
||||
$this->assertTrue($this->object->set($wrongArray));
|
||||
|
||||
$this->reflection->setProperty('defaultConfigPath', $this->defaultConfigPath);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,6 +31,7 @@ return array (
|
||||
1 => 'EUR',
|
||||
),
|
||||
'testOption' => 'Another Wrong Value',
|
||||
'testOption2' => 'Test2',
|
||||
);
|
||||
|
||||
?>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
return array (
|
||||
'configPath' => 'tests/testData/Utils/Config/config.php',
|
||||
'configPath' => 'tests/testData/Utils/Config/testArray.php',
|
||||
|
||||
'dateFormat' => 'MM/DD/YYYY',
|
||||
'timeFormat' => 'HH:mm',
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
return array (
|
||||
'configPath' => 'tests/testData/Utils/Config/config.php',
|
||||
|
||||
'dateFormat' => 'MM/DD/YYYY',
|
||||
'timeFormat' => 'HH:mm',
|
||||
|
||||
'cron' => array(
|
||||
'maxJobNumber' => 15, /*Max number of jobs per one execution*/
|
||||
'jobPeriod' => 7800, /*Period for jobs, ex. if cron executed at 15:35, it will execute all pending jobs for times from 14:05 to 15:35*/
|
||||
'minExecutionTime' => 50, /*to avoid too frequency execution*/
|
||||
),
|
||||
|
||||
'systemUser' => array(
|
||||
'id' => 'system',
|
||||
'userName' => 'system',
|
||||
'firstName' => '',
|
||||
'lastName' => 'System',
|
||||
),
|
||||
|
||||
'crud' => array(
|
||||
'get' => 'read',
|
||||
'post' => 'create',
|
||||
'put' => 'update',
|
||||
'patch' => 'patch',
|
||||
'delete' => 'delete',
|
||||
),
|
||||
'systemItems' =>
|
||||
array (
|
||||
'systemItems',
|
||||
'adminItems',
|
||||
'configPath',
|
||||
'cachePath',
|
||||
'database',
|
||||
'customPath',
|
||||
'defaultsPath',
|
||||
'crud',
|
||||
),
|
||||
'adminItems' =>
|
||||
array (
|
||||
'defaultPermissions',
|
||||
'logger',
|
||||
'devMode',
|
||||
),
|
||||
'currency' =>
|
||||
array(
|
||||
'base' => 'USD',
|
||||
'rate' => array(
|
||||
'EUR' => 1.37,
|
||||
'GBP' => 1.67,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
return array (
|
||||
'testOption' => 'Another Wrong Value',
|
||||
);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user