Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rebranded composer components #15253

Merged
merged 8 commits into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions LegacyAutoloader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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, 'Piwik\\') === 0) {
$newName = 'Matomo' . substr($className, 5);
if (class_exists($newName)) {
class_alias($newName, $className);
}
}
}
}

LegacyAutoloader::register();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I missed it but could we add maybe a few basic tests that this works?

In general behaviour seems otherwise good: https://3v4l.org/TAS8d

Can we assume, that if a file containing a Matomo class was loaded manually through include/require, then the logic would not work? (Probably not an issue but something to be aware of eg if we wanted to do that for all classes in core).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that works as well. Added some simple tests for it. See de2fea6

15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@
"symfony/console": "~2.6.0",
"mustangostang/spyc": "~0.6.0",
"piwik/device-detector": "~3.0",
"piwik/decompress": "~1.0",
"piwik/network": "~0",
"piwik/cache": "~1.0.0",
"piwik/ini": "^1.0.8",
"matomo/decompress": "~2.0",
"matomo/cache": "~2.0",
"matomo/ini": "~2.0",
"php-di/php-di": "^5.0.0",
"psr/log": "~1.0",
"monolog/monolog": "~1.11",
Expand All @@ -44,12 +43,13 @@
"matomo/referrer-spam-blacklist": "~1.0",
"matomo/searchengine-and-social-list": "~1.0",
"tecnickcom/tcpdf": "~6.0",
"piwik/piwik-php-tracker": "^1.0.0",
"composer/semver": "~1.3.0",
"szymach/c-pchart": "^2.0",
"geoip2/geoip2": "^2.8",
"davaxi/sparkline": "dev-multiple-series",
"matomo-org/jshrink": "1.3.1"
"matomo-org/jshrink": "1.3.1",
"matomo/network": "~2.0",
"matomo/matomo-php-tracker": "~2.0"
},
"require-dev": {
"aws/aws-sdk-php": "2.7.1",
Expand Down Expand Up @@ -148,7 +148,8 @@
"HTML_": "libs/",
"PEAR_": "libs/",
"Archive_": "libs/"
}
},
"files": ["LegacyAutoloader.php"]
},
"autoload-dev": {
"psr-4": {
Expand Down
Loading