Skip to content

Commit

Permalink
Fix autoload and template path (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
s4ddly authored Mar 18, 2024
1 parent 78132ec commit d11df26
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
29 changes: 1 addition & 28 deletions examples/loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,4 @@

namespace Tpay\Example;

spl_autoload_register(function ($class) {
// project-specific namespace prefix
$prefix = 'tpayLibs\\';

// base directory for the namespace prefix
$base_dir = __DIR__.'/../';

// does the class use the namespace prefix?
$len = strlen($prefix);
if (0 !== strncmp($prefix, $class, $len)) {
// no, move to the next registered autoloader
return;
}

// get the relative class name
$relative_class = substr($class, $len);

// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $base_dir.str_replace('\\', '/', $relative_class).'.php';

// if the file exists, require it

if (file_exists($file)) {
require $file;
}
});
require '../vendor/autoload.php';
2 changes: 1 addition & 1 deletion src/Utilities/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function parseTemplate($templateFileName, $data = [])
$data['static_files_url'] = static::$libraryPath;
}
if (is_null(static::$customTemplateDirectory)) {
$templateDirectory = dirname(__FILE__).'/../../View/Templates/';
$templateDirectory = dirname(__FILE__).'/../View/Templates/';
} else {
$templateDirectory = static::$customTemplateDirectory;
}
Expand Down

0 comments on commit d11df26

Please sign in to comment.