Skip to content

Commit

Permalink
COMDEVNL-1814 -- Fix OCMod support to support 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
maximj committed Feb 8, 2019
1 parent 4eb6512 commit c6d3d2f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 27 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"license": "BSD-2-Clause",
"require": {
"php": ">=5.4.0",
"php": ">=5.6.0",
"ext-curl": "*",
"ext-openssl": "*"
},
Expand Down
58 changes: 32 additions & 26 deletions system/comercia/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ function library($library)
$bestOption = $this->findBestOption($libDir, $library, "php");
if (!class_exists($className)) {
if (class_exists("VQMod")) {
@include_once(\VQMod::modCheck(modification($libDir . $bestOption["name"] . ".php"), $libDir . $bestOption["name"] . ".php"));
@include_once(\VQMod::modCheck($this->modification($libDir . $bestOption["name"] . ".php"), $libDir . $bestOption["name"] . ".php"));
} else {
@include_once(modification($libDir . $bestOption["name"] . ".php"));
@include_once($this->modification($libDir . $bestOption["name"] . ".php"));
}
}

Expand Down Expand Up @@ -108,9 +108,9 @@ function model($model)
$className = $route["class"];
if (!class_exists($className)) {
if (class_exists("VQMod")) {
@include_once(\VQMod::modCheck(modification($modelDir . $route["file"] . ".php"), $modelDir . $route["file"] . ".php"));
@include_once(\VQMod::modCheck($this->modification($modelDir . $route["file"] . ".php"), $modelDir . $route["file"] . ".php"));
} else {
@include_once(modification($modelDir . $route["file"] . ".php"));
@include_once($this->modification($modelDir . $route["file"] . ".php"));
}
}

Expand All @@ -119,8 +119,8 @@ function model($model)
//Check for events
if(Util::version()->isMinimal("2.2")) {
$result = new \Proxy();
$r = new \ReflectionMethod('Loader', 'callback');

$r = new \ReflectionMethod('Loader', 'callback');
$r->setAccessible(true);

foreach (get_class_methods($className) as $method) {
Expand All @@ -129,7 +129,7 @@ function model($model)
} else {
$result = new $className(Util::registry());
}

Util::registry()->set(Util::stringHelper()->ccToUnderline($className), $result);
return $result;
}
Expand Down Expand Up @@ -234,9 +234,9 @@ function view($view, $data = array())
}
$fakeControllerFile = __DIR__ . "/fakeController.php";
if (class_exists("VQMod")) {
require_once(\VQMod::modCheck(modification($fakeControllerFile), $fakeControllerFile));
require_once(\VQMod::modCheck($this->modification($fakeControllerFile), $fakeControllerFile));
} else {
require_once(modification($fakeControllerFile));
require_once($this->modification($fakeControllerFile));
}
$controller = new FakeController($registry);
$result = $controller->getView($view, $data);
Expand Down Expand Up @@ -326,9 +326,9 @@ function controller($controller)
$className = $route["class"];
if (!class_exists($className)) {
if (class_exists("VQMod")) {
@include_once(\VQMod::modCheck(modification($controllerDir . $route["file"] . ".php"), $controllerDir . $route["file"] . ".php"));
@include_once(\VQMod::modCheck($this->modification($controllerDir . $route["file"] . ".php"), $controllerDir . $route["file"] . ".php"));
} else {
@include_once(modification($controllerDir . $route["file"] . ".php"));
@include_once($this->modification($controllerDir . $route["file"] . ".php"));
}
}

Expand Down Expand Up @@ -368,12 +368,16 @@ private function rewriteModel($model)
"" => "sale/custom_field",
"2.1" => "customer/custom_field"
],
[
"" => "sale/customer_group",
"2.1" => "customer/customer_group"
],
[
"" => "setting/extension",
"2.0" => "extension/extension",
"3.0" => "setting/extension"
],
[
[
"" => "extension/event",
"3.0" => "setting/event"
]
Expand All @@ -393,23 +397,25 @@ private function rewriteLanguage($model)
]
);
}
// Modification Override

// Modification Override
function modification($filename) {
if (defined('DIR_CATALOG')) {
$file = DIR_MODIFICATION . 'admin/' . substr($filename, strlen(DIR_APPLICATION));
} elseif (defined('DIR_OPENCART')) {
$file = DIR_MODIFICATION . 'install/' . substr($filename, strlen(DIR_APPLICATION));
} else {
$file = DIR_MODIFICATION . 'catalog/' . substr($filename, strlen(DIR_APPLICATION));
}
if (Util::version()->isMinimal(2.0)) {
if (defined('DIR_CATALOG')) {
$file = DIR_MODIFICATION . 'admin/' . substr($filename, strlen(DIR_APPLICATION));
} elseif (defined('DIR_OPENCART')) {
$file = DIR_MODIFICATION . 'install/' . substr($filename, strlen(DIR_APPLICATION));
} else {
$file = DIR_MODIFICATION . 'catalog/' . substr($filename, strlen(DIR_APPLICATION));
}

if (substr($filename, 0, strlen(DIR_SYSTEM)) == DIR_SYSTEM) {
$file = DIR_MODIFICATION . 'system/' . substr($filename, strlen(DIR_SYSTEM));
}
if (substr($filename, 0, strlen(DIR_SYSTEM)) == DIR_SYSTEM) {
$file = DIR_MODIFICATION . 'system/' . substr($filename, strlen(DIR_SYSTEM));
}

if (is_file($file)) {
return $file;
if (is_file($file)) {
return $file;
}
}

return $filename;
Expand Down

0 comments on commit c6d3d2f

Please sign in to comment.