| 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) 2025 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 _JchOptimizeVendor\V91\Psr\Http\Client\ClientInterface; |
| 19 |
use _JchOptimizeVendor\V91\Psr\Log\LoggerInterface; |
| 20 |
use JchOptimize\Core\Platform\CacheInterface; |
| 21 |
use JchOptimize\Core\Platform\ExcludesInterface; |
| 22 |
use JchOptimize\Core\Platform\HooksInterface; |
| 23 |
use JchOptimize\Core\Platform\HtmlInterface; |
| 24 |
use JchOptimize\Core\Platform\PathsInterface; |
| 25 |
use JchOptimize\Core\Platform\PluginInterface; |
| 26 |
use JchOptimize\Core\Platform\ProfilerInterface; |
| 27 |
use JchOptimize\Core\Platform\UtilityInterface; |
| 28 |
use JchOptimize\WordPress\Platform\Cache; |
| 29 |
use JchOptimize\WordPress\Platform\Excludes; |
| 30 |
use JchOptimize\WordPress\Platform\Hooks; |
| 31 |
use JchOptimize\WordPress\Platform\Html; |
| 32 |
use JchOptimize\WordPress\Platform\Paths; |
| 33 |
use JchOptimize\WordPress\Platform\Plugin; |
| 34 |
use JchOptimize\WordPress\Platform\Profiler; |
| 35 |
use JchOptimize\WordPress\Platform\Utility; |
| 36 |
|
| 37 |
class PlatformProvider implements ServiceProviderInterface |
| 38 |
{ |
| 39 |
public function register(Container $container): void |
| 40 |
{ |
| 41 |
$container->share(CacheInterface::class, function (): CacheInterface { |
| 42 |
return new Cache(); |
| 43 |
}); |
| 44 |
|
| 45 |
$container->share(ExcludesInterface::class, function (Container $container): ExcludesInterface { |
| 46 |
return new Excludes( |
| 47 |
$container->get(PathsInterface::class) |
| 48 |
); |
| 49 |
}); |
| 50 |
|
| 51 |
$container->share(HooksInterface::class, function (): HooksInterface { |
| 52 |
return new Hooks(); |
| 53 |
}); |
| 54 |
|
| 55 |
$container->share(PathsInterface::class, function (): PathsInterface { |
| 56 |
return new Paths(); |
| 57 |
}); |
| 58 |
|
| 59 |
$container->share(PluginInterface::class, function (): PluginInterface { |
| 60 |
return new Plugin(); |
| 61 |
}); |
| 62 |
|
| 63 |
$container->share(UtilityInterface::class, function (): UtilityInterface { |
| 64 |
return new Utility(); |
| 65 |
}); |
| 66 |
|
| 67 |
$container->share(HtmlInterface::class, function (Container $container): HtmlInterface { |
| 68 |
$html = new Html( |
| 69 |
$container->get(ClientInterface::class), |
| 70 |
$container->get(ProfilerInterface::class), |
| 71 |
$container->get(UtilityInterface::class) |
| 72 |
); |
| 73 |
$html->setLogger($container->get(LoggerInterface::class)); |
| 74 |
|
| 75 |
return $html; |
| 76 |
}); |
| 77 |
|
| 78 |
$container->share(ProfilerInterface::class, function (Container $container): ProfilerInterface { |
| 79 |
return new Profiler(); |
| 80 |
}); |
| 81 |
} |
| 82 |
} |
| 83 |
|