Zend Framework - 您的资源插件

发布于 2024-10-13 04:54:55 字数 1599 浏览 3 评论 0原文

创建了资源插件来与 Realplexor 类一起使用,使用它在多个客户端之间交换消息,它非常适合聊天。 application.ini中规定了这个插件的设置。测试的控制器编写以下代码:

$realplexorObject = Zend_Registry::get('realplexor');
print_r ($realplexorObject);
die ();

他给出以下内容:

Dklab_Realplexor Object
(
    [_timeout:Dklab_Realplexor:private] => 5
    [_host:Dklab_Realplexor:private] => rpl.newchat.com
    [_port:Dklab_Realplexor:private] => 10010
    [_identifier:Dklab_Realplexor:private] => identifier
    [_login:Dklab_Realplexor:private] => 
    [_password:Dklab_Realplexor:private] => 
    [_namespace] => Chat_
)

即 Dklab_Realplexor 对象被创建并存储在 Zend_Registry 中,但这对他来说是有效的 我想为他编写一个具有特定方法的模型,该模型应该使用类方法Dklab_Realplexor,它到底是怎么做的?

我尝试编写这样的模型:

class Application_Model_Realplexor_Message extends Dklab_Realplexor
{
    public function  __construct() {
        return Zend_Registry::get('realplexor');
    }

    public function post ($text, $fromUser = 0, $fromOperator = 0) {
        $this->send("Alpha", $text);
    }
}

但是,如果您在控制器中创建该模型的对象,这就是它未初始化的原因:

$realplexorMessageModel = new Application_Model_Realplexor_Message();
print_R ($realplexorMessageModel);
die ();

问题:

Application_Model_Realplexor_Message Object
(
    [_timeout:Dklab_Realplexor:private] => 5
    [_host:Dklab_Realplexor:private] => 
    [_port:Dklab_Realplexor:private] => 
    [_identifier:Dklab_Realplexor:private] => 
    [_login:Dklab_Realplexor:private] => 
    [_password:Dklab_Realplexor:private] => 
)

我想在同一台上为他制作此插件资源和模型原理作为数据库现有 ZF 插件资源的模型。

Has created the resource plugin to work with the class Realplexor, using it to exchange messages between multiple clients, it is well suited for a chat. Prescribed for this plugin settings application.ini. The controller for the test write the following code:

$realplexorObject = Zend_Registry::get('realplexor');
print_r ($realplexorObject);
die ();

He gives the following:

Dklab_Realplexor Object
(
    [_timeout:Dklab_Realplexor:private] => 5
    [_host:Dklab_Realplexor:private] => rpl.newchat.com
    [_port:Dklab_Realplexor:private] => 10010
    [_identifier:Dklab_Realplexor:private] => identifier
    [_login:Dklab_Realplexor:private] => 
    [_password:Dklab_Realplexor:private] => 
    [_namespace] => Chat_
)

ie Dklab_Realplexor object is created and stored in Zend_Registry, but that would work with him I want to write for him a model with specific methods for my project that should use class methods Dklab_Realplexor, how exactly does this do?

I tried to write a model like this:

class Application_Model_Realplexor_Message extends Dklab_Realplexor
{
    public function  __construct() {
        return Zend_Registry::get('realplexor');
    }

    public function post ($text, $fromUser = 0, $fromOperator = 0) {
        $this->send("Alpha", $text);
    }
}

But, if you create an object of this model in the controller, it is why it is not initialized:

$realplexorMessageModel = new Application_Model_Realplexor_Message();
print_R ($realplexorMessageModel);
die ();

issues:

Application_Model_Realplexor_Message Object
(
    [_timeout:Dklab_Realplexor:private] => 5
    [_host:Dklab_Realplexor:private] => 
    [_port:Dklab_Realplexor:private] => 
    [_identifier:Dklab_Realplexor:private] => 
    [_login:Dklab_Realplexor:private] => 
    [_password:Dklab_Realplexor:private] => 
)

I would like to make this plug-in resource and model for him on the same principle as a model made for existing ZF plug-in resources for the database.

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

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

发布评论

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

评论(1

悟红尘 2024-10-20 04:54:55

也许你可以尝试这个:

class Application_Model_Realplexor_Message
{
    protected $realplexor;

    public function  __construct() {
        $this->realplexor = Zend_Registry::get('realplexor');
    }

    public function post ($text, $fromUser = 0, $fromOperator = 0) {
        $this->realplexor->send("Alpha", $text);
    }
}

Maybe you can try this:

class Application_Model_Realplexor_Message
{
    protected $realplexor;

    public function  __construct() {
        $this->realplexor = Zend_Registry::get('realplexor');
    }

    public function post ($text, $fromUser = 0, $fromOperator = 0) {
        $this->realplexor->send("Alpha", $text);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文