Gobb
Member
Hi,
Just hoping to get some clarification as to using handlers. The following is seen in the alert abstract handler:
What I want to understand is, the $alert variable and $content variable and how this is passed in. Am I correct to assume the UserAlert $alert is the UserAlert entity and the data that is currently being passed in, and the Entity $content is the entity of content that is being fetched? So if an alert is alerting a thread, the Entity $content would be the XF:Thread entity and relevant contents?
Only asking because my own handler only works and delivers the template when removing the equivalent "UserAlert", but if it's just Entity it works fine.
Any assistance would be very much appreciated,
Thanks
Just hoping to get some clarification as to using handlers. The following is seen in the alert abstract handler:
PHP:
public function getTemplateName($action)
{
return 'public:alert_' . $this->contentType . '_' . $action;
}
public function getTemplateData($action, UserAlert $alert, Entity $content = null)
{
if (!$content)
{
$content = $alert->Content;
}
return [
'alert' => $alert,
'user' => $alert->User,
'extra' => $alert->extra_data,
'content' => $content
];
}
public function render(UserAlert $alert, Entity $content = null)
{
if (!$content)
{
$content = $alert->Content;
if (!$content)
{
return '';
}
}
$action = $alert->action;
$template = $this->getTemplateName($action);
$data = $this->getTemplateData($action, $alert, $content);
return \XF::app()->templater()->renderTemplate($template, $data);
}
What I want to understand is, the $alert variable and $content variable and how this is passed in. Am I correct to assume the UserAlert $alert is the UserAlert entity and the data that is currently being passed in, and the Entity $content is the entity of content that is being fetched? So if an alert is alerting a thread, the Entity $content would be the XF:Thread entity and relevant contents?
Only asking because my own handler only works and delivers the template when removing the equivalent "UserAlert", but if it's just Entity it works fine.
Any assistance would be very much appreciated,
Thanks