Zend Framework - 您的资源插件
创建了资源插件来与 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许你可以尝试这个:
Maybe you can try this: