Skip to content

Commit

Permalink
Add back-compatibility of removed Loader
Browse files Browse the repository at this point in the history
For case if any project already using `new Loader()` to access plugin internals.
  • Loading branch information
jakubboucek committed Oct 13, 2019
1 parent d684e1e commit 83c78d9
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/Loader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* @package Redbit\SimpleShop\WpPlugin
* @license MIT
* @copyright 2016-2018 Redbit s.r.o.
* @author Redbit s.r.o. <[email protected]>
*/

namespace Redbit\SimpleShop\WpPlugin;

/**
* Back-compatibility of deprecated plugin loader
* @package Redbit\SimpleShop\WpPlugin
*/
class Loader {
public function __construct() {
$class = SimpleShop::class;
trigger_error(
"Manually start of plugin is deprecated, use '$class::getInstance()' instead",
E_USER_DEPRECATED
);
}

/**
* @param string $method
* @param array $arguments
*
* @return mixed
*/
public function __call( $method, array $arguments ) {
$currentClass = self::class;
$class = SimpleShop::class;
trigger_error(
"'$currentClass' is deprecated, use '$class::getInstance()->$method()' instead",
E_USER_DEPRECATED
);

return call_user_func_array( [ SimpleShop::getInstance(), $method ], $arguments );
}
}

0 comments on commit 83c78d9

Please sign in to comment.