Refactor all env variables into Env class.
This commit is contained in:
@ -4,7 +4,15 @@ namespace MailPoet\Config;
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Env {
|
||||
public static $version;
|
||||
public static $plugin_name;
|
||||
public static $file;
|
||||
public static $path;
|
||||
public static $views_path;
|
||||
public static $assets_path;
|
||||
public static $assets_url;
|
||||
public static $languages_path;
|
||||
public static $lib_path;
|
||||
public static $plugin_prefix;
|
||||
public static $db_prefix;
|
||||
public static $db_source_name;
|
||||
@ -14,9 +22,17 @@ class Env {
|
||||
public static $db_password;
|
||||
public static $db_charset;
|
||||
|
||||
public static function init() {
|
||||
public static function init($file, $version) {
|
||||
global $wpdb;
|
||||
self::$version = $version;
|
||||
self::$plugin_name = 'mailpoet';
|
||||
self::$file = $file;
|
||||
self::$path = dirname(self::$file);
|
||||
self::$views_path = self::$path . '/views';
|
||||
self::$assets_path = self::$path . '/assets';
|
||||
self::$assets_url = plugins_url('/assets', $file);
|
||||
self::$languages_path = self::$path . '/lang';
|
||||
self::$lib_path = self::$path . '/lib';
|
||||
self::$plugin_prefix = 'mailpoet_';
|
||||
self::$db_prefix = $wpdb->prefix . self::$plugin_prefix;
|
||||
self::$db_source_name = self::dbSourceName();
|
||||
|
@ -18,7 +18,7 @@ class Initializer {
|
||||
'file' => '',
|
||||
'version' => '1.0.0'
|
||||
)) {
|
||||
Env::init();
|
||||
Env::init($params['file'], $params['version']);
|
||||
$this->setup_db();
|
||||
|
||||
$this->data = array();
|
||||
|
@ -4,7 +4,7 @@ use \MailPoet\Config\Env;
|
||||
|
||||
class EnvCest {
|
||||
function _before() {
|
||||
Env::init();
|
||||
Env::init('file', '1.0.0');
|
||||
}
|
||||
|
||||
function itCanReturnThePluginPrefix() {
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
use \MailPoet\Config\Env;
|
||||
|
||||
$wordpress_path = getenv('WP_TEST_PATH');
|
||||
|
||||
|
Reference in New Issue
Block a user