"PHP message: PHP Fatal error: Uncaught TypeError: Argument 2 passed to Mage::dispatchEvent() must be of the type array, object given, called in TestimonialController.php on line 26"
I am facing above error, i have upgraded my php version to 7.1 with magento 9.1.0
here is my function
/*TestimonialController.php starts*/
public function editAction()
{
$this->_title($this->__("Testimonials"));
$this->_title($this->__("Testimonial"));
$this->_title($this->__("Edit Item"));
$id = $this->getRequest()->getParam("id");
$model = Mage::getModel("testimonials/testimonial")->load($id);
Mage::dispatchEvent('testimonial_save_before', $model);//Line No.->26
if ($model->getId()) {
Mage::register("testimonial_data", $model);
$this->loadLayout();
$this->_setActiveMenu("testimonials/testimonial");
$this->_addBreadcrumb(Mage::helper("adminhtml")->__('Testimonial Manager"), Mage::helper("adminhtml")->__("Testimonial Manager"));
$this->_addBreadcrumb(Mage::helper("adminhtml")->__("Testimonial Description"), Mage::helper("adminhtml")->__("Testimonial Description"));
$this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
$this->_addContent($this->getLayout()->createBlock("testimonials/adminhtml_testimonial_edit"))->_addLeft($this->getLayout()->createBlock("testimonials/adminhtml_testimonial_edit_tabs"));
$this->renderLayout();
}
else {
Mage::getSingleton("adminhtml/session")->addError(Mage::helper("testimonials")->__("Item does not exist."));
$this->_redirect("*/*/");
}
}
/*TestimonialController.php starts*/
/*Observer.php starts*/
class Ravi_Testimonials_Model_Observer extends Mage_Core_Model_Abstract
{
const COUPON_ACTIVE = 'testimonial/couponcode/activecoupon';
public function testimonialSaveBefore($observer){
//echo $observer->getEvent()->getData()->getId();
//echo $observer->getEvent()->getData()->getStatus();
$tId = $observer->getEvent()->getData()->getId(); //line 33
Mage::getSingleton('core/session')->setTid($tId);
Mage::getSingleton('core/session')->setSt($observer->getEvent()->getData()->getStatus());
}
public function testimonialSaveAfter($observer){
$testimonialId = Mage::getSingleton('core/session')->getTid();
$status = Mage::getSingleton('core/session')->getSt();
if($status == 0 && $observer->getStatus() == 0){
return;
}
if($status == 0 && $observer->getStatus() == 1){
return;
}
if($status == 1 && $observer->getStatus() == 0){
//If status goes from disable to enable, notify customer via email. Write codd for send emails.
//return;
if(Mage::getStoreConfig(self::COUPON_ACTIVE) == 1){
Mage::helper('testimonials')->sendCustomerNotificationEmail($testimonialId);
}else{
return;
}
}
}
}
/*Observer.php ends*/