Skip to content

Commit

Permalink
change start configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeks-semenov committed Apr 21, 2016
1 parent 4478abe commit 9906558
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
36 changes: 24 additions & 12 deletions components/Cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,19 @@ public function generateTmpConfig()
$result = \yii\helpers\ArrayHelper::merge($result, $fileData);
}

$file = new File(TMP_CONFIG_FILE_EXTENSIONS);
if ($file->isExist())
{
$file->remove();
if (!file_exists(dirname(TMP_CONFIG_FILE_EXTENSIONS))) {
mkdir(dirname(TMP_CONFIG_FILE_EXTENSIONS), 0777, true);
}
$file->write(serialize($result));
return $file->isExist();

$string = var_export($result, true);
file_put_contents(TMP_CONFIG_FILE_EXTENSIONS, "<?php\n\nreturn $string;\n");

// invalidate opcache of extensions.php if exists
if (function_exists('opcache_invalidate')) {
opcache_invalidate(TMP_CONFIG_FILE_EXTENSIONS, true);
}

return file_exists(TMP_CONFIG_FILE_EXTENSIONS);
}

/**
Expand All @@ -352,13 +358,19 @@ public function generateTmpConsoleConfig()
$result = \yii\helpers\ArrayHelper::merge($result, $fileData);
}

$file = new File(TMP_CONSOLE_CONFIG_FILE_EXTENSIONS);
if ($file->isExist())
{
$file->remove();
if (!file_exists(dirname(TMP_CONSOLE_CONFIG_FILE_EXTENSIONS))) {
mkdir(dirname(TMP_CONSOLE_CONFIG_FILE_EXTENSIONS), 0777, true);
}
$file->write(serialize($result));
return $file->isExist();

$string = var_export($result, true);
file_put_contents(TMP_CONSOLE_CONFIG_FILE_EXTENSIONS, "<?php\n\nreturn $string;\n");

// invalidate opcache of extensions.php if exists
if (function_exists('opcache_invalidate')) {
opcache_invalidate(TMP_CONSOLE_CONFIG_FILE_EXTENSIONS, true);
}

return file_exists(TMP_CONSOLE_CONFIG_FILE_EXTENSIONS);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions global.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

defined('COMMON_CONFIG_DIR') or define('COMMON_CONFIG_DIR', ROOT_DIR . '/common/config');

define("TMP_CONFIG_FILE_EXTENSIONS", VENDOR_DIR . '/skeeks/tmp-config-extensions.cache.conf' );
define("TMP_CONSOLE_CONFIG_FILE_EXTENSIONS", VENDOR_DIR . '/skeeks/tmp-console-config-extensions.cache.conf' );
define("TMP_CONFIG_FILE_EXTENSIONS", VENDOR_DIR . '/skeeks/tmp-config-extensions.php' );
define("TMP_CONSOLE_CONFIG_FILE_EXTENSIONS", VENDOR_DIR . '/skeeks/tmp-console-config-extensions.php' );

/**
* Глобальный файл где задается настройка окружения.
Expand Down
5 changes: 1 addition & 4 deletions tmp-config-console-extensions.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?php
$tmpConfig = [];
if (file_exists(TMP_CONSOLE_CONFIG_FILE_EXTENSIONS))
{
$tmpConfig = unserialize(file_get_contents(TMP_CONSOLE_CONFIG_FILE_EXTENSIONS));
return (array) require(TMP_CONSOLE_CONFIG_FILE_EXTENSIONS);
} else
{
return (array) require(__DIR__ . '/config/main-console.php');
}

return $tmpConfig;
4 changes: 1 addition & 3 deletions tmp-config-extensions.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php
$tmpConfig = [];
if (file_exists(TMP_CONFIG_FILE_EXTENSIONS))
{
$tmpConfig = unserialize(file_get_contents(TMP_CONFIG_FILE_EXTENSIONS));
return (array) require(TMP_CONFIG_FILE_EXTENSIONS);
} else
{
return (array) require(__DIR__ . '/config/main.php');
}
return $tmpConfig;

0 comments on commit 9906558

Please sign in to comment.