Skip to content
Permalink
Browse files

Added pre events.

  • Loading branch information...
jamesallsup committed Aug 6, 2014
1 parent 42e98c9 commit a69c05c7aad4157d5dc48e7fd5b18a4a4f7624e6
@@ -1,6 +1,8 @@
<?php
class ModelCatalogAttribute extends Model {
public function addAttribute($data) {
$this->event->trigger('pre_admin_add_attribute');

This comment has been minimized.

Copy link
@JAY6390

JAY6390 Aug 6, 2014

Contributor

@jamesallsup Will these be getting the $data array passed too by reference?

$this->db->query("INSERT INTO " . DB_PREFIX . "attribute SET attribute_group_id = '" . (int)$data['attribute_group_id'] . "', sort_order = '" . (int)$data['sort_order'] . "'");
$attribute_id = $this->db->getLastId();
@@ -15,6 +17,8 @@ public function addAttribute($data) {
}
public function editAttribute($attribute_id, $data) {
$this->event->trigger('pre_admin_edit_attribute');
$this->db->query("UPDATE " . DB_PREFIX . "attribute SET attribute_group_id = '" . (int)$data['attribute_group_id'] . "', sort_order = '" . (int)$data['sort_order'] . "' WHERE attribute_id = '" . (int)$attribute_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "attribute_description WHERE attribute_id = '" . (int)$attribute_id . "'");
@@ -27,10 +31,12 @@ public function editAttribute($attribute_id, $data) {
}
public function deleteAttribute($attribute_id) {
$this->event->trigger('pre_admin_delete_attribute', array('attribute_id' => $attribute_id));
$this->db->query("DELETE FROM " . DB_PREFIX . "attribute WHERE attribute_id = '" . (int)$attribute_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "attribute_description WHERE attribute_id = '" . (int)$attribute_id . "'");
$this->event->trigger('admin_delete_attribute');
$this->event->trigger('admin_delete_attribute', array('attribute_id' => $attribute_id));
}
public function getAttribute($attribute_id) {
@@ -1,6 +1,8 @@
<?php
class ModelCatalogAttributeGroup extends Model {
public function addAttributeGroup($data) {
$this->event->trigger('pre_admin_add_attribute_group');
$this->db->query("INSERT INTO " . DB_PREFIX . "attribute_group SET sort_order = '" . (int)$data['sort_order'] . "'");
$attribute_group_id = $this->db->getLastId();
@@ -15,6 +17,8 @@ public function addAttributeGroup($data) {
}
public function editAttributeGroup($attribute_group_id, $data) {
$this->event->trigger('pre_admin_edit_attribute_group');
$this->db->query("UPDATE " . DB_PREFIX . "attribute_group SET sort_order = '" . (int)$data['sort_order'] . "' WHERE attribute_group_id = '" . (int)$attribute_group_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "attribute_group_description WHERE attribute_group_id = '" . (int)$attribute_group_id . "'");
@@ -27,10 +31,12 @@ public function editAttributeGroup($attribute_group_id, $data) {
}
public function deleteAttributeGroup($attribute_group_id) {
$this->event->trigger('pre_admin_delete_attribute_group', array('attribute_group_id' => $attribute_group_id));
$this->db->query("DELETE FROM " . DB_PREFIX . "attribute_group WHERE attribute_group_id = '" . (int)$attribute_group_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "attribute_group_description WHERE attribute_group_id = '" . (int)$attribute_group_id . "'");
$this->event->trigger('admin_delete_attribute_group');
$this->event->trigger('admin_delete_attribute_group', array('attribute_group_id' => $attribute_group_id));
}
public function getAttributeGroup($attribute_group_id) {
@@ -1,6 +1,8 @@
<?php
class ModelCatalogCategory extends Model {
public function addCategory($data) {
$this->event->trigger('pre_admin_add_category');
$this->db->query("INSERT INTO " . DB_PREFIX . "category SET parent_id = '" . (int)$data['parent_id'] . "', `top` = '" . (isset($data['top']) ? (int)$data['top'] : 0) . "', `column` = '" . (int)$data['column'] . "', sort_order = '" . (int)$data['sort_order'] . "', status = '" . (int)$data['status'] . "', date_modified = NOW(), date_added = NOW()");
$category_id = $this->db->getLastId();
@@ -59,6 +61,8 @@ public function addCategory($data) {
}
public function editCategory($category_id, $data) {
$this->event->trigger('pre_admin_edit_category');
$this->db->query("UPDATE " . DB_PREFIX . "category SET parent_id = '" . (int)$data['parent_id'] . "', `top` = '" . (isset($data['top']) ? (int)$data['top'] : 0) . "', `column` = '" . (int)$data['column'] . "', sort_order = '" . (int)$data['sort_order'] . "', status = '" . (int)$data['status'] . "', date_modified = NOW() WHERE category_id = '" . (int)$category_id . "'");
if (isset($data['image'])) {
@@ -160,6 +164,8 @@ public function editCategory($category_id, $data) {
}
public function deleteCategory($category_id) {
$this->event->trigger('pre_admin_delete_category', array('category_id' => $category_id));
$this->db->query("DELETE FROM " . DB_PREFIX . "category_path WHERE category_id = '" . (int)$category_id . "'");
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category_path WHERE path_id = '" . (int)$category_id . "'");
@@ -178,7 +184,7 @@ public function deleteCategory($category_id) {
$this->cache->delete('category');
$this->event->trigger('admin_delete_category');
$this->event->trigger('admin_delete_category', array('category_id' => $category_id));
}
public function repairCategories($parent_id = 0) {
@@ -1,6 +1,8 @@
<?php
class ModelCatalogDownload extends Model {
public function addDownload($data) {
$this->event->trigger('pre_admin_add_download');
$this->db->query("INSERT INTO " . DB_PREFIX . "download SET filename = '" . $this->db->escape($data['filename']) . "', mask = '" . $this->db->escape($data['mask']) . "', date_added = NOW()");
$download_id = $this->db->getLastId();
@@ -15,6 +17,8 @@ public function addDownload($data) {
}
public function editDownload($download_id, $data) {
$this->event->trigger('pre_admin_edit_download');
$this->db->query("UPDATE " . DB_PREFIX . "download SET filename = '" . $this->db->escape($data['filename']) . "', mask = '" . $this->db->escape($data['mask']) . "' WHERE download_id = '" . (int)$download_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "download_description WHERE download_id = '" . (int)$download_id . "'");
@@ -27,10 +31,12 @@ public function editDownload($download_id, $data) {
}
public function deleteDownload($download_id) {
$this->event->trigger('pre_admin_delete_download', array('download_id' => $download_id));
$this->db->query("DELETE FROM " . DB_PREFIX . "download WHERE download_id = '" . (int)$download_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "download_description WHERE download_id = '" . (int)$download_id . "'");
$this->event->trigger('admin_delete_download');
$this->event->trigger('admin_delete_download', array('download_id' => $download_id));
}
public function getDownload($download_id) {
@@ -1,6 +1,8 @@
<?php
class ModelCatalogFilter extends Model {
public function addFilter($data) {
$this->event->trigger('pre_admin_add_filter');
$this->db->query("INSERT INTO `" . DB_PREFIX . "filter_group` SET sort_order = '" . (int)$data['sort_order'] . "'");
$filter_group_id = $this->db->getLastId();
@@ -27,6 +29,8 @@ public function addFilter($data) {
}
public function editFilter($filter_group_id, $data) {
$this->event->trigger('pre_admin_edit_filter');
$this->db->query("UPDATE `" . DB_PREFIX . "filter_group` SET sort_order = '" . (int)$data['sort_order'] . "' WHERE filter_group_id = '" . (int)$filter_group_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "filter_group_description WHERE filter_group_id = '" . (int)$filter_group_id . "'");
@@ -58,12 +62,14 @@ public function editFilter($filter_group_id, $data) {
}
public function deleteFilter($filter_group_id) {
$this->event->trigger('pre_admin_delete_filter', array('filter_id' => $filter_id));
$this->db->query("DELETE FROM `" . DB_PREFIX . "filter_group` WHERE filter_group_id = '" . (int)$filter_group_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "filter_group_description` WHERE filter_group_id = '" . (int)$filter_group_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "filter` WHERE filter_group_id = '" . (int)$filter_group_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "filter_description` WHERE filter_group_id = '" . (int)$filter_group_id . "'");
$this->event->trigger('admin_delete_filter');
$this->event->trigger('admin_delete_filter', array('filter_id' => $filter_id));
}
public function getFilterGroup($filter_group_id) {
@@ -1,6 +1,8 @@
<?php
class ModelCatalogInformation extends Model {
public function addInformation($data) {
$this->event->trigger('pre_admin_add_information');
$this->db->query("INSERT INTO " . DB_PREFIX . "information SET sort_order = '" . (int)$data['sort_order'] . "', bottom = '" . (isset($data['bottom']) ? (int)$data['bottom'] : 0) . "', status = '" . (int)$data['status'] . "'");
$information_id = $this->db->getLastId();
@@ -35,6 +37,8 @@ public function addInformation($data) {
}
public function editInformation($information_id, $data) {
$this->event->trigger('pre_admin_edit_information');
$this->db->query("UPDATE " . DB_PREFIX . "information SET sort_order = '" . (int)$data['sort_order'] . "', bottom = '" . (isset($data['bottom']) ? (int)$data['bottom'] : 0) . "', status = '" . (int)$data['status'] . "' WHERE information_id = '" . (int)$information_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "information_description WHERE information_id = '" . (int)$information_id . "'");
@@ -73,6 +77,8 @@ public function editInformation($information_id, $data) {
}
public function deleteInformation($information_id) {
$this->event->trigger('pre_admin_delete_information', array('information_id' => $information_id));
$this->db->query("DELETE FROM " . DB_PREFIX . "information WHERE information_id = '" . (int)$information_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "information_description WHERE information_id = '" . (int)$information_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "information_to_store WHERE information_id = '" . (int)$information_id . "'");
@@ -81,7 +87,7 @@ public function deleteInformation($information_id) {
$this->cache->delete('information');
$this->event->trigger('admin_delete_information');
$this->event->trigger('admin_delete_information', array('information_id' => $information_id));
}
public function getInformation($information_id) {
@@ -1,6 +1,8 @@
<?php
class ModelCatalogManufacturer extends Model {
public function addManufacturer($data) {
$this->event->trigger('pre_admin_add_manufacturer');
$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer SET name = '" . $this->db->escape($data['name']) . "', sort_order = '" . (int)$data['sort_order'] . "'");
$manufacturer_id = $this->db->getLastId();
@@ -27,6 +29,8 @@ public function addManufacturer($data) {
}
public function editManufacturer($manufacturer_id, $data) {
$this->event->trigger('pre_admin_edit_manufacturer');
$this->db->query("UPDATE " . DB_PREFIX . "manufacturer SET name = '" . $this->db->escape($data['name']) . "', sort_order = '" . (int)$data['sort_order'] . "' WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
if (isset($data['image'])) {
@@ -53,13 +57,15 @@ public function editManufacturer($manufacturer_id, $data) {
}
public function deleteManufacturer($manufacturer_id) {
$this->event->trigger('pre_admin_delete_manufacturer', array('manufacturer_id' => $manufacturer_id));
$this->db->query("DELETE FROM " . DB_PREFIX . "manufacturer WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "manufacturer_to_store WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "url_alias WHERE query = 'manufacturer_id=" . (int)$manufacturer_id . "'");
$this->cache->delete('manufacturer');
$this->event->trigger('admin_delete_manufacturer');
$this->event->trigger('admin_delete_manufacturer', array('manufacturer_id' => $manufacturer_id));
}
public function getManufacturer($manufacturer_id) {
@@ -1,6 +1,8 @@
<?php
class ModelCatalogOption extends Model {
public function addOption($data) {
$this->event->trigger('pre_admin_add_option');
$this->db->query("INSERT INTO `" . DB_PREFIX . "option` SET type = '" . $this->db->escape($data['type']) . "', sort_order = '" . (int)$data['sort_order'] . "'");
$option_id = $this->db->getLastId();
@@ -27,6 +29,8 @@ public function addOption($data) {
}
public function editOption($option_id, $data) {
$this->event->trigger('pre_admin_edit_option');
$this->db->query("UPDATE `" . DB_PREFIX . "option` SET type = '" . $this->db->escape($data['type']) . "', sort_order = '" . (int)$data['sort_order'] . "' WHERE option_id = '" . (int)$option_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "option_description WHERE option_id = '" . (int)$option_id . "'");
@@ -59,12 +63,14 @@ public function editOption($option_id, $data) {
}
public function deleteOption($option_id) {
$this->event->trigger('pre_admin_delete_option', array('option_id' => $option_id));
$this->db->query("DELETE FROM `" . DB_PREFIX . "option` WHERE option_id = '" . (int)$option_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "option_description WHERE option_id = '" . (int)$option_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "option_value WHERE option_id = '" . (int)$option_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "option_value_description WHERE option_id = '" . (int)$option_id . "'");
$this->event->trigger('admin_delete_option');
$this->event->trigger('admin_delete_option', array('option_id' => $option_id));
}
public function getOption($option_id) {
@@ -1,6 +1,8 @@
<?php
class ModelCatalogProduct extends Model {
public function addProduct($data) {
$this->event->trigger('pre_admin_add_product');
$this->db->query("INSERT INTO " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . $this->db->escape($data['tax_class_id']) . "', sort_order = '" . (int)$data['sort_order'] . "', date_added = NOW()");
$product_id = $this->db->getLastId();
@@ -126,6 +128,8 @@ public function addProduct($data) {
}
public function editProduct($product_id, $data) {
$this->event->trigger('pre_admin_edit_product');
$this->db->query("UPDATE " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . $this->db->escape($data['tax_class_id']) . "', sort_order = '" . (int)$data['sort_order'] . "', date_modified = NOW() WHERE product_id = '" . (int)$product_id . "'");
if (isset($data['image'])) {
@@ -312,6 +316,8 @@ public function copyProduct($product_id) {
}
public function deleteProduct($product_id) {
$this->event->trigger('pre_admin_delete_product', array('product_id' => $product_id));
$this->db->query("DELETE FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product_id . "'");
@@ -1,6 +1,8 @@
<?php
class ModelCatalogProfile extends Model {
public function addProfile($data) {
$this->event->trigger('pre_admin_add_profile');
$this->db->query("INSERT INTO `" . DB_PREFIX . "profile` SET `sort_order` = " . (int)$data['sort_order'] . ", `status` = " . (int)$data['status'] . ", `price` = " . (double)$data['price'] . ", `frequency` = '" . $this->db->escape($data['frequency']) . "', `duration` = " . (int)$data['duration'] . ", `cycle` = " . (int)$data['cycle'] . ", `trial_status` = " . (int)$data['trial_status'] . ", `trial_price` = " . (double)$data['trial_price'] . ", `trial_frequency` = '" . $this->db->escape($data['trial_frequency']) . "', `trial_duration` = " . (int)$data['trial_duration'] . ", `trial_cycle` = " . (int)$data['trial_cycle']);
$profile_id = $this->db->getLastId();
@@ -15,6 +17,8 @@ public function addProfile($data) {
}
public function editProfile($profile_id, $data) {
$this->event->trigger('pre_admin_edit_profile');
$this->db->query("DELETE FROM `" . DB_PREFIX . "profile_description` WHERE profile_id = " . (int)$profile_id);
$this->db->query("UPDATE `" . DB_PREFIX . "profile` SET `sort_order` = " . (int)$data['sort_order'] . ", `status` = " . (int)$data['status'] . ", `price` = " . (double)$data['price'] . ", `frequency` = '" . $this->db->escape($data['frequency']) . "', `duration` = " . (int)$data['duration'] . ", `cycle` = " . (int)$data['cycle'] . ", `trial_status` = " . (int)$data['trial_status'] . ", `trial_price` = " . (double)$data['trial_price'] . ", `trial_frequency` = '" . $this->db->escape($data['trial_frequency']) . "', `trial_duration` = " . (int)$data['trial_duration'] . ", `trial_cycle` = " . (int)$data['trial_cycle'] . " WHERE profile_id = " . (int)$profile_id);
@@ -38,13 +42,15 @@ public function copyProfile($profile_id) {
}
public function deleteProfile($profile_id) {
$this->event->trigger('pre_admin_delete_profile', array('profile_id' => $profile_id));
$this->db->query("DELETE FROM `" . DB_PREFIX . "profile` WHERE profile_id = " . (int)$profile_id);
$this->db->query("DELETE FROM `" . DB_PREFIX . "profile_description` WHERE profile_id = " . (int)$profile_id);
$this->db->query("DELETE FROM `" . DB_PREFIX . "product_profile` WHERE profile_id = " . (int)$profile_id);
$this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `profile_id` = 0 WHERE `profile_id` = " . (int)$profile_id);
$this->event->trigger('admin_delete_profile');
$this->event->trigger('admin_delete_profile', array('profile_id' => $profile_id));
}
public function getProfile($profile_id) {

9 comments on commit a69c05c

@jamesallsup

This comment has been minimized.

Copy link
Contributor Author

replied Aug 6, 2014

Hmm I hadn't thought about that but that's a great shout. Will take a look at that.

@JAY6390

This comment has been minimized.

Copy link
Contributor

replied Aug 6, 2014

http://forum.opencart.com/viewtopic.php?f=100&t=128438#p507837
We have discussed this previously :) Clearly a lot going on 👍

@jamesallsup

This comment has been minimized.

Copy link
Contributor Author

replied Aug 6, 2014

Tbh I've forgotten what day it is! Lol

@jamesallsup

This comment has been minimized.

Copy link
Contributor Author

replied Aug 7, 2014

All done :) 4c3fd50

@JAY6390

This comment has been minimized.

Copy link
Contributor

replied Aug 7, 2014

Great stuff, will give it some thorough testing over the next few days

@JAY6390

This comment has been minimized.

Copy link
Contributor

replied Aug 8, 2014

Just done some testing on this, and all seems to be working perfectly 👍 One suggestion - Create a folder called 'event' in the admin directory too, and possibly make it more obvious that events go into their own folder. I naturally assumed with it being registered in one of my modules, that the event would have to be run through that controller, and only then realised that it was a completely new directory and needed to create it. May also be worth adding a note in the wiki about the standard event that comes with 2.0 (pp_login) for reference for new developers on how to create them, or even reference them in the examples on the wiki instead

@JAY6390

This comment has been minimized.

Copy link
Contributor

replied Aug 8, 2014

Class could be simply EventVendorMod and either extend Controller, or a new class called Event that gives access to $this->config... etc

@jamesallsup

This comment has been minimized.

Copy link
Contributor Author

replied Aug 8, 2014

I need to do a demo event ideally - that has a front end example and admin and would include the whole structure.

There is more to merge into master so the folder will appear at some point in the admin, they are almost ready.

@OpencartHelp Events are already in a separate folder, identical structure to controllers/models too (easier for people to understand). The idea is that you put events in the same folder structure as you would the controller event/module/ or event/account etc BUT since you specify the location you could use whatever you want

$this->model_tool_event->setHandler('admin_add_product', array(
    'type' => 'wm', // i.e. this could be the vendor folder
    'code' => 'demo', // i.e. this is the file name or demo.php etc
    'method' => 'sendAdminAlert') // method name that is called
);

This would be admin/event/wm/demo.php

@JAY6390 You extend Event (its the same as controller/model though due to the changes in 2.0). Just had to fix the current event to use the correct one:
https://github.com/opencart/opencart/blob/master/upload/catalog/event/module/pp_login.php

You can access anything you need, db, config, request, session etc - same as a controller.

The only reason why these are not controller methods was a security issue where you could access in the browser directly, big issue when you are passing sensitive data around..

@mhcwebdesign

This comment has been minimized.

Copy link

replied Aug 8, 2014

It would be very useful to have events for controller actions (before and after), also an event where an action is completed, but the rendering hasn't been done yet. For example:

<?php
class ControllerProductProduct extends Controller {
    ....
    public function index() {
        $this->event->trigger('before_product_product_index', $data);
        ......
        if ($product_info) {
            ......
            if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
                $this->event->trigger('prerender_product_product_index', $this->config->get('config_template') . '/template/product/product.tpl', $data);
                $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/product.tpl', $data));
                $this->event->trigger('after_product_product_index', $this->config->get('config_template') . '/template/product/product.tpl', $data);
            } else {
                $this->event->trigger('prerender_product_product_index', 'default/template/product/product.tpl', $data);
                $this->response->setOutput($this->load->view('default/template/product/product.tpl', $data));
                $this->event->trigger('after_product_product_index', 'default/template/product/product.tpl', $data);
            }
        } else {
            .....
        }
    }
    ....
}
?>

This will make it lot easier for 3rd party extensions to modify core controllers for their needs.

That still leaves the question on how to modify templates and language files, maybe events should also be triggered for the latter in the appropriate places in system/engine/loader.php .

BTW.: I still think the system/library/event.php should be renamed to system/library/mediator.php, because its not an event here, rather it's the mediator between the subject (models,controllers) and the event handler (system/engine/event.php), we are dealing here with a mediator design pattern, see e.g. http://blog.ircmaxell.com/2012/03/handling-plugins-in-php.html

Please sign in to comment.
You can’t perform that action at this time.