【发布时间】:2023-03-12 16:40:02
【问题描述】:
试图了解如何在 codeigniter https://github.com/ericbarnes/CodeIgniter-Events 中使用此事件侦听器库
我正在尝试在提交后发送电子邮件。我的后期控制器如下
/**
* Posts
*/
class Posts extends MX_Controller
{
function __construct(argument)
{
# code...
}
function post_new()
{
// all form validation and submission code
Events::trigger('add_post', 'system_events', 'string');
}
}
我创建了一个控制器,我将在其中注册所有系统事件
/**
* System Events
*/
class System_Events extends MX_Controller
{
function __construct(argument)
{
Events::register('add_post', array($this, 'shoot_email'));
}
function shoot_email()
{
// all email code here
}
}
但这并不是在提交后发送任何电子邮件。我真的不明白如何使用这个事件库。
如果有其他方法可以注册和触发事件,我也很好。但不是硬编码到系统中,而是一种 API。
【问题讨论】:
标签: php codeigniter event-handling