forked from Scalingo/matomo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add legacy autoloader to support Matomo namespaces in 3.X (matomo-org…
- Loading branch information
1 parent
95b71fd
commit 7c45f1f
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
class LegacyAutoloader | ||
{ | ||
public function __construct() | ||
{ | ||
spl_autoload_register(array($this, 'load_class')); | ||
} | ||
|
||
public static function register() | ||
{ | ||
new LegacyAutoloader(); | ||
} | ||
|
||
public function load_class($className) | ||
{ | ||
if (strpos($className, 'Matomo\\') === 0) { | ||
$newName = 'Piwik' . substr($className, 6); | ||
if (class_exists($newName) && !class_exists($className, false)) { | ||
@class_alias($newName, $className); | ||
} | ||
} elseif (strpos($className, 'Piwik\\') === 0) { | ||
$newName = 'Matomo' . substr($className, 5); | ||
if (class_exists($newName) && !class_exists($className, false)) { | ||
@class_alias($newName, $className); | ||
} | ||
} | ||
} | ||
} | ||
|
||
LegacyAutoloader::register(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters