Skip to content

Instantly share code, notes, and snippets.

@matrunchyk
Last active October 15, 2015 09:58
Show Gist options
  • Save matrunchyk/1085a6750b57499119bd to your computer and use it in GitHub Desktop.
Save matrunchyk/1085a6750b57499119bd to your computer and use it in GitHub Desktop.
Proposal for OpenCart guys
<?php
// ...
public function model($model, $data = array()) {
// $this->event->trigger('pre/model/' . str_replace('/', '.', (string)$model), $data);
$model = str_replace('../', '', (string)$model);
/* <custom_model_support> */
$mod_file = DIR_MODIFICATION . ((defined('HTTP_CATALOG')) ? 'admin' : 'catalog') . '/model/' . $model . '.php';
/* </custom_model_support> */
$file = DIR_APPLICATION . 'model/' . $model . '.php';
$class = 'Model' . preg_replace('/[^a-zA-Z0-9]/', '', $model);
if (file_exists($file)) {
include_once(modification($file));
$this->registry->set('model_' . str_replace('/', '_', $model), new $class($this->registry));
/* <custom_model_support> */
} elseif (file_exists($mod_file)) {
include_once($mod_file);
$this->registry->set('model_' . str_replace('/', '_', $model), new $class($this->registry));
/* </custom_model_support> */
} else {
trigger_error('Error: Could not load model ' . $file . '!');
exit();
}
// $this->event->trigger('post/model/' . str_replace('/', '.', (string)$model), $output);
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment