Kohana 3.2 - phpBB 库 - 使用抽象方法

发布于 2024-12-26 00:10:17 字数 1800 浏览 0 评论 0原文

我正在尝试在 Kohana 中实现 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, ...)

现在包含的文件是 phpBB 使用的文件,所以显然我不能只是去修改它们。


已解决 01/02/2012

按照 Michal M 提出的解决方案,我创建了我的自己版本的 Kohana Session 类并将它们保存在模块中。我必须复制、重命名和编辑的文件是:

/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

在所有文件中,主要编辑涉及将类名 Session 更改为 MySiteSession 并将 Kohana_Session 更改为 <代码>Kohana_MySite_Session。尽管 /system/classes/kohana 文件中的变量有一些用法,但也需要更改名称。

现在要使用会话,我只需调用 MySiteSession::instance()

PHPBB 现在作为包含项工作,因为我不再使用 Session 类。

I'm attempting to implement a phpBB library into Kohana.

I have created a vendor folder in my module and load the library like this and initialise it:

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

However once the library starts attempting to include the phpBB files:

// 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);

I then receive the following error:

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, ...)

Now the included files are those used by phpBB so obviously I can't just go modifying them.


Solved 01/02/2012

Following the solution proposed by Michal M I have created my own versions of the Kohana Session class and saved them in a module. The files I had to copy, rename and edit were:

/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

In all files the main edits involved changing class names Session to MySiteSession and Kohana_Session to Kohana_MySite_Session. Although there were a few usages of the variables in the /system/classes/kohana files which also needed the name change.

Now to use the session I simply call MySiteSession::instance().

PHPBB now works as an include as I am no longer using the Session class.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

弃爱 2025-01-02 00:10:17

CI 有不同的类命名。所有 CI 类均以 CI_ 开头,而 Kohana 不使用任何前缀*。

我能为您想到的唯一解决方案是重构 Kohana Session 类(在各处重命名)或使用 phpBB 库来完成。但两者都不理想。


*)澄清一下,Kohana 确实使用 Kohana_,但它们的所有类都是由没有前缀的类扩展的。

CI has different class naming. All CI classes begin with CI_ while Kohana doesn't use any prefixes*.

The only solution I can think of for you would be to refactor Kohana Session class (rename it everywhere) or do it with phpBB libraries. Neither is ideal though.


*) Just to clarify, Kohana does use Kohana_, but all their classes are extended by classes without prefixes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文