AmplitudeProvider.php
2 months ago
AssetsProvider.php
11 months ago
BlocksProvider.php
3 months ago
ClientProvider.php
2 months ago
ContainerProvider.php
11 months ago
DatabaseProvider.php
8 months ago
HostingRoutesProvider.php
2 months ago
IntegrationsProvider.php
5 months ago
JobsProvider.php
7 months ago
MenusProvider.php
11 months ago
NoticesProvider.php
4 months ago
ProviderInterface.php
11 months ago
RedirectsProvider.php
11 months ago
RoutesProvider.php
9 months ago
SurveysProvider.php
2 months ago
TrackingProvider.php
8 months ago
WebhooksProvider.php
8 months ago
WpdbProvider.php
11 months ago
ClientProvider.php
37 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Hostinger\Reach\Providers; |
| 4 | |
| 5 | use Hostinger\Reach\Container; |
| 6 | use Hostinger\WpHelper\Config; |
| 7 | use Hostinger\WpHelper\Constants; |
| 8 | use Hostinger\WpHelper\Requests\Client; |
| 9 | use Hostinger\WpHelper\Utils as Helper; |
| 10 | |
| 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | die; |
| 13 | } |
| 14 | |
| 15 | class ClientProvider implements ProviderInterface { |
| 16 | |
| 17 | public function register( Container $container ): void { |
| 18 | $container->set( Helper::class, fn() => new Helper() ); |
| 19 | $container->set( Config::class, fn() => new Config() ); |
| 20 | $container->set( |
| 21 | Client::class, |
| 22 | function () use ( $container ) { |
| 23 | return new Client( |
| 24 | $container->get( Config::class )->getConfigValue( |
| 25 | 'base_rest_uri', |
| 26 | Constants::HOSTINGER_REST_URI |
| 27 | ), |
| 28 | array( |
| 29 | Config::TOKEN_HEADER => apply_filters( 'hostinger_api_token', $container->get( Helper::class )->getApiToken() ), |
| 30 | Config::DOMAIN_HEADER => apply_filters( 'hostinger_domain', $container->get( Helper::class )->getHostInfo() ), |
| 31 | ) |
| 32 | ); |
| 33 | } |
| 34 | ); |
| 35 | } |
| 36 | } |
| 37 |