HEX
Server: LiteSpeed
System: Linux eko108.isimtescil.net 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: uyarreklamcomtr (11202)
PHP: 7.4.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/ThirdPartyServiceProvider.php.tar
plugins/google-listings-and-ads/src/Internal/DependencyManagement/ThirdPartyServiceProvider.php000064400000004727151556100100041307 0ustar00var/www/vhosts/uyarreklam.com.tr/httpdocs/wp-content<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement;

use Automattic\Jetpack\Config;
use Automattic\Jetpack\Connection\Manager;
use Automattic\WooCommerce\GoogleListingsAndAds\Internal\Interfaces\ISO3166AwareInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\PluginHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\ISO3166\ISO3166;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\ISO3166\ISO3166DataProvider;
use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\Validator\ValidatorInterface;

defined( 'ABSPATH' ) || exit;

/**
 * Class ThirdPartyServiceProvider
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement
 */
class ThirdPartyServiceProvider extends AbstractServiceProvider {

	use PluginHelper;

	/**
	 * Array of classes provided by this container.
	 *
	 * Keys should be the class name, and the value can be anything (like `true`).
	 *
	 * @var array
	 */
	protected $provides = [
		Config::class              => true,
		Manager::class             => true,
		ISO3166DataProvider::class => true,
		ValidatorInterface::class  => true,
	];

	/**
	 * Use the register method to register items with the container via the
	 * protected $this->container property or the `getContainer` method
	 * from the ContainerAwareTrait.
	 *
	 * @return void
	 */
	public function register(): void {
		$jetpack_id = 'google-listings-and-ads';
		$this->share( Manager::class )->addArgument( $jetpack_id );

		$this->share( Config::class )->addMethodCall(
			'ensure',
			[
				'connection',
				[
					'slug' => $jetpack_id,
					'name' => 'Google for WooCommerce', // Use hardcoded name for initial registration.
				],
			]
		);

		$this->share_concrete( ISO3166DataProvider::class, ISO3166::class );
		$this->getContainer()
			->inflector( ISO3166AwareInterface::class )
			->invokeMethod( 'set_iso3166_provider', [ ISO3166DataProvider::class ] );

		$this->share_concrete(
			ValidatorInterface::class,
			function () {
				return Validation::createValidatorBuilder()
					->addMethodMapping( 'load_validator_metadata' )
					->getValidator();
			}
		);

		// Update Jetpack connection with a translatable name, after init is called.
		add_action(
			'init',
			function () {
				$manager = $this->getContainer()->get( Manager::class );
				$manager->get_plugin()->add(
					__( 'Google for WooCommerce', 'google-listings-and-ads' )
				);
			}
		);
	}
}