| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* JCH Optimize - Performs several front-end optimizations for fast downloads |
| 5 |
* |
| 6 |
* @package jchoptimize/wordpress-platform |
| 7 |
* @author Samuel Marshall <samuel@jch-optimize.net> |
| 8 |
* @copyright Copyright (c) 2021 Samuel Marshall / JCH Optimize |
| 9 |
* @license GNU/GPLv3, or later. See LICENSE file |
| 10 |
* |
| 11 |
* If LICENSE file missing, see <http://www.gnu.org/licenses/>. |
| 12 |
*/ |
| 13 |
|
| 14 |
namespace JchOptimize\WordPress\Service; |
| 15 |
|
| 16 |
use _JchOptimizeVendor\V91\Joomla\DI\Container; |
| 17 |
use _JchOptimizeVendor\V91\Joomla\DI\ServiceProviderInterface; |
| 18 |
use JchOptimize\Core\Registry; |
| 19 |
|
| 20 |
use function define; |
| 21 |
use function defined; |
| 22 |
use function get_option; |
| 23 |
|
| 24 |
class ConfigurationProvider implements ServiceProviderInterface |
| 25 |
{ |
| 26 |
public function register(Container $container): void |
| 27 |
{ |
| 28 |
$container->alias('params', Registry::class) |
| 29 |
->share( |
| 30 |
Registry::class, |
| 31 |
function (): Registry { |
| 32 |
$params = new Registry(get_option('jch-optimize_settings')); |
| 33 |
|
| 34 |
if (!defined('JCH_DEBUG')) { |
| 35 |
define('JCH_DEBUG', ($params->get('debug', 0))); |
| 36 |
} |
| 37 |
|
| 38 |
return $params; |
| 39 |
}, |
| 40 |
); |
| 41 |
} |
| 42 |
} |
| 43 |
|