我设法用一个非常非常肮脏的黑客来做到这一点。
在/srv/http/public/php/kcfinder/core/autoload.php
我附加的行:
require '../../../paths.php';
require path('sys').'core.php';
\Laravel\Bundle::start(DEFAULT_BUNDLE);
$KCFinderRoot = addslashes(realpath(dirname(__FILE__). '/../') . DS);
\Laravel\Autoloader::map(array(
'browser' => $KCFinderRoot . 'core/browser.php',
'uploader' => $KCFinderRoot . 'core/uploader.php',
'type_img' => $KCFinderRoot . 'core/types/type_img.php',
'type_mime' => $KCFinderRoot . 'core/types/type_mime.php',
'gd' => $KCFinderRoot . 'lib/class_gd.php',
'input' => $KCFinderRoot . 'lib/class_input.php',
'zipFolder' => $KCFinderRoot . 'lib/class_zipFolder.php',
'dir' => $KCFinderRoot . 'lib/helper_dir.php',
'file' => $KCFinderRoot . 'lib/helper_file.php',
'httpCache' => $KCFinderRoot . 'lib/helper_httpCache.php',
'path' => $KCFinderRoot . 'lib/helper_path.php',
'text' => $KCFinderRoot . 'lib/helper_text.php',
));
if (!\Laravel\Auth::check())
{
die('no user :(');
}
无论 KCF 有一些文件包含在哪里,我都必须挤进去$KCFinderRoot
,在某些方法中甚至以前需要global
它们。
在 KCF 的配置中,我添加了:
// ...
'uploadURL' => "/useruploads/" . sha1(Auth::user()->id . Auth::user()->email),
'uploadDir' => path('public') . "useruploads/" . sha1(Auth::user()->id . Auth::user()->email),
// ...
最终结果就像我想要的那样工作,除了我不知道这是多么“聪明”。
PS 在接下来的几天里,我将尝试捆绑 IoC,同时保持 KCF 文件完整。