/** * Instantiates this class * */ public function __construct() { // Set current environment key $this->current_env = EnvManager::getInstance()->getCurrentKey(); // Get paths manager $paths = PathManager::getInstance(); // Create hooks base structure $this->hooks = new Collection(['presets' => [__DIR__ . '/presets.json', $paths->get('theme', 'bebop-presets.json')], 'build' => [$paths->get('theme', 'bebop.json')]]); // Create config collection $this->config = new Collection(); // Build configuration on the after_setup_theme hook add_action('after_setup_theme', [$this, 'build']); }
/** * Returns the Env class instance or * the target environment by using its key * */ public static function Env($key = null) { $env_manager = EnvManager::getInstance(); return is_string($key) && $env_manager->exists($key) ? $env_manager->get($key) : $env_manager; }
/** * Executes any function that exists for the current environment * */ protected function __applyEnvModifications() { // Get current environment $current_env = EnvManager::getInstance()->getCurrentKey(); // Execute current environment function if ($this->env_configs->hasKey($current_env)) { call_user_func_array($this->env_configs->get($current_env), array($this)); } }