問:如何從插件/ config目錄加載配置文件?在CakePHP中動態加載插件配置文件3
演示項目:https://github.com/CakePHPKitchen/CakeDC-Users-Permissions-Example
我使用CakeDC /用戶插件,它有它加載從RBAC權限permissions.php文件。從我可以告訴,它要麼加載用戶插件的配置文件夾中的默認權限文件,要麼從app/config文件夾加載permissions.php文件。
現在對於我的應用程序骨架,我在app/config/permissions.php中擁有一堆權限,但是,我不想修改該文件,因爲我將從上游回購中執行git pull操作,而且我希望避免衝突。
所以我想要做的是,在應用程序骨架引導
什麼,我想
foreach(Plugin::loaded() as $plugin) {
$path = Plugin::path($plugin) . 'config/permissions.php';
if(file_exists($path)) {
Configure::load($path, 'default', true);
}
}
但我收到以下錯誤....
Error: The application is trying to load a file from the /Users/jlroberts/Projects/JeffreyLRobertsCom/CakePHPKitchen/PluginDemos/plugins/SharpAgent/config/permissions plugin.
Make sure your plugin /Users/jlroberts/Projects/JeffreyLRobertsCom/CakePHPKitchen/PluginDemos/plugins/SharpAgent/config/permissions is in the /Users/jlroberts/Projects/JeffreyLRobertsCom/CakePHPKitchen/PluginDemos/plugins/ directory and was loaded.
關於如何從Plugin/config目錄加載permissions.php文件的想法?
我創建了一個示範項目c9.io環境,它擁有您在示例插件推薦代碼的bootstrap.php ... https://github.com/CakePHPKitchen/CakeDC-Users-Permissions-Example –
當插件引導程序加載時,權限尚未添加到配置中,並且如果我在引導程序中爲插件設置權限,它們最終會被覆蓋... –
It在我看來,permissions.php文件不會被加載,直到在CakeDC/auth中SimpleRbacAuthorize.php的構造函數被觸發爲止......對於我來說,對於你所說的工作,它需要從一個啓動CakeDC/auth或CakeDC /用戶 –