@kenji_sさんからのアドバイスで前記事の内容を本家フォーラムで聞いてみました。
General Config::save('any-config', 'any_config') at config/{Fuel::$env}/any-config.php
以下が回答(と僕の稚拙な訳)
This is correct behavior.
これは仕様です。
When loading a config file, you can have up to 8 files being merged (module, app, package, core, both with a global and enviroment specific version).
Configファイルをロードする際、最大で8ファイルがマージされます。
(module, app, package, coreに対して、グローバルと指定環境の両方)
When saving, Fuel has no way of knowing from which of they 8 a particular key came from, it always saves to app/config, unless you specify a fully qualified path.
保存時、Fuelを利用すると、完全修飾パスを指定しない限り、それら8つの特定のキーから来たか知る術がないため、常にapp/configに保存されます。
Your question is: if there is an app/config/environment file, save it to that one instead of the global one? If so, please create a feature request for it at https://github.com/fuel/core/issues with this use-case.
あなたの質問はこうですか?app/config/environmentファイルがある場合、グローバルではないそのファイルに保存しますか?もし、そうしたいならユースケースを含めてissueを登録してください。
納得。ちなみに「完全修飾パスを指定しない限り」はこういうことらしい。
hoge
Config::save(Fuel::$env.'/'.'hoge', 'hoge');
Configを保存するケース自体稀だけど、ちょっとなー
ということで、例のごとくConfigクラスを継承してAutoloaderで読み込んでしまうことにしました。
fuel/app/core/config.php
<?php
/*
* Copyright (c) 2014 Yasuyuki Sasaki
* This software is released under the MIT License.
* http://opensource.org/licenses/mit-license.php
*/
class Config extends \Fuel\Core\Config
{
/**
* Save a config array to disc.
*
* @param string $file desired file name
* @param string|array $config master config array key or config array
* @return bool false when config is empty or invalid else \File::update result
*/
public static function save($file, $config)
{
return parent::save(Fuel::$env.'/'.$file, $config);
}
}
fuel/app/bootstrap.php
<?php
Autoloader::add_classes(array(
'Config' => __DIR__.'/classes/core/config.php', // 追加
));
完全修飾のこと知ってたら最初からこうやってたのに、深いところまで行っちゃってた