Skip to content
Browse files

Move Autoloader to OSCOM::autoload

  • Loading branch information...
1 parent cb30821 commit d71c72d0cd513d7733482cca3d861baa589ba0d5 @haraldpdl committed Feb 24, 2014
Showing with 25 additions and 37 deletions.
  1. +2 −2 index.php
  2. +0 −35 osCommerce/OM/Core/Autoloader.php
  3. +23 −0 osCommerce/OM/Core/OSCOM.php
View
4 index.php
@@ -14,8 +14,8 @@
define('OSCOM_PUBLIC_BASE_DIRECTORY', __DIR__ . '/');
- require('osCommerce/OM/Core/Autoloader.php');
- spl_autoload_register('osCommerce\\OM\\Core\\Autoloader::load');
+ require('osCommerce/OM/Core/OSCOM.php');
+ spl_autoload_register('osCommerce\\OM\\Core\\OSCOM::autoload');
OSCOM::initialize();
View
35 osCommerce/OM/Core/Autoloader.php
@@ -1,35 +0,0 @@
-<?php
-/**
- * osCommerce Online Merchant
- *
- * @copyright Copyright (c) 2014 osCommerce; http://www.oscommerce.com
- * @license BSD License; http://www.oscommerce.com/bsdlicense.txt
- */
-
- namespace osCommerce\OM\Core;
-
- define('OSCOM_BASE_DIRECTORY', realpath(__DIR__ . '/../') . DIRECTORY_SEPARATOR);
-
- class Autoloader {
- public static function load($class) {
- $prefix = 'osCommerce\\OM\\';
-
-// only auto load related classes
- $len = strlen($prefix);
- if ( strncmp($prefix, $class, $len) !== 0 ) {
- return false;
- }
-
- $class = substr($class, $len);
-
- $file = OSCOM_BASE_DIRECTORY . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
- $custom = str_replace('osCommerce' . DIRECTORY_SEPARATOR . 'OM' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR, 'osCommerce' . DIRECTORY_SEPARATOR . 'OM' . DIRECTORY_SEPARATOR . 'Custom' . DIRECTORY_SEPARATOR, $file);
-
- if ( file_exists($custom) ) {
- require($custom);
- } else if ( file_exists($file) ) {
- require($file);
- }
- }
- }
-?>
View
23 osCommerce/OM/Core/OSCOM.php
@@ -8,6 +8,8 @@
namespace osCommerce\OM\Core;
+ define('OSCOM_BASE_DIRECTORY', realpath(__DIR__ . '/../') . DIRECTORY_SEPARATOR);
+
class OSCOM {
const TIMESTAMP_START = OSCOM_TIMESTAMP_START;
const BASE_DIRECTORY = OSCOM_BASE_DIRECTORY;
@@ -515,5 +517,26 @@ public static function getAllGET($exclude = null) {
return $params;
}
+
+ public static function autoload($class) {
+ $prefix = 'osCommerce\\OM\\';
+
+// only auto load related classes
+ $len = strlen($prefix);
+ if ( strncmp($prefix, $class, $len) !== 0 ) {
+ return false;
+ }
+
+ $class = substr($class, $len);
+
+ $file = OSCOM_BASE_DIRECTORY . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
+ $custom = str_replace('osCommerce' . DIRECTORY_SEPARATOR . 'OM' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR, 'osCommerce' . DIRECTORY_SEPARATOR . 'OM' . DIRECTORY_SEPARATOR . 'Custom' . DIRECTORY_SEPARATOR, $file);
+
+ if ( file_exists($custom) ) {
+ require($custom);
+ } else if ( file_exists($file) ) {
+ require($file);
+ }
+ }
}
?>

0 comments on commit d71c72d

Please sign in to comment.
Something went wrong with that request. Please try again.