2012-01-09 152 views
2

我試圖在Kohana中實現一個phpBB庫。Kohana 3.2 - phpBB庫 - 使用抽象方法

我有我的模塊中創建一個供應商的文件夾,並加載庫這樣並初始化它:

require_once Kohana::find_file('vendor/phpbb_library', 'phpbb_library'); 
$phpbb = new Phpbb_library(); 

然而,一旦庫開始嘗試包括phpBB的文件:

// Include needed files 
include($phpbb_root_path . 'common.' . $phpEx); 
include($phpbb_root_path . 'config.' . $phpEx); 
include($phpbb_root_path . 'includes/functions_user.' . $phpEx); 
include($phpbb_root_path . 'includes/functions_display.' . $phpEx); 
include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); 
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); 

我然後收到以下錯誤:

ErrorException [ Fatal Error ]: Class user contains 5 abstract methods and must therefore be declared abstract or implement the remaining methods (Kohana_Session::_read, Kohana_Session::_regenerate, Kohana_Session::_write, ...) 

現在包括的文件是thos e由phpBB使用,顯然我不能只是去修改它們。


解決01/02/2012

繼我已經創建了自己的Kohana的會話類的版本和模塊中保存了他們的Michal M提出的解決方案。我不得不復制,重命名和編輯這些文件是:

/system/classes/session.php 
/system/classes/session/cookie.php 
/system/classes/session/exception.php 
/system/classes/session/native.php 

/system/classes/kohana/session.php 
/system/classes/kohana/session/cookie.php 
/system/classes/kohana/session/exception.php 
/system/classes/kohana/session/native.php 

中的所有文件涉及改變類名SessionMySiteSessionKohana_SessionKohana_MySite_Session主編輯。雖然在/system/classes/kohana文件中有一些變量用法,它們也需要名稱更改。

現在使用會話我只需撥打MySiteSession::instance()

PHPBB現在作爲一個包含,因爲我不再使用Session類。

+1

錯誤正在觸發,因爲phpBB和Kohana都有一個Session類。沒有解決方案。 – shadowhand 2012-01-09 18:04:35

+0

怎麼能沒有解決方案? CodeIgniter允許它工作:http://codeigniter.com/wiki/phpBB3_library我認爲Kohana是CodeIgniter框架的偏移量。 – diggersworld 2012-01-10 09:26:09

+0

您是否真的成功實施了橋接?你可以分享一些資源嗎?謝謝 – zinovii 2012-03-12 16:43:26

回答

2

CI有不同的類命名。所有CI類以CI_開頭,而Kohana不使用任何前綴*。

我能想到的唯一解決方案就是重構Kohana Session類(在任何地方重新命名)或者使用phpBB庫進行重構。然而,兩者都不是理想的。


*)只是爲了澄清,Kohana中確實使用Kohana_,但他們所有的課程都是由類沒有前綴擴展。

+0

我已經創建了一個新的會話類並在整個站點中使用它。系統中有一個地方也使用'system/classes/kohana/security'文件中的'Session :: instance()'。我不知道我是否應該改變。將嘗試擴展它。 – diggersworld 2012-02-01 11:47:36

+0

確認此工作,並在原始問題中添加完整的說明。 – diggersworld 2012-02-01 14:15:42