PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 2.0.6
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v2.0.6
4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 340 releases
profile-builder / assets / lib / Mustache / Autoloader.php

Autoloader.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 2.0.6, at assets/lib/Mustache/Autoloader.php

76 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of Mustache.php.
5 *
6 * (c) 2012 Justin Hileman
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 /**
13 * Mustache class autoloader.
14 */
15 class Mustache_Autoloader
16 {
17
18 private $baseDir;
19
20 /**
21 * Autoloader constructor.
22 *
23 * @param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
24 */
25 public function __construct($baseDir = null)
26 {
27 if ($baseDir === null) {
28 $baseDir = dirname(__FILE__).'/..';
29 }
30
31 // realpath doesn't always work, for example, with stream URIs
32 $realDir = realpath($baseDir);
33 if (is_dir($realDir)) {
34 $this->baseDir = $realDir;
35 } else {
36 $this->baseDir = $baseDir;
37 }
38 }
39
40 /**
41 * Register a new instance as an SPL autoloader.
42 *
43 * @param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
44 *
45 * @return Mustache_Autoloader Registered Autoloader instance
46 */
47 public static function register($baseDir = null)
48 {
49 $loader = new self($baseDir);
50 spl_autoload_register(array($loader, 'autoload'));
51
52 return $loader;
53 }
54
55 /**
56 * Autoload Mustache classes.
57 *
58 * @param string $class
59 */
60 public function autoload($class)
61 {
62 if ($class[0] === '\\') {
63 $class = substr($class, 1);
64 }
65
66 if (strpos($class, 'Mustache') !== 0) {
67 return;
68 }
69
70 $file = sprintf('%s/%s.php', $this->baseDir, str_replace('_', '/', $class));
71 if (is_file($file)) {
72 require $file;
73 }
74 }
75 }
76