File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/DependencyManagement.tar
AbstractServiceProvider.php 0000644 00000007741 15154275314 0012074 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Conditional;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\DefinitionInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\ServiceProvider\AbstractServiceProvider as LeagueProvider;
/**
* Class AbstractServiceProvider
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement
*/
abstract class AbstractServiceProvider extends LeagueProvider {
/**
* 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 = [];
/**
* Returns a boolean if checking whether this provider provides a specific
* service or returns an array of provided services if no argument passed.
*
* @param string $service
*
* @return boolean
*/
public function provides( string $service ): bool {
return array_key_exists( $service, $this->provides );
}
/**
* 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 {
foreach ( $this->provides as $class => $provided ) {
$this->share( $class );
}
}
/**
* Add an interface to the container.
*
* @param string $interface_name The interface to add.
* @param string|null $concrete (Optional) The concrete class.
*
* @return DefinitionInterface
*/
protected function share_concrete( string $interface_name, $concrete = null ): DefinitionInterface {
return $this->getContainer()->addShared( $interface_name, $concrete );
}
/**
* Share a class and add interfaces as tags.
*
* @param string $class_name The class name to add.
* @param mixed ...$arguments Constructor arguments for the class.
*
* @return DefinitionInterface
*/
protected function share_with_tags( string $class_name, ...$arguments ): DefinitionInterface {
$definition = $this->share( $class_name, ...$arguments );
foreach ( class_implements( $class_name ) as $interface_name ) {
$definition->addTag( $interface_name );
}
return $definition;
}
/**
* Share a class.
*
* Shared classes will always return the same instance of the class when the class is requested
* from the container.
*
* @param string $class_name The class name to add.
* @param mixed ...$arguments Constructor arguments for the class.
*
* @return DefinitionInterface
*/
protected function share( string $class_name, ...$arguments ): DefinitionInterface {
return $this->getContainer()->addShared( $class_name )->addArguments( $arguments );
}
/**
* Add a class.
*
* Classes will return a new instance of the class when the class is requested from the container.
*
* @param string $class_name The class name to add.
* @param mixed ...$arguments Constructor arguments for the class.
*
* @return DefinitionInterface
*/
protected function add( string $class_name, ...$arguments ): DefinitionInterface {
return $this->getContainer()->add( $class_name )->addArguments( $arguments );
}
/**
* Maybe share a class and add interfaces as tags.
*
* This will also check any classes that implement the Conditional interface and only add them if
* they are needed.
*
* @param string $class_name The class name to add.
* @param mixed ...$arguments Constructor arguments for the class.
*/
protected function conditionally_share_with_tags( string $class_name, ...$arguments ) {
$implements = class_implements( $class_name );
if ( array_key_exists( Conditional::class, $implements ) ) {
/** @var Conditional $class */
if ( ! $class_name::is_needed() ) {
return;
}
}
$this->provides[ $class_name ] = true;
$this->share_with_tags( $class_name, ...$arguments );
}
}
ContainerException.php 0000644 00000001256 15154275315 0011072 0 ustar 00 <?php
/**
* ExtendedContainer class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement;
/**
* Class ContainerException.
* Used to signal error conditions related to the dependency injection container.
*/
class ContainerException extends \Exception {
/**
* Create a new instance of the class.
*
* @param null $message The exception message to throw.
* @param int $code The error code.
* @param \Exception|null $previous The previous throwable used for exception chaining.
*/
public function __construct( $message = null, $code = 0, \Exception $previous = null ) {
parent::__construct( $message, $code, $previous );
}
}
Definition.php 0000644 00000003476 15154275315 0007367 0 ustar 00 <?php
/**
* An extension to the Definition class to prevent constructor injection from being possible.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement;
use Automattic\WooCommerce\Vendor\League\Container\Definition\Definition as BaseDefinition;
/**
* An extension of the definition class that replaces constructor injection with method injection.
*/
class Definition extends BaseDefinition {
/**
* The standard method that we use for dependency injection.
*/
public const INJECTION_METHOD = 'init';
/**
* Resolve a class using method injection instead of constructor injection.
*
* @param string $concrete The concrete to instantiate.
*
* @return object
*/
protected function resolveClass( string $concrete ) {
$instance = new $concrete();
$this->invokeInit( $instance );
return $instance;
}
/**
* Invoke methods on resolved instance, including 'init'.
*
* @param object $instance The concrete to invoke methods on.
*
* @return object
*/
protected function invokeMethods( $instance ) {
$this->invokeInit( $instance );
parent::invokeMethods( $instance );
return $instance;
}
/**
* Invoke the 'init' method on a resolved object.
*
* Constructor injection causes backwards compatibility problems
* so we will rely on method injection via an internal method.
*
* @param object $instance The resolved object.
* @return void
*/
private function invokeInit( $instance ) {
$resolved = $this->resolveArguments( $this->arguments );
if ( method_exists( $instance, static::INJECTION_METHOD ) ) {
call_user_func_array( array( $instance, static::INJECTION_METHOD ), $resolved );
}
}
/**
* Forget the cached resolved object, so the next time it's requested
* it will be resolved again.
*/
public function forgetResolved() {
$this->resolved = null;
}
}
ExtendedContainer.php 0000644 00000017025 15154275315 0010675 0 ustar 00 <?php
/**
* ExtendedContainer class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement;
use Automattic\WooCommerce\Container;
use Automattic\WooCommerce\Proxies\LegacyProxy;
use Automattic\WooCommerce\Testing\Tools\DependencyManagement\MockableLegacyProxy;
use Automattic\WooCommerce\Utilities\StringUtil;
use Automattic\WooCommerce\Vendor\League\Container\Container as BaseContainer;
use Automattic\WooCommerce\Vendor\League\Container\Definition\DefinitionInterface;
/**
* This class extends the original League's Container object by adding some functionality
* that we need for WooCommerce.
*/
class ExtendedContainer extends BaseContainer {
/**
* The root namespace of all WooCommerce classes in the `src` directory.
*
* @var string
*/
private $woocommerce_namespace = 'Automattic\\WooCommerce\\';
/**
* Holds the original registrations so that 'reset_replacement' can work, keys are class names and values are the original concretes.
*
* @var array
*/
private $original_concretes = array();
/**
* Whitelist of classes that we can register using the container
* despite not belonging to the WooCommerce root namespace.
*
* In general we allow only the registration of classes in the
* WooCommerce root namespace to prevent registering 3rd party code
* (which doesn't really belong to this container) or old classes
* (which may be eventually deprecated, also the LegacyProxy
* should be used for those).
*
* @var string[]
*/
private $registration_whitelist = array(
Container::class,
);
/**
* Register a class in the container.
*
* @param string $class_name Class name.
* @param mixed $concrete How to resolve the class with `get`: a factory callback, a concrete instance, another class name, or null to just create an instance of the class.
* @param bool|null $shared Whether the resolution should be performed only once and cached.
*
* @return DefinitionInterface The generated definition for the container.
* @throws ContainerException Invalid parameters.
*/
public function add( string $class_name, $concrete = null, bool $shared = null ) : DefinitionInterface {
if ( ! $this->is_class_allowed( $class_name ) ) {
throw new ContainerException( "You cannot add '$class_name', only classes in the {$this->woocommerce_namespace} namespace are allowed." );
}
$concrete_class = $this->get_class_from_concrete( $concrete );
if ( isset( $concrete_class ) && ! $this->is_class_allowed( $concrete_class ) ) {
throw new ContainerException( "You cannot add concrete '$concrete_class', only classes in the {$this->woocommerce_namespace} namespace are allowed." );
}
// We want to use a definition class that does not support constructor injection to avoid accidental usage.
if ( ! $concrete instanceof DefinitionInterface ) {
$concrete = new Definition( $class_name, $concrete );
}
return parent::add( $class_name, $concrete, $shared );
}
/**
* Replace an existing registration with a different concrete. See also 'reset_replacement' and 'reset_all_replacements'.
*
* @param string $class_name The class name whose definition will be replaced.
* @param mixed $concrete The new concrete (same as "add").
*
* @return DefinitionInterface The modified definition.
* @throws ContainerException Invalid parameters.
*/
public function replace( string $class_name, $concrete ) : DefinitionInterface {
if ( ! $this->has( $class_name ) ) {
throw new ContainerException( "The container doesn't have '$class_name' registered, please use 'add' instead of 'replace'." );
}
$concrete_class = $this->get_class_from_concrete( $concrete );
if ( isset( $concrete_class ) && ! $this->is_class_allowed( $concrete_class ) && ! $this->is_anonymous_class( $concrete_class ) ) {
throw new ContainerException( "You cannot use concrete '$concrete_class', only classes in the {$this->woocommerce_namespace} namespace are allowed." );
}
if ( ! array_key_exists( $class_name, $this->original_concretes ) ) {
// LegacyProxy is a special case: we replace it with MockableLegacyProxy at unit testing bootstrap time.
$original_concrete = LegacyProxy::class === $class_name ? MockableLegacyProxy::class : $this->extend( $class_name )->getConcrete( $concrete );
$this->original_concretes[ $class_name ] = $original_concrete;
}
return $this->extend( $class_name )->setConcrete( $concrete );
}
/**
* Reset a replaced registration back to its original concrete.
*
* @param string $class_name The class name whose definition had been replaced.
* @return bool True if the registration has been reset, false if no replacement had been made for the specified class name.
*/
public function reset_replacement( string $class_name ) : bool {
if ( ! array_key_exists( $class_name, $this->original_concretes ) ) {
return false;
}
$this->extend( $class_name )->setConcrete( $this->original_concretes[ $class_name ] );
unset( $this->original_concretes[ $class_name ] );
return true;
}
/**
* Reset all the replaced registrations back to their original concretes.
*/
public function reset_all_replacements() {
foreach ( $this->original_concretes as $class_name => $concrete ) {
$this->extend( $class_name )->setConcrete( $concrete );
}
$this->original_concretes = array();
}
/**
* Reset all the cached resolutions, so any further "get" for shared definitions will generate the instance again.
*/
public function reset_all_resolved() {
foreach ( $this->definitions->getIterator() as $definition ) {
$definition->forgetResolved();
}
}
/**
* Get an instance of a registered class.
*
* @param string $id The class name.
* @param bool $new True to generate a new instance even if the class was registered as shared.
*
* @return object An instance of the requested class.
* @throws ContainerException Attempt to get an instance of a non-namespaced class.
*/
public function get( $id, bool $new = false ) {
if ( false === strpos( $id, '\\' ) ) {
throw new ContainerException( "Attempt to get an instance of the non-namespaced class '$id' from the container, did you forget to add a namespace import?" );
}
return parent::get( $id, $new );
}
/**
* Gets the class from the concrete regardless of type.
*
* @param mixed $concrete The concrete that we want the class from..
*
* @return string|null The class from the concrete if one is available, null otherwise.
*/
protected function get_class_from_concrete( $concrete ) {
if ( is_object( $concrete ) && ! is_callable( $concrete ) ) {
if ( $concrete instanceof DefinitionInterface ) {
return $this->get_class_from_concrete( $concrete->getConcrete() );
}
return get_class( $concrete );
}
if ( is_string( $concrete ) && class_exists( $concrete ) ) {
return $concrete;
}
return null;
}
/**
* Checks to see whether or not a class is allowed to be registered.
*
* @param string $class_name The class to check.
*
* @return bool True if the class is allowed to be registered, false otherwise.
*/
protected function is_class_allowed( string $class_name ): bool {
return StringUtil::starts_with( $class_name, $this->woocommerce_namespace, false ) || in_array( $class_name, $this->registration_whitelist, true );
}
/**
* Check if a class name corresponds to an anonymous class.
*
* @param string $class_name The class name to check.
* @return bool True if the name corresponds to an anonymous class.
*/
protected function is_anonymous_class( string $class_name ): bool {
return StringUtil::starts_with( $class_name, 'class@anonymous' );
}
}
ServiceProviders/AssignDefaultCategoryServiceProvider.php 0000644 00000001320 15154275316 0020043 0 ustar 00 <?php
/**
* AssignDefaultCategoryServiceProvider class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
use Automattic\WooCommerce\Internal\AssignDefaultCategory;
/**
* Service provider for the AssignDefaultCategory class.
*/
class AssignDefaultCategoryServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
AssignDefaultCategory::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( AssignDefaultCategory::class );
}
}
ServiceProviders/BatchProcessingServiceProvider.php 0000644 00000001750 15154275316 0016701 0 ustar 00 <?php
/**
* Service provider for ActionUpdateController class.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
use Automattic\WooCommerce\Internal\BatchProcessing\BatchProcessingController;
/**
* Class BatchProcessingServiceProvider
*
* @package Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders
*/
class BatchProcessingServiceProvider extends AbstractServiceProvider {
/**
* Services provided by this provider.
*
* @var string[]
*/
protected $provides = array(
BatchProcessingController::class,
);
/**
* Use the register method to register items with the container via the
* protected $this->leagueContainer property or the `getLeagueContainer` method
* from the ContainerAwareTrait.
*
* @return void
*/
public function register() {
$this->share( BatchProcessingController::class, new BatchProcessingController() );
}
}
ServiceProviders/BlockTemplatesServiceProvider.php 0000644 00000002363 15154275316 0016535 0 ustar 00 <?php
/**
* BlockTemplatesServiceProvider class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
use Automattic\WooCommerce\Internal\Admin\BlockTemplateRegistry\BlockTemplatesController;
use Automattic\WooCommerce\Internal\Admin\BlockTemplateRegistry\BlockTemplateRegistry;
use Automattic\WooCommerce\Internal\Admin\BlockTemplateRegistry\TemplateTransformer;
/**
* Service provider for the block templates controller classes in the Automattic\WooCommerce\Internal\BlockTemplateRegistry namespace.
*/
class BlockTemplatesServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
BlockTemplateRegistry::class,
BlockTemplatesController::class,
TemplateTransformer::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( TemplateTransformer::class );
$this->share( BlockTemplateRegistry::class );
$this->share( BlockTemplatesController::class )->addArguments(
array(
BlockTemplateRegistry::class,
TemplateTransformer::class,
)
);
}
}
ServiceProviders/COTMigrationServiceProvider.php 0000644 00000002125 15154275316 0016117 0 ustar 00 <?php
/**
* Service provider for COTMigration.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\DataBase\Migrations\CustomOrderTable\CLIRunner;
use Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostsToOrdersMigrationController;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
/**
* Class COTMigrationServiceProvider
*
* @package Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders
*/
class COTMigrationServiceProvider extends AbstractServiceProvider {
/**
* Services provided by this provider.
*
* @var string[]
*/
protected $provides = array(
PostsToOrdersMigrationController::class,
CLIRunner::class,
);
/**
* Use the register method to register items with the container via the
* protected $this->leagueContainer property or the `getLeagueContainer` method
* from the ContainerAwareTrait.
*
* @return void
*/
public function register() {
$this->share( PostsToOrdersMigrationController::class );
$this->share( CLIRunner::class );
}
}
ServiceProviders/DownloadPermissionsAdjusterServiceProvider.php 0000644 00000001364 15154275316 0021331 0 ustar 00 <?php
/**
* DownloadPermissionsAdjusterServiceProvider class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
use Automattic\WooCommerce\Internal\DownloadPermissionsAdjuster;
/**
* Service provider for the DownloadPermissionsAdjuster class.
*/
class DownloadPermissionsAdjusterServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
DownloadPermissionsAdjuster::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( DownloadPermissionsAdjuster::class );
}
}
ServiceProviders/FeaturesServiceProvider.php 0000644 00000001501 15154275316 0015373 0 ustar 00 <?php
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
use Automattic\WooCommerce\Internal\Features\FeaturesController;
use Automattic\WooCommerce\Proxies\LegacyProxy;
use Automattic\WooCommerce\Utilities\PluginUtil;
/**
* Service provider for the features enabling/disabling/compatibility engine.
*/
class FeaturesServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
FeaturesController::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( FeaturesController::class )
->addArguments( array( LegacyProxy::class, PluginUtil::class ) );
}
}
ServiceProviders/MarketingServiceProvider.php 0000644 00000002164 15154275316 0015544 0 ustar 00 <?php
/**
* MarketingServiceProvider class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Admin\Marketing\MarketingChannels;
use Automattic\WooCommerce\Internal\Admin\Marketing\MarketingSpecs;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
// Indicates that the multichannel marketing classes exist.
// This constant will be checked by third-party extensions before utilizing any of the classes defined for this feature.
if ( ! defined( 'WC_MCM_EXISTS' ) ) {
define( 'WC_MCM_EXISTS', true );
}
/**
* Service provider for the non-static utils classes in the Automattic\WooCommerce\src namespace.
*
* @since x.x.x
*/
class MarketingServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
MarketingSpecs::class,
MarketingChannels::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( MarketingSpecs::class );
$this->share( MarketingChannels::class );
}
}
ServiceProviders/MarketplaceServiceProvider.php 0000644 00000001236 15154275316 0016052 0 ustar 00 <?php
/**
* MarketplaceServiceProvider class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
use Automattic\WooCommerce\Internal\Admin\Marketplace;
/**
* Service provider for the Marketplace namespace.
*/
class MarketplaceServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
Marketplace::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( Marketplace::class );
}
}
ServiceProviders/ObjectCacheServiceProvider.php 0000644 00000001154 15154275316 0015753 0 ustar 00 <?php
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Caching\WPCacheEngine;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
/**
* Service provider for the object cache mechanism.
*/
class ObjectCacheServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
WPCacheEngine::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( WPCacheEngine::class );
}
}
ServiceProviders/OptionSanitizerServiceProvider.php 0000644 00000001266 15154275316 0016766 0 ustar 00 <?php
/**
* OptionSanitizerServiceProvider class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
use Automattic\WooCommerce\Internal\Settings\OptionSanitizer;
/**
* Service provider for the OptionSanitizer class.
*/
class OptionSanitizerServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
OptionSanitizer::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( OptionSanitizer::class );
}
}
ServiceProviders/OrderAdminServiceProvider.php 0000644 00000002776 15154275316 0015660 0 ustar 00 <?php
/**
* Service provider for various order admin classes.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\Admin\Orders\COTRedirectionController;
use Automattic\WooCommerce\Internal\Admin\Orders\Edit;
use Automattic\WooCommerce\Internal\Admin\Orders\EditLock;
use Automattic\WooCommerce\Internal\Admin\Orders\ListTable;
use Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes\TaxonomiesMetaBox;
use Automattic\WooCommerce\Internal\Admin\Orders\PageController;
use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
/**
* OrderAdminServiceProvider class.
*/
class OrderAdminServiceProvider extends AbstractServiceProvider {
/**
* List services provided by this class.
*
* @var string[]
*/
protected $provides = array(
COTRedirectionController::class,
PageController::class,
Edit::class,
ListTable::class,
EditLock::class,
TaxonomiesMetaBox::class,
);
/**
* Registers services provided by this class.
*
* @return void
*/
public function register() {
$this->share( COTRedirectionController::class );
$this->share( PageController::class );
$this->share( Edit::class )->addArgument( PageController::class );
$this->share( ListTable::class )->addArgument( PageController::class );
$this->share( EditLock::class );
$this->share( TaxonomiesMetaBox::class )->addArgument( OrdersTableDataStore::class );
}
}
ServiceProviders/OrderMetaBoxServiceProvider.php 0000644 00000001252 15154275316 0016153 0 ustar 00 <?php
/**
* Service provider for order meta boxes.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes\CustomMetaBox;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
/**
* OrderMetaBoxServiceProvider class.
*/
class OrderMetaBoxServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
CustomMetaBox::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( CustomMetaBox::class );
}
}
ServiceProviders/OrdersControllersServiceProvider.php 0000644 00000001571 15154275316 0017311 0 ustar 00 <?php
/**
* OrdersControllersServiceProvider class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
use Automattic\WooCommerce\Internal\Orders\CouponsController;
use Automattic\WooCommerce\Internal\Orders\TaxesController;
/**
* Service provider for the orders controller classes in the Automattic\WooCommerce\Internal\Orders namespace.
*/
class OrdersControllersServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
CouponsController::class,
TaxesController::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( CouponsController::class );
$this->share( TaxesController::class );
}
}
ServiceProviders/OrdersDataStoreServiceProvider.php 0000644 00000006122 15154275316 0016666 0 ustar 00 <?php
/**
* OrdersDataStoreServiceProvider class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\Jetpack\Constants;
use Automattic\WooCommerce\Caches\OrderCache;
use Automattic\WooCommerce\Caches\OrderCacheController;
use Automattic\WooCommerce\Caching\TransientsEngine;
use Automattic\WooCommerce\DataBase\Migrations\CustomOrderTable\CLIRunner;
use Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostsToOrdersMigrationController;
use Automattic\WooCommerce\Internal\BatchProcessing\BatchProcessingController;
use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableRefundDataStore;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
use Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer;
use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;
use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStoreMeta;
use Automattic\WooCommerce\Internal\Features\FeaturesController;
use Automattic\WooCommerce\Internal\Utilities\DatabaseUtil;
use Automattic\WooCommerce\Proxies\LegacyProxy;
use Automattic\WooCommerce\Utilities\PluginUtil;
/**
* Service provider for the classes in the Internal\DataStores\Orders namespace.
*/
class OrdersDataStoreServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
DataSynchronizer::class,
CustomOrdersTableController::class,
OrdersTableDataStore::class,
CLIRunner::class,
OrdersTableDataStoreMeta::class,
OrdersTableRefundDataStore::class,
OrderCache::class,
OrderCacheController::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( OrdersTableDataStoreMeta::class );
$this->share( OrdersTableDataStore::class )->addArguments( array( OrdersTableDataStoreMeta::class, DatabaseUtil::class, LegacyProxy::class ) );
$this->share( DataSynchronizer::class )->addArguments(
array(
OrdersTableDataStore::class,
DatabaseUtil::class,
PostsToOrdersMigrationController::class,
LegacyProxy::class,
OrderCacheController::class,
)
);
$this->share( OrdersTableRefundDataStore::class )->addArguments( array( OrdersTableDataStoreMeta::class, DatabaseUtil::class, LegacyProxy::class ) );
$this->share( CustomOrdersTableController::class )->addArguments(
array(
OrdersTableDataStore::class,
DataSynchronizer::class,
OrdersTableRefundDataStore::class,
BatchProcessingController::class,
FeaturesController::class,
OrderCache::class,
OrderCacheController::class,
PluginUtil::class,
)
);
$this->share( OrderCache::class );
$this->share( OrderCacheController::class )->addArgument( OrderCache::class );
if ( Constants::is_defined( 'WP_CLI' ) && WP_CLI ) {
$this->share( CLIRunner::class )->addArguments( array( CustomOrdersTableController::class, DataSynchronizer::class, PostsToOrdersMigrationController::class ) );
}
}
}
ServiceProviders/ProductAttributesLookupServiceProvider.php 0000644 00000002112 15154275316 0020475 0 ustar 00 <?php
/**
* ProductAttributesLookupServiceProvider class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
use Automattic\WooCommerce\Internal\ProductAttributesLookup\DataRegenerator;
use Automattic\WooCommerce\Internal\ProductAttributesLookup\Filterer;
use Automattic\WooCommerce\Internal\ProductAttributesLookup\LookupDataStore;
/**
* Service provider for the ProductAttributesLookupServiceProvider namespace.
*/
class ProductAttributesLookupServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
DataRegenerator::class,
Filterer::class,
LookupDataStore::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( DataRegenerator::class )->addArgument( LookupDataStore::class );
$this->share( Filterer::class )->addArgument( LookupDataStore::class );
$this->share( LookupDataStore::class );
}
}
ServiceProviders/ProductDownloadsServiceProvider.php 0000644 00000002213 15154275316 0017111 0 ustar 00 <?php
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
use Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Admin\SyncUI;
use Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Admin\UI;
use Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Register;
use Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Synchronize;
/**
* Service provider for the Product Downloads-related services.
*/
class ProductDownloadsServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
Register::class,
Synchronize::class,
SyncUI::class,
UI::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( Register::class );
$this->share( Synchronize::class )->addArgument( Register::class );
$this->share( SyncUI::class )->addArgument( Register::class );
$this->share( UI::class )->addArgument( Register::class );
}
}
ServiceProviders/ProductReviewsServiceProvider.php 0000644 00000001562 15154275316 0016611 0 ustar 00 <?php
/**
* OrdersDataStoreServiceProvider class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\Admin\ProductReviews\Reviews;
use Automattic\WooCommerce\Internal\Admin\ProductReviews\ReviewsCommentsOverrides;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
/**
* Service provider for the classes in the Internal\Admin\ProductReviews namespace.
*/
class ProductReviewsServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
Reviews::class,
ReviewsCommentsOverrides::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( Reviews::class );
$this->share( ReviewsCommentsOverrides::class );
}
}
ServiceProviders/ProxiesServiceProvider.php 0000644 00000001464 15154275316 0015256 0 ustar 00 <?php
/**
* ProxiesServiceProvider class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
use Automattic\WooCommerce\Proxies\LegacyProxy;
use Automattic\WooCommerce\Proxies\ActionsProxy;
/**
* Service provider for the classes in the Automattic\WooCommerce\Proxies namespace.
*/
class ProxiesServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
LegacyProxy::class,
ActionsProxy::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( ActionsProxy::class );
$this->share_with_auto_arguments( LegacyProxy::class );
}
}
ServiceProviders/RestockRefundedItemsAdjusterServiceProvider.php 0000644 00000001372 15154275316 0021416 0 ustar 00 <?php
/**
* RestockRefundedItemsAdjusterServiceProvider class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
use Automattic\WooCommerce\Internal\RestockRefundedItemsAdjuster;
/**
* Service provider for the RestockRefundedItemsAdjuster class.
*/
class RestockRefundedItemsAdjusterServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
RestockRefundedItemsAdjuster::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( RestockRefundedItemsAdjuster::class );
}
}
ServiceProviders/UtilsClassesServiceProvider.php 0000644 00000003157 15154275316 0016244 0 ustar 00 <?php
/**
* UtilsClassesServiceProvider class file.
*/
namespace Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders;
use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
use Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer;
use Automattic\WooCommerce\Internal\DependencyManagement\AbstractServiceProvider;
use Automattic\WooCommerce\Internal\Utilities\COTMigrationUtil;
use Automattic\WooCommerce\Internal\Utilities\DatabaseUtil;
use Automattic\WooCommerce\Internal\Utilities\HtmlSanitizer;
use Automattic\WooCommerce\Internal\Utilities\WebhookUtil;
use Automattic\WooCommerce\Proxies\LegacyProxy;
use Automattic\WooCommerce\Utilities\PluginUtil;
use Automattic\WooCommerce\Utilities\OrderUtil;
/**
* Service provider for the non-static utils classes in the Automattic\WooCommerce\src namespace.
*/
class UtilsClassesServiceProvider extends AbstractServiceProvider {
/**
* The classes/interfaces that are serviced by this service provider.
*
* @var array
*/
protected $provides = array(
DatabaseUtil::class,
HtmlSanitizer::class,
OrderUtil::class,
PluginUtil::class,
COTMigrationUtil::class,
WebhookUtil::class,
);
/**
* Register the classes.
*/
public function register() {
$this->share( DatabaseUtil::class );
$this->share( HtmlSanitizer::class );
$this->share( OrderUtil::class );
$this->share( PluginUtil::class )
->addArgument( LegacyProxy::class );
$this->share( COTMigrationUtil::class )
->addArguments( array( CustomOrdersTableController::class, DataSynchronizer::class ) );
$this->share( WebhookUtil::class );
}
}
AdminServiceProvider.php 0000644 00000011775 15155156354 0011366 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Admin;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\BulkEdit\BulkEditInitializer;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\BulkEdit\CouponBulkEdit;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\MetaBox\ChannelVisibilityMetaBox;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\MetaBox\CouponChannelVisibilityMetaBox;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\MetaBox\MetaBoxInitializer;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\MetaBox\MetaBoxInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Redirect;
use Automattic\WooCommerce\GoogleListingsAndAds\Ads\AdsService;
use Automattic\WooCommerce\GoogleListingsAndAds\Assets\AssetsHandlerInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\ConnectionTest;
use Automattic\WooCommerce\GoogleListingsAndAds\Coupon\CouponHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Coupon\CouponMetaHandler;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\AdminConditional;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Conditional;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Service;
use Automattic\WooCommerce\GoogleListingsAndAds\Menu\AttributeMapping;
use Automattic\WooCommerce\GoogleListingsAndAds\Menu\Dashboard;
use Automattic\WooCommerce\GoogleListingsAndAds\Menu\GetStarted;
use Automattic\WooCommerce\GoogleListingsAndAds\Menu\ProductFeed;
use Automattic\WooCommerce\GoogleListingsAndAds\Menu\Reports;
use Automattic\WooCommerce\GoogleListingsAndAds\Menu\Settings;
use Automattic\WooCommerce\GoogleListingsAndAds\Menu\SetupAds;
use Automattic\WooCommerce\GoogleListingsAndAds\Menu\SetupMerchantCenter;
use Automattic\WooCommerce\GoogleListingsAndAds\Menu\Shipping;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantCenterService;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\TargetAudience;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductMetaHandler;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\WP;
use Automattic\WooCommerce\GoogleListingsAndAds\View\PHPViewFactory;
/**
* Class AdminServiceProvider
* Provides services which are only required for the WP admin dashboard.
*
* Note: These services will not be available in a REST API request.
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement
*/
class AdminServiceProvider extends AbstractServiceProvider implements Conditional {
use AdminConditional;
/**
* @var array
*/
protected $provides = [
Admin::class => true,
AttributeMapping::class => true,
BulkEditInitializer::class => true,
ConnectionTest::class => true,
CouponBulkEdit::class => true,
Dashboard::class => true,
GetStarted::class => true,
MetaBoxInterface::class => true,
MetaBoxInitializer::class => true,
ProductFeed::class => true,
Redirect::class => true,
Reports::class => true,
Settings::class => true,
SetupAds::class => true,
SetupMerchantCenter::class => true,
Shipping::class => true,
Service::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 {
$this->share_with_tags(
Admin::class,
AssetsHandlerInterface::class,
PHPViewFactory::class,
MerchantCenterService::class,
AdsService::class
);
$this->share_with_tags( PHPViewFactory::class );
$this->share_with_tags( Redirect::class, WP::class );
// Share bulk edit views
$this->share_with_tags( CouponBulkEdit::class, CouponMetaHandler::class, MerchantCenterService::class, TargetAudience::class );
$this->share_with_tags( BulkEditInitializer::class );
// Share admin meta boxes
$this->share_with_tags( ChannelVisibilityMetaBox::class, Admin::class, ProductMetaHandler::class, ProductHelper::class, MerchantCenterService::class );
$this->share_with_tags( CouponChannelVisibilityMetaBox::class, Admin::class, CouponMetaHandler::class, CouponHelper::class, MerchantCenterService::class, TargetAudience::class );
$this->share_with_tags( MetaBoxInitializer::class, Admin::class, MetaBoxInterface::class );
$this->share_with_tags( ConnectionTest::class );
$this->share_with_tags( AttributeMapping::class );
$this->share_with_tags( Dashboard::class );
$this->share_with_tags( GetStarted::class );
$this->share_with_tags( ProductFeed::class );
$this->share_with_tags( Reports::class );
$this->share_with_tags( Settings::class );
$this->share_with_tags( SetupAds::class );
$this->share_with_tags( SetupMerchantCenter::class );
$this->share_with_tags( Shipping::class );
}
}
CoreServiceProvider.php 0000644 00000047015 15155156354 0011222 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement;
use Automattic\WooCommerce\Admin\Marketing\MarketingChannels;
use Automattic\WooCommerce\GoogleListingsAndAds\ActionScheduler\ActionScheduler;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Admin;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\AttributesTab;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\VariationsAttributes;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\ChannelVisibilityBlock;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\ProductBlocksService;
use Automattic\WooCommerce\GoogleListingsAndAds\Ads\AccountService as AdsAccountService;
use Automattic\WooCommerce\GoogleListingsAndAds\Ads\AdsAwareInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Ads\AdsService;
use Automattic\WooCommerce\GoogleListingsAndAds\Ads\AssetSuggestionsService;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Ads;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\AdsCampaign;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Connection as GoogleConnection;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Merchant;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\MerchantMetrics;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Settings as GoogleSettings;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\AdsAssetGroupAsset;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\RESTControllers;
use Automattic\WooCommerce\GoogleListingsAndAds\API\WP\OAuthService;
use Automattic\WooCommerce\GoogleListingsAndAds\Assets\AssetsHandler;
use Automattic\WooCommerce\GoogleListingsAndAds\Assets\AssetsHandlerInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Coupon\CouponHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Coupon\CouponMetaHandler;
use Automattic\WooCommerce\GoogleListingsAndAds\Coupon\CouponSyncer;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Installer as DBInstaller;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Migration\Migrator;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Query\AttributeMappingRulesQuery;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\TableManager;
use Automattic\WooCommerce\GoogleListingsAndAds\Event\ClearProductStatsCache;
use Automattic\WooCommerce\GoogleListingsAndAds\Google\GlobalSiteTag;
use Automattic\WooCommerce\GoogleListingsAndAds\Google\GoogleHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Google\GoogleHelperAwareInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Google\GoogleProductService;
use Automattic\WooCommerce\GoogleListingsAndAds\Google\GooglePromotionService;
use Automattic\WooCommerce\GoogleListingsAndAds\API\WP\NotificationsService;
use Automattic\WooCommerce\GoogleListingsAndAds\Google\RequestReviewStatuses;
use Automattic\WooCommerce\GoogleListingsAndAds\Google\SiteVerificationMeta;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Service;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\ViewFactory;
use Automattic\WooCommerce\GoogleListingsAndAds\Installer;
use Automattic\WooCommerce\GoogleListingsAndAds\Internal\DeprecatedFilters;
use Automattic\WooCommerce\GoogleListingsAndAds\Internal\InstallTimestamp;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\ProductSyncStats;
use Automattic\WooCommerce\GoogleListingsAndAds\Logging\DebugLogger;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\AccountService;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\AccountService as MerchantAccountService;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\ContactInformation;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantCenterAwareInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantCenterService;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantStatuses;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\PhoneVerification;
use Automattic\WooCommerce\GoogleListingsAndAds\MultichannelMarketing\GLAChannel;
use Automattic\WooCommerce\GoogleListingsAndAds\MultichannelMarketing\MarketingChannelRegistrar;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\PolicyComplianceCheck;
use Automattic\WooCommerce\GoogleListingsAndAds\Notes\CompleteSetup as CompleteSetupNote;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\TargetAudience;
use Automattic\WooCommerce\GoogleListingsAndAds\Notes\ContactInformation as ContactInformationNote;
use Automattic\WooCommerce\GoogleListingsAndAds\Notes\NoteInitializer;
use Automattic\WooCommerce\GoogleListingsAndAds\Notes\ReconnectWordPress as ReconnectWordPressNote;
use Automattic\WooCommerce\GoogleListingsAndAds\Notes\ReviewAfterClicks as ReviewAfterClicksNote;
use Automattic\WooCommerce\GoogleListingsAndAds\Notes\ReviewAfterConversions as ReviewAfterConversionsNote;
use Automattic\WooCommerce\GoogleListingsAndAds\Notes\SetupCampaign as SetupCampaignNote;
use Automattic\WooCommerce\GoogleListingsAndAds\Notes\SetupCampaignTwoWeeks as SetupCampaign2Note;
use Automattic\WooCommerce\GoogleListingsAndAds\Notes\SetupCouponSharing as SetupCouponSharingNote;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\AdsAccountState;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\AdsSetupCompleted;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\MerchantAccountState;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\MerchantSetupCompleted;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\Options;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\OptionsAwareInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\OptionsInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\Transients;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\TransientsInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\AttributeMapping\AttributeMappingHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes\AttributeManager;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\BatchProductHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductFactory;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductFilter;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductMetaHandler;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductRepository;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductSyncer;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\GoogleGtagJs;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\Tracks as TracksProxy;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\WC;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\WP;
use Automattic\WooCommerce\GoogleListingsAndAds\Shipping\LocationRatesProcessor;
use Automattic\WooCommerce\GoogleListingsAndAds\Shipping\ShippingSuggestionService;
use Automattic\WooCommerce\GoogleListingsAndAds\Shipping\ZoneMethodsParser;
use Automattic\WooCommerce\GoogleListingsAndAds\Shipping\ShippingZone;
use Automattic\WooCommerce\GoogleListingsAndAds\Shipping\ZoneLocationsParser;
use Automattic\WooCommerce\GoogleListingsAndAds\TaskList\CompleteSetupTask;
use Automattic\WooCommerce\GoogleListingsAndAds\Tracking\Events\ActivatedEvents;
use Automattic\WooCommerce\GoogleListingsAndAds\Tracking\Events\GenericEvents;
use Automattic\WooCommerce\GoogleListingsAndAds\Tracking\Events\SiteClaimEvents;
use Automattic\WooCommerce\GoogleListingsAndAds\Tracking\Events\SiteVerificationEvents;
use Automattic\WooCommerce\GoogleListingsAndAds\Tracking\EventTracking;
use Automattic\WooCommerce\GoogleListingsAndAds\Tracking\TrackerSnapshot;
use Automattic\WooCommerce\GoogleListingsAndAds\Tracking\Tracks;
use Automattic\WooCommerce\GoogleListingsAndAds\Tracking\TracksAwareInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Tracking\TracksInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Utility\AddressUtility;
use Automattic\WooCommerce\GoogleListingsAndAds\Utility\DateTimeUtility;
use Automattic\WooCommerce\GoogleListingsAndAds\Utility\ImageUtility;
use Automattic\WooCommerce\GoogleListingsAndAds\Utility\ISOUtility;
use Automattic\WooCommerce\GoogleListingsAndAds\Utility\WPCLIMigrationGTIN;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\ISO3166\ISO3166DataProvider;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use wpdb;
/**
* Class CoreServiceProvider
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement
*/
class CoreServiceProvider extends AbstractServiceProvider {
/**
* @var array
*/
protected $provides = [
Installer::class => true,
AddressUtility::class => true,
AssetsHandlerInterface::class => true,
ContactInformationNote::class => true,
CompleteSetupTask::class => true,
CompleteSetupNote::class => true,
CouponHelper::class => true,
CouponMetaHandler::class => true,
CouponSyncer::class => true,
DateTimeUtility::class => true,
EventTracking::class => true,
GlobalSiteTag::class => true,
ISOUtility::class => true,
SiteVerificationEvents::class => true,
OptionsInterface::class => true,
TransientsInterface::class => true,
ReconnectWordPressNote::class => true,
ReviewAfterClicksNote::class => true,
RESTControllers::class => true,
Service::class => true,
SetupCampaignNote::class => true,
SetupCampaign2Note::class => true,
SetupCouponSharingNote::class => true,
TableManager::class => true,
TrackerSnapshot::class => true,
Tracks::class => true,
TracksInterface::class => true,
ProductSyncer::class => true,
ProductHelper::class => true,
ProductMetaHandler::class => true,
SiteVerificationMeta::class => true,
BatchProductHelper::class => true,
ProductFilter::class => true,
ProductRepository::class => true,
ViewFactory::class => true,
DebugLogger::class => true,
MerchantStatuses::class => true,
PhoneVerification::class => true,
PolicyComplianceCheck::class => true,
ContactInformation::class => true,
MerchantCenterService::class => true,
NotificationsService::class => true,
TargetAudience::class => true,
MerchantAccountState::class => true,
AdsAccountState::class => true,
DBInstaller::class => true,
AttributeManager::class => true,
ProductFactory::class => true,
AttributesTab::class => true,
VariationsAttributes::class => true,
DeprecatedFilters::class => true,
ZoneLocationsParser::class => true,
ZoneMethodsParser::class => true,
LocationRatesProcessor::class => true,
ShippingZone::class => true,
AdsAccountService::class => true,
MerchantAccountService::class => true,
MarketingChannelRegistrar::class => true,
OAuthService::class => true,
WPCLIMigrationGTIN::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 {
$this->conditionally_share_with_tags( DebugLogger::class );
// Share our interfaces, possibly with concrete objects.
$this->share_concrete( AssetsHandlerInterface::class, AssetsHandler::class );
$this->share_concrete( TransientsInterface::class, Transients::class );
$this->share_concrete(
TracksInterface::class,
$this->share_with_tags( Tracks::class, TracksProxy::class )
);
// Set up Options, and inflect classes that need options.
$this->share_concrete( OptionsInterface::class, Options::class );
$this->getContainer()
->inflector( OptionsAwareInterface::class )
->invokeMethod( 'set_options_object', [ OptionsInterface::class ] );
// Share helper classes, and inflect classes that need it.
$this->share_with_tags( GoogleHelper::class, WC::class );
$this->getContainer()
->inflector( GoogleHelperAwareInterface::class )
->invokeMethod( 'set_google_helper_object', [ GoogleHelper::class ] );
// Set up the TargetAudience service.
$this->share_with_tags( TargetAudience::class, WC::class, OptionsInterface::class, GoogleHelper::class );
// Set up MerchantCenter service, and inflect classes that need it.
$this->share_with_tags( MerchantCenterService::class );
// Set up Notifications service.
$this->share_with_tags( NotificationsService::class, MerchantCenterService::class, AccountService::class );
// Set up OAuthService service.
$this->share_with_tags( OAuthService::class );
$this->getContainer()
->inflector( MerchantCenterAwareInterface::class )
->invokeMethod( 'set_merchant_center_object', [ MerchantCenterService::class ] );
// Set up Ads service, and inflect classes that need it.
$this->share_with_tags( AdsAccountState::class );
$this->share_with_tags( AdsService::class, AdsAccountState::class );
$this->getContainer()
->inflector( AdsAwareInterface::class )
->invokeMethod( 'set_ads_object', [ AdsService::class ] );
$this->share_with_tags( AssetSuggestionsService::class, WP::class, WC::class, ImageUtility::class, wpdb::class, AdsAssetGroupAsset::class );
// Set up the installer.
$this->share_with_tags( Installer::class, WP::class );
// Share utility classes
$this->share_with_tags( AddressUtility::class );
$this->share_with_tags( DateTimeUtility::class );
$this->share_with_tags( ImageUtility::class, WP::class );
$this->share_with_tags( ISOUtility::class, ISO3166DataProvider::class );
// Share our regular service classes.
$this->share_with_tags( TrackerSnapshot::class );
$this->share_with_tags( EventTracking::class );
$this->share_with_tags( RESTControllers::class );
$this->share_with_tags( CompleteSetupTask::class );
$this->conditionally_share_with_tags( GlobalSiteTag::class, AssetsHandlerInterface::class, GoogleGtagJs::class, ProductHelper::class, WC::class, WP::class );
$this->share_with_tags( SiteVerificationMeta::class );
$this->conditionally_share_with_tags( MerchantSetupCompleted::class );
$this->conditionally_share_with_tags( AdsSetupCompleted::class );
$this->share_with_tags( AdsAccountService::class, AdsAccountState::class );
$this->share_with_tags( MerchantAccountService::class, MerchantAccountState::class );
// Inbox Notes
$this->share_with_tags( ContactInformationNote::class );
$this->share_with_tags( CompleteSetupNote::class );
$this->share_with_tags( ReconnectWordPressNote::class, GoogleConnection::class );
$this->share_with_tags( ReviewAfterClicksNote::class, MerchantMetrics::class, WP::class );
$this->share_with_tags( ReviewAfterConversionsNote::class, MerchantMetrics::class, WP::class );
$this->share_with_tags( SetupCampaignNote::class, MerchantCenterService::class );
$this->share_with_tags( SetupCampaign2Note::class, MerchantCenterService::class );
$this->share_with_tags( SetupCouponSharingNote::class, MerchantStatuses::class );
$this->share_with_tags( NoteInitializer::class, ActionScheduler::class );
// Product attributes
$this->conditionally_share_with_tags( AttributeManager::class, AttributeMappingRulesQuery::class, WC::class );
$this->conditionally_share_with_tags( AttributesTab::class, Admin::class, AttributeManager::class, MerchantCenterService::class );
$this->conditionally_share_with_tags( VariationsAttributes::class, Admin::class, AttributeManager::class, MerchantCenterService::class );
// Product Block Editor
$this->share_with_tags( ChannelVisibilityBlock::class, ProductHelper::class, MerchantCenterService::class );
$this->conditionally_share_with_tags( ProductBlocksService::class, AssetsHandlerInterface::class, ChannelVisibilityBlock::class, AttributeManager::class, MerchantCenterService::class );
$this->share_with_tags( MerchantAccountState::class );
$this->share_with_tags( MerchantStatuses::class );
$this->share_with_tags( PhoneVerification::class, Merchant::class, WP::class, ISOUtility::class );
$this->share_with_tags( PolicyComplianceCheck::class, WC::class, GoogleHelper::class, TargetAudience::class );
$this->share_with_tags( ContactInformation::class, Merchant::class, GoogleSettings::class );
$this->share_with_tags( ProductMetaHandler::class );
$this->share( ProductHelper::class, ProductMetaHandler::class, WC::class, TargetAudience::class );
$this->share_with_tags( ProductFilter::class, ProductHelper::class );
$this->share_with_tags( ProductRepository::class, ProductMetaHandler::class, ProductFilter::class );
$this->share_with_tags( ProductFactory::class, AttributeManager::class, WC::class );
$this->share_with_tags(
BatchProductHelper::class,
ProductMetaHandler::class,
ProductHelper::class,
ValidatorInterface::class,
ProductFactory::class,
TargetAudience::class,
AttributeMappingRulesQuery::class
);
$this->share_with_tags(
ProductSyncer::class,
GoogleProductService::class,
BatchProductHelper::class,
ProductHelper::class,
MerchantCenterService::class,
WC::class,
ProductRepository::class
);
// Coupon management classes
$this->share_with_tags( CouponMetaHandler::class );
$this->share_with_tags(
CouponHelper::class,
CouponMetaHandler::class,
WC::class,
MerchantCenterService::class
);
$this->share_with_tags(
CouponSyncer::class,
GooglePromotionService::class,
CouponHelper::class,
ValidatorInterface::class,
MerchantCenterService::class,
TargetAudience::class,
WC::class
);
// Set up inflector for tracks classes.
$this->getContainer()
->inflector( TracksAwareInterface::class )
->invokeMethod( 'set_tracks', [ TracksInterface::class ] );
// Share other classes.
$this->share_with_tags( ActivatedEvents::class, $_SERVER );
$this->share_with_tags( GenericEvents::class );
$this->share_with_tags( SiteClaimEvents::class );
$this->share_with_tags( SiteVerificationEvents::class );
$this->conditionally_share_with_tags( InstallTimestamp::class );
$this->conditionally_share_with_tags( ClearProductStatsCache::class, MerchantStatuses::class );
$this->share_with_tags( TableManager::class, 'db_table' );
$this->share_with_tags( DBInstaller::class, TableManager::class, Migrator::class );
$this->share_with_tags( DeprecatedFilters::class );
$this->share_with_tags( LocationRatesProcessor::class );
$this->share_with_tags( ZoneLocationsParser::class, GoogleHelper::class );
$this->share_with_tags( ZoneMethodsParser::class, WC::class );
$this->share_with_tags( ShippingZone::class, WC::class, ZoneLocationsParser::class, ZoneMethodsParser::class, LocationRatesProcessor::class );
$this->share_with_tags( ShippingSuggestionService::class, ShippingZone::class, WC::class );
$this->share_with_tags( RequestReviewStatuses::class );
// Share Attribute Mapping related classes
$this->share_with_tags( AttributeMappingHelper::class );
if ( class_exists( MarketingChannels::class ) ) {
$this->share_with_tags( GLAChannel::class, MerchantCenterService::class, AdsCampaign::class, Ads::class, MerchantStatuses::class, ProductSyncStats::class );
$this->share_with_tags( MarketingChannelRegistrar::class, GLAChannel::class, WC::class );
}
// ClI Classes
$this->conditionally_share_with_tags( WPCLIMigrationGTIN::class, ProductRepository::class, AttributeManager::class );
}
}
DBServiceProvider.php 0000644 00000015006 15155156354 0010612 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Migration\Migration20231109T1653383133;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Migration\MigrationInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Migration\Migration20211228T1640692399;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Migration\Migration20220524T1653383133;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Migration\Migration20240813T1653383133;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Migration\MigrationVersion141;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Migration\Migrator;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\ProductFeedQueryHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\ProductMetaQueryHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Query\AttributeMappingRulesQuery;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Query\BudgetRecommendationQuery;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Query\MerchantIssueQuery;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Query\ShippingRateQuery;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Query\ShippingTimeQuery;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Table\AttributeMappingRulesTable;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Table\BudgetRecommendationTable;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Table\MerchantIssueTable;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Table\ShippingRateTable;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Table\ShippingTimeTable;
use Automattic\WooCommerce\GoogleListingsAndAds\Exception\InvalidClass;
use Automattic\WooCommerce\GoogleListingsAndAds\Exception\ValidateInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\OptionsInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductRepository;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\WP;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\DefinitionInterface;
use wpdb;
defined( 'ABSPATH' ) || exit;
/**
* Class DBServiceProvider
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement
*/
class DBServiceProvider extends AbstractServiceProvider {
use ValidateInterface;
/**
* 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 = [
AttributeMappingRulesTable::class => true,
AttributeMappingRulesQuery::class => true,
ShippingRateTable::class => true,
ShippingRateQuery::class => true,
ShippingTimeTable::class => true,
ShippingTimeQuery::class => true,
BudgetRecommendationTable::class => true,
BudgetRecommendationQuery::class => true,
MerchantIssueTable::class => true,
MerchantIssueQuery::class => true,
ProductFeedQueryHelper::class => true,
ProductMetaQueryHelper::class => true,
MigrationInterface::class => true,
Migrator::class => true,
];
/**
* Returns a boolean if checking whether this provider provides a specific
* service or returns an array of provided services if no argument passed.
*
* @param string $service
*
* @return boolean
*/
public function provides( string $service ): bool {
return 'db_table' === $service || 'db_query' === $service || parent::provides( $service );
}
/**
* 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 {
$this->share_table_class( AttributeMappingRulesTable::class );
$this->add_query_class( AttributeMappingRulesQuery::class, AttributeMappingRulesTable::class );
$this->share_table_class( BudgetRecommendationTable::class );
$this->add_query_class( BudgetRecommendationQuery::class, BudgetRecommendationTable::class );
$this->share_table_class( ShippingRateTable::class );
$this->add_query_class( ShippingRateQuery::class, ShippingRateTable::class );
$this->share_table_class( ShippingTimeTable::class );
$this->add_query_class( ShippingTimeQuery::class, ShippingTimeTable::class );
$this->share_table_class( MerchantIssueTable::class );
$this->add_query_class( MerchantIssueQuery::class, MerchantIssueTable::class );
$this->share_with_tags( ProductFeedQueryHelper::class, wpdb::class, ProductRepository::class );
$this->share_with_tags( ProductMetaQueryHelper::class, wpdb::class );
// Share DB migrations
$this->share_migration( MigrationVersion141::class, MerchantIssueTable::class );
$this->share_migration( Migration20211228T1640692399::class, ShippingRateTable::class, OptionsInterface::class );
$this->share_with_tags( Migration20220524T1653383133::class, BudgetRecommendationTable::class );
$this->share_migration( Migration20231109T1653383133::class, BudgetRecommendationTable::class );
$this->share_migration( Migration20240813T1653383133::class, ShippingTimeTable::class );
$this->share_with_tags( Migrator::class, MigrationInterface::class );
}
/**
* Add a query class.
*
* @param string $class_name
* @param mixed ...$arguments
*
* @return DefinitionInterface
*/
protected function add_query_class( string $class_name, ...$arguments ): DefinitionInterface {
return $this->add( $class_name, wpdb::class, ...$arguments )->addTag( 'db_query' );
}
/**
* Share a table class.
*
* Shared classes will always return the same instance of the class when the class is requested
* from the container.
*
* @param string $class_name The class name to add.
* @param mixed ...$arguments Constructor arguments for the class.
*
* @return DefinitionInterface
*/
protected function share_table_class( string $class_name, ...$arguments ): DefinitionInterface {
return parent::share( $class_name, WP::class, wpdb::class, ...$arguments )->addTag( 'db_table' );
}
/**
* Share a migration class.
*
* @param string $class_name The class name to add.
* @param mixed ...$arguments Constructor arguments for the class.
*
* @throws InvalidClass When the given class does not implement the MigrationInterface.
*
* @since 1.4.1
*/
protected function share_migration( string $class_name, ...$arguments ) {
$this->validate_interface( $class_name, MigrationInterface::class );
$this->share_with_tags(
$class_name,
wpdb::class,
...$arguments
);
}
}
GoogleServiceProvider.php 0000644 00000035755 15155156354 0011556 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement;
use Automattic\Jetpack\Connection\Manager;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Ads;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\AdsAssetGroup;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\AdsCampaign;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\AdsCampaignBudget;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\AdsCampaignCriterion;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\AdsCampaignLabel;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\AdsConversionAction;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\AdsReport;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\AdsAssetGroupAsset;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\AdsAsset;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Connection;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Merchant;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\MerchantMetrics;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\MerchantReport;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Middleware;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Settings;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\SiteVerification;
use Automattic\WooCommerce\GoogleListingsAndAds\Exception\AccountReconnect;
use Automattic\WooCommerce\GoogleListingsAndAds\Exception\WPError;
use Automattic\WooCommerce\GoogleListingsAndAds\Exception\WPErrorTrait;
use Automattic\WooCommerce\GoogleListingsAndAds\Google\Ads\GoogleAdsClient;
use Automattic\WooCommerce\GoogleListingsAndAds\Google\GoogleHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Google\GoogleProductService;
use Automattic\WooCommerce\GoogleListingsAndAds\Google\GooglePromotionService;
use Automattic\WooCommerce\GoogleListingsAndAds\Notes\ReconnectWordPress;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\Options;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\OptionsInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\TransientsInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\PluginHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\WP;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\Google\Client;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\Google\Service\ShoppingContent;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\Google\Service\SiteVerification as SiteVerificationService;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\GuzzleHttp\Client as GuzzleClient;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\GuzzleHttp\ClientInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\GuzzleHttp\Exception\RequestException;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\GuzzleHttp\HandlerStack;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\Psr\Http\Message\RequestInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\Psr\Http\Message\ResponseInterface;
use Google\Ads\GoogleAds\Util\V18\GoogleAdsFailures;
use Jetpack_Options;
defined( 'ABSPATH' ) || exit;
/**
* Class GoogleServiceProvider
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement
*/
class GoogleServiceProvider extends AbstractServiceProvider {
use PluginHelper;
use WPErrorTrait;
/**
* 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 = [
Client::class => true,
ShoppingContent::class => true,
GoogleAdsClient::class => true,
GuzzleClient::class => true,
Middleware::class => true,
Merchant::class => true,
MerchantMetrics::class => true,
Ads::class => true,
AdsAssetGroup::class => true,
AdsCampaign::class => true,
AdsCampaignBudget::class => true,
AdsCampaignLabel::class => true,
AdsConversionAction::class => true,
AdsReport::class => true,
AdsAssetGroupAsset::class => true,
AdsAsset::class => true,
'connect_server_root' => true,
Connection::class => true,
GoogleProductService::class => true,
GooglePromotionService::class => true,
SiteVerification::class => true,
Settings::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 {
$this->register_guzzle();
$this->register_ads_client();
$this->register_google_classes();
$this->share( Middleware::class );
$this->add( Connection::class );
$this->add( Settings::class );
$this->share( Ads::class, GoogleAdsClient::class );
$this->share( AdsAssetGroup::class, GoogleAdsClient::class, AdsAssetGroupAsset::class );
$this->share( AdsCampaign::class, GoogleAdsClient::class, AdsCampaignBudget::class, AdsCampaignCriterion::class, GoogleHelper::class, AdsCampaignLabel::class );
$this->share( AdsCampaignBudget::class, GoogleAdsClient::class );
$this->share( AdsAssetGroupAsset::class, GoogleAdsClient::class, AdsAsset::class );
$this->share( AdsAsset::class, GoogleAdsClient::class, WP::class );
$this->share( AdsCampaignCriterion::class );
$this->share( AdsCampaignLabel::class, GoogleAdsClient::class );
$this->share( AdsConversionAction::class, GoogleAdsClient::class );
$this->share( AdsReport::class, GoogleAdsClient::class );
$this->share( Merchant::class, ShoppingContent::class );
$this->share( MerchantMetrics::class, ShoppingContent::class, GoogleAdsClient::class, WP::class, TransientsInterface::class );
$this->share( MerchantReport::class, ShoppingContent::class, ProductHelper::class );
$this->share( SiteVerification::class );
$this->getContainer()->add( 'connect_server_root', $this->get_connect_server_url_root() );
}
/**
* Register guzzle with authorization middleware added.
*/
protected function register_guzzle() {
$callback = function () {
$handler_stack = HandlerStack::create();
$handler_stack->remove( 'http_errors' );
$handler_stack->push( $this->error_handler(), 'http_errors' );
$handler_stack->push( $this->add_auth_header(), 'auth_header' );
$handler_stack->push( $this->add_plugin_version_header(), 'plugin_version_header' );
// Override endpoint URL if we are using http locally.
if ( 0 === strpos( $this->get_connect_server_url_root(), 'http://' ) ) {
$handler_stack->push( $this->override_http_url(), 'override_http_url' );
}
return new GuzzleClient( [ 'handler' => $handler_stack ] );
};
$this->share_concrete( GuzzleClient::class, new Definition( GuzzleClient::class, $callback ) );
$this->share_concrete( ClientInterface::class, new Definition( GuzzleClient::class, $callback ) );
}
/**
* Register ads client.
*/
protected function register_ads_client() {
$callback = function () {
return new GoogleAdsClient( $this->get_connect_server_endpoint() );
};
$this->share_concrete(
GoogleAdsClient::class,
new Definition( GoogleAdsClient::class, $callback )
)->addMethodCall( 'setHttpClient', [ ClientInterface::class ] );
}
/**
* Register the various Google classes we use.
*/
protected function register_google_classes() {
$this->add( Client::class )->addMethodCall( 'setHttpClient', [ ClientInterface::class ] );
$this->add(
ShoppingContent::class,
Client::class,
$this->get_connect_server_url_root( 'google/google-mc' )
);
$this->add(
SiteVerificationService::class,
Client::class,
$this->get_connect_server_url_root( 'google/google-sv' )
);
$this->share( GoogleProductService::class, ShoppingContent::class );
$this->share( GooglePromotionService::class, ShoppingContent::class );
}
/**
* Custom error handler to detect and handle a disconnected status.
*
* @return callable
*/
protected function error_handler(): callable {
return function ( callable $handler ) {
return function ( RequestInterface $request, array $options ) use ( $handler ) {
return $handler( $request, $options )->then(
function ( ResponseInterface $response ) use ( $request ) {
$code = $response->getStatusCode();
$path = $request->getUri()->getPath();
// Partial Failures come back with a status code of 200, so it's necessary to call GoogleAdsFailures:init every time.
if ( strpos( $path, 'google-ads' ) !== false ) {
GoogleAdsFailures::init();
}
if ( $code < 400 ) {
return $response;
}
if ( 401 === $code ) {
$this->handle_unauthorized_error( $request, $response );
}
throw RequestException::create( $request, $response );
}
);
};
};
}
/**
* Handle a 401 unauthorized error.
* Marks either the Jetpack or the Google account as disconnected.
*
* @since 1.12.5
*
* @param RequestInterface $request
* @param ResponseInterface $response
*
* @throws AccountReconnect When an account must be reconnected.
*/
protected function handle_unauthorized_error( RequestInterface $request, ResponseInterface $response ) {
$auth_header = $response->getHeader( 'www-authenticate' )[0] ?? '';
if ( 0 === strpos( $auth_header, 'X_JP_Auth' ) ) {
// Log original exception before throwing reconnect exception.
do_action( 'woocommerce_gla_exception', RequestException::create( $request, $response ), __METHOD__ );
$this->set_jetpack_connected( false );
throw AccountReconnect::jetpack_disconnected();
}
// Exclude listing customers as it will handle it's own unauthorized errors.
$path = $request->getUri()->getPath();
if ( false === strpos( $path, 'customers:listAccessibleCustomers' ) ) {
// Log original exception before throwing reconnect exception.
do_action( 'woocommerce_gla_exception', RequestException::create( $request, $response ), __METHOD__ );
$this->set_google_disconnected();
throw AccountReconnect::google_disconnected();
}
}
/**
* @return callable
*/
protected function add_auth_header(): callable {
return function ( callable $handler ) {
return function ( RequestInterface $request, array $options ) use ( $handler ) {
try {
$request = $request->withHeader( 'Authorization', $this->generate_auth_header() );
// Getting a valid authorization token, indicates Jetpack is connected.
$this->set_jetpack_connected( true );
} catch ( WPError $error ) {
do_action( 'woocommerce_gla_guzzle_client_exception', $error, __METHOD__ . ' in add_auth_header()' );
$this->set_jetpack_connected( false );
throw AccountReconnect::jetpack_disconnected();
}
return $handler( $request, $options );
};
};
}
/**
* Add client name and version headers to request
*
* @since 2.4.11
*
* @return callable
*/
protected function add_plugin_version_header(): callable {
return function ( callable $handler ) {
return function ( RequestInterface $request, array $options ) use ( $handler ) {
$request = $request->withHeader( 'x-client-name', $this->get_client_name() )
->withHeader( 'x-client-version', $this->get_version() );
return $handler( $request, $options );
};
};
}
/**
* @return callable
*/
protected function override_http_url(): callable {
return function ( callable $handler ) {
return function ( RequestInterface $request, array $options ) use ( $handler ) {
$request = $request->withUri( $request->getUri()->withScheme( 'http' ) );
return $handler( $request, $options );
};
};
}
/**
* Generate the authorization header for the GuzzleClient and GoogleAdsClient.
*
* @return string Empty if no access token is available.
*
* @throws WPError If the authorization token isn't found.
*/
protected function generate_auth_header(): string {
/** @var Manager $manager */
$manager = $this->getContainer()->get( Manager::class );
$token = $manager->get_tokens()->get_access_token( false, false, false );
$this->check_for_wp_error( $token );
[ $key, $secret ] = explode( '.', $token->secret );
$key = sprintf(
'%s:%d:%d',
$key,
defined( 'JETPACK__API_VERSION' ) ? JETPACK__API_VERSION : 1,
$token->external_user_id
);
$timestamp = time() + (int) Jetpack_Options::get_option( 'time_diff' );
$nonce = wp_generate_password( 10, false );
$request = join( "\n", [ $key, $timestamp, $nonce, '' ] );
$signature = base64_encode( hash_hmac( 'sha1', $request, $secret, true ) );
$auth = [
'token' => $key,
'timestamp' => $timestamp,
'nonce' => $nonce,
'signature' => $signature,
];
$pieces = [ 'X_JP_Auth' ];
foreach ( $auth as $key => $value ) {
$pieces[] = sprintf( '%s="%s"', $key, $value );
}
return join( ' ', $pieces );
}
/**
* Get the root Url for the connect server.
*
* @param string $path (Optional) A path relative to the root to include.
*
* @return string
*/
protected function get_connect_server_url_root( string $path = '' ): string {
$url = trailingslashit( $this->get_connect_server_url() );
$path = trim( $path, '/' );
return "{$url}{$path}";
}
/**
* Get the connect server endpoint in the format `domain:port/path`
*
* @return string
*/
protected function get_connect_server_endpoint(): string {
$parts = wp_parse_url( $this->get_connect_server_url_root( 'google/google-ads' ) );
$port = empty( $parts['port'] ) ? 443 : $parts['port'];
return sprintf( '%s:%d%s', $parts['host'], $port, $parts['path'] );
}
/**
* Set the Google account connection as disconnected.
*/
protected function set_google_disconnected() {
/** @var Options $options */
$options = $this->getContainer()->get( OptionsInterface::class );
$options->update( OptionsInterface::GOOGLE_CONNECTED, false );
}
/**
* Set the Jetpack account connection.
*
* @since 1.12.5
*
* @param bool $connected Is connected or disconnected?
*/
protected function set_jetpack_connected( bool $connected ) {
/** @var Options $options */
$options = $this->getContainer()->get( OptionsInterface::class );
// Save previous connected status before updating.
$previous_connected = boolval( $options->get( OptionsInterface::JETPACK_CONNECTED ) );
$options->update( OptionsInterface::JETPACK_CONNECTED, $connected );
if ( $previous_connected !== $connected ) {
$this->jetpack_connected_change( $connected );
}
}
/**
* Handle the reconnect notification when the Jetpack connection status changes.
*
* @since 1.12.5
*
* @param boolean $connected
*/
protected function jetpack_connected_change( bool $connected ) {
/** @var ReconnectWordPress $note */
$note = $this->getContainer()->get( ReconnectWordPress::class );
if ( $connected ) {
$note->delete();
} else {
$note->get_entry()->save();
}
}
}
IntegrationServiceProvider.php 0000644 00000004437 15155156354 0012616 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Query\ShippingTimeQuery;
use Automattic\WooCommerce\GoogleListingsAndAds\Exception\ValidateInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Service;
use Automattic\WooCommerce\GoogleListingsAndAds\Integration\IntegrationInitializer;
use Automattic\WooCommerce\GoogleListingsAndAds\Integration\IntegrationInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Integration\WooCommerceBrands;
use Automattic\WooCommerce\GoogleListingsAndAds\Integration\WooCommercePreOrders;
use Automattic\WooCommerce\GoogleListingsAndAds\Integration\WooCommerceProductBundles;
use Automattic\WooCommerce\GoogleListingsAndAds\Integration\WPCOMProxy;
use Automattic\WooCommerce\GoogleListingsAndAds\Integration\YoastWooCommerceSeo;
use Automattic\WooCommerce\GoogleListingsAndAds\Integration\JetpackWPCOM;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes\AttributeManager;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\WP;
defined( 'ABSPATH' ) || exit;
/**
* Class IntegrationServiceProvider
*
* Provides the integration classes and their related services to the container.
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement
*/
class IntegrationServiceProvider extends AbstractServiceProvider {
use ValidateInterface;
/**
* @var array
*/
protected $provides = [
Service::class => true,
IntegrationInterface::class => true,
IntegrationInitializer::class => true,
];
/**
* @return void
*/
public function register(): void {
$this->share_with_tags( YoastWooCommerceSeo::class );
$this->share_with_tags( WooCommerceBrands::class, WP::class );
$this->share_with_tags( WooCommerceProductBundles::class, AttributeManager::class );
$this->share_with_tags( WooCommercePreOrders::class, ProductHelper::class );
$this->conditionally_share_with_tags( JetpackWPCOM::class );
$this->share_with_tags( WPCOMProxy::class, ShippingTimeQuery::class, AttributeManager::class );
$this->share_with_tags(
IntegrationInitializer::class,
IntegrationInterface::class
);
}
}
JobServiceProvider.php 0000644 00000024055 15155156354 0011043 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement;
use ActionScheduler as ActionSchedulerCore;
use ActionScheduler_AsyncRequest_QueueRunner as QueueRunnerAsyncRequest;
use Automattic\WooCommerce\GoogleListingsAndAds\ActionScheduler\ActionScheduler;
use Automattic\WooCommerce\GoogleListingsAndAds\ActionScheduler\ActionSchedulerInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\ActionScheduler\AsyncActionRunner;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Settings as GoogleSettings;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\MerchantReport;
use Automattic\WooCommerce\GoogleListingsAndAds\Exception\InvalidClass;
use Automattic\WooCommerce\GoogleListingsAndAds\Exception\ValidateInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\API\WP\NotificationsService;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Service;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\AbstractProductSyncerBatchedJob;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\ActionSchedulerJobInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\ActionSchedulerJobMonitor;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\CleanupProductsJob;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\CleanupSyncedProducts;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\DeleteAllProducts;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\DeleteProducts;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\JobInitializer;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\JobInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\JobRepository;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\MigrateGTIN;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\Notifications\CouponNotificationJob;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\Notifications\ProductNotificationJob;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\Notifications\SettingsNotificationJob;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\Notifications\ShippingNotificationJob;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\ProductSyncStats;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\ResubmitExpiringProducts;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\UpdateAllProducts;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\DeleteCoupon;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\UpdateCoupon;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\UpdateProducts;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\Update\CleanupProductTargetCountriesJob;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\Update\PluginUpdate;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\UpdateShippingSettings;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\UpdateSyncableProductsCount;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\UpdateMerchantProductStatuses;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantCenterService;
use Automattic\WooCommerce\GoogleListingsAndAds\Coupon\CouponHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Coupon\CouponSyncer;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\BatchProductHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductRepository;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductSyncer;
use Automattic\WooCommerce\GoogleListingsAndAds\Event\StartProductSync;
use Automattic\WooCommerce\GoogleListingsAndAds\Coupon;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantStatuses;
use Automattic\WooCommerce\GoogleListingsAndAds\Product;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\WC;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\WP;
use Automattic\WooCommerce\GoogleListingsAndAds\Shipping;
use Automattic\WooCommerce\GoogleListingsAndAds\Settings;
defined( 'ABSPATH' ) || exit;
/**
* Class JobServiceProvider
*
* Provides the job classes and their related services to the container.
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement
*/
class JobServiceProvider extends AbstractServiceProvider {
use ValidateInterface;
/**
* @var array
*/
protected $provides = [
JobInterface::class => true,
ActionSchedulerInterface::class => true,
AsyncActionRunner::class => true,
ActionSchedulerJobMonitor::class => true,
Coupon\SyncerHooks::class => true,
PluginUpdate::class => true,
Product\SyncerHooks::class => true,
ProductSyncStats::class => true,
Service::class => true,
JobRepository::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 {
$this->share_with_tags(
AsyncActionRunner::class,
new QueueRunnerAsyncRequest( ActionSchedulerCore::store() ),
ActionSchedulerCore::lock()
);
$this->share_with_tags( ActionScheduler::class, AsyncActionRunner::class );
$this->share_with_tags( ActionSchedulerJobMonitor::class, ActionScheduler::class );
$this->share_with_tags( ProductSyncStats::class, ActionScheduler::class );
// share product syncer jobs
$this->share_product_syncer_job( UpdateAllProducts::class );
$this->share_product_syncer_job( DeleteAllProducts::class );
$this->share_product_syncer_job( UpdateProducts::class );
$this->share_product_syncer_job( DeleteProducts::class );
$this->share_product_syncer_job( ResubmitExpiringProducts::class );
$this->share_product_syncer_job( CleanupProductsJob::class );
$this->share_product_syncer_job( CleanupSyncedProducts::class );
// share coupon syncer jobs.
$this->share_coupon_syncer_job( UpdateCoupon::class );
$this->share_coupon_syncer_job( DeleteCoupon::class );
// share product notifications job
$this->share_action_scheduler_job(
ProductNotificationJob::class,
NotificationsService::class,
ProductHelper::class
);
// share coupon notifications job
$this->share_action_scheduler_job(
CouponNotificationJob::class,
NotificationsService::class,
CouponHelper::class
);
// share GTIN migration job
$this->share_action_scheduler_job(
MigrateGTIN::class,
ProductRepository::class,
Product\Attributes\AttributeManager::class
);
$this->share_with_tags( JobRepository::class );
$this->conditionally_share_with_tags(
JobInitializer::class,
JobRepository::class,
ActionScheduler::class
);
$this->share_with_tags(
Product\SyncerHooks::class,
BatchProductHelper::class,
ProductHelper::class,
JobRepository::class,
MerchantCenterService::class,
NotificationsService::class,
WC::class
);
$this->share_with_tags(
Coupon\SyncerHooks::class,
CouponHelper::class,
JobRepository::class,
MerchantCenterService::class,
NotificationsService::class,
WC::class,
WP::class
);
$this->share_with_tags( StartProductSync::class, JobRepository::class );
$this->share_with_tags( PluginUpdate::class, JobRepository::class );
// Share shipping notifications job
$this->share_action_scheduler_job(
ShippingNotificationJob::class,
NotificationsService::class
);
// Share settings notifications job
$this->share_action_scheduler_job(
SettingsNotificationJob::class,
NotificationsService::class
);
// Share settings syncer hooks
$this->share_with_tags( Settings\SyncerHooks::class, JobRepository::class, NotificationsService::class );
// Share shipping settings syncer job and hooks.
$this->share_action_scheduler_job( UpdateShippingSettings::class, MerchantCenterService::class, GoogleSettings::class );
$this->share_with_tags( Shipping\SyncerHooks::class, MerchantCenterService::class, GoogleSettings::class, JobRepository::class, NotificationsService::class );
// Share plugin update jobs
$this->share_product_syncer_job( CleanupProductTargetCountriesJob::class );
// Share update syncable products count job
$this->share_action_scheduler_job( UpdateSyncableProductsCount::class, ProductRepository::class, ProductHelper::class );
$this->share_action_scheduler_job( UpdateMerchantProductStatuses::class, MerchantCenterService::class, MerchantReport::class, MerchantStatuses::class );
}
/**
* Share an ActionScheduler job class
*
* @param string $class_name The class name to add.
* @param mixed ...$arguments Constructor arguments for the class.
*
* @throws InvalidClass When the given class does not implement the ActionSchedulerJobInterface.
*/
protected function share_action_scheduler_job( string $class_name, ...$arguments ) {
$this->validate_interface( $class_name, ActionSchedulerJobInterface::class );
$this->share_with_tags(
$class_name,
ActionScheduler::class,
ActionSchedulerJobMonitor::class,
...$arguments
);
}
/**
* Share a product syncer job class
*
* @param string $class_name The class name to add.
* @param mixed ...$arguments Constructor arguments for the class.
*/
protected function share_product_syncer_job( string $class_name, ...$arguments ) {
if ( is_subclass_of( $class_name, AbstractProductSyncerBatchedJob::class ) ) {
$this->share_action_scheduler_job(
$class_name,
ProductSyncer::class,
ProductRepository::class,
BatchProductHelper::class,
MerchantCenterService::class,
MerchantStatuses::class,
...$arguments
);
} else {
$this->share_action_scheduler_job(
$class_name,
ProductSyncer::class,
ProductRepository::class,
MerchantCenterService::class,
...$arguments
);
}
}
/**
* Share a coupon syncer job class
*
* @param string $class_name The class name to add.
* @param mixed ...$arguments Constructor arguments for the class.
*/
protected function share_coupon_syncer_job( string $class_name, ...$arguments ) {
$this->share_action_scheduler_job(
$class_name,
CouponHelper::class,
CouponSyncer::class,
WC::class,
MerchantCenterService::class,
...$arguments
);
}
}
ProxyServiceProvider.php 0000644 00000003406 15155156354 0011447 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\GoogleGtagJs;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\RESTServer;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\Tracks;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\WC as WCProxy;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\WP;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\Jetpack;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition;
use wpdb;
use function WC;
/**
* Class ProxyServiceProvider
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement
*/
class ProxyServiceProvider extends AbstractServiceProvider {
/**
* Array of classes provided by this container.
*
* @var array
*/
protected $provides = [
RESTServer::class => true,
Tracks::class => true,
GoogleGtagJs::class => true,
WP::class => true,
Jetpack::class => true,
WCProxy::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 {
$this->share( RESTServer::class );
$this->share( Tracks::class );
$this->share( GoogleGtagJs::class );
$this->share( WP::class );
$this->share( Jetpack::class );
$this->share( WCProxy::class, WC()->countries );
// Use a wrapper function to get the wpdb object.
$this->share_concrete(
wpdb::class,
new Definition(
wpdb::class,
function () {
global $wpdb;
return $wpdb;
}
)
);
}
}
RESTServiceProvider.php 0000644 00000027015 15155156354 0011105 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement;
use Automattic\Jetpack\Connection\Manager;
use Automattic\WooCommerce\GoogleListingsAndAds\Ads\AccountService as AdsAccountService;
use Automattic\WooCommerce\GoogleListingsAndAds\Ads\AssetSuggestionsService as AdsAssetSuggestionsService;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Ads;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\AdsCampaign;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Connection;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Merchant;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\MerchantMetrics;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Middleware;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Settings;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\AdsAssetGroup;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Ads\AccountController as AdsAccountController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Ads\BudgetRecommendationController as AdsBudgetRecommendationController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Ads\CampaignController as AdsCampaignController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Ads\ReportsController as AdsReportsController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Ads\SetupCompleteController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Ads\AssetGroupController as AdsAssetGroupController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Ads\AssetSuggestionsController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\GTINMigrationController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\TourController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\DisconnectController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Google\AccountController as GoogleAccountController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Jetpack\AccountController as JetpackAccountController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\AccountController as MerchantCenterAccountController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\AttributeMappingCategoriesController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\AttributeMapping\AttributeMappingDataController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\AttributeMapping\AttributeMappingRulesController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\AttributeMapping\AttributeMappingSyncerController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\RequestReviewController as MerchantCenterRequestReviewController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\ConnectionController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\ContactInformationController as MerchantCenterContactInformationController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\IssuesController as MerchantCenterIssuesController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\PolicyComplianceCheckController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\PhoneVerificationController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\ProductFeedController as MerchantCenterProductFeedController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\ProductStatisticsController as MerchantCenterProductStatsController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\ProductVisibilityController as MerchantCenterProductVisibilityController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\ReportsController as MerchantCenterReportsController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\SettingsController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\SettingsSyncController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\ShippingRateBatchController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\ShippingRateController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\ShippingRateSuggestionsController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\ShippingTimeBatchController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\ShippingTimeController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\SupportedCountriesController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\SyncableProductsCountController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\TargetAudienceController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\RestAPI\AuthController as RestAPIAuthController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\WP\OAuthService;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\ProductFeedQueryHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Query\AttributeMappingRulesQuery;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Query\BudgetRecommendationQuery;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Query\MerchantIssueQuery;
use Automattic\WooCommerce\GoogleListingsAndAds\DB\Query\ShippingRateQuery;
use Automattic\WooCommerce\GoogleListingsAndAds\Google\RequestReviewStatuses;
use Automattic\WooCommerce\GoogleListingsAndAds\Google\GoogleHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\JobRepository;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\ProductSyncStats;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\AccountService as MerchantAccountService;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantStatuses;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\ContactInformation;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\PhoneVerification;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\PolicyComplianceCheck;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\TransientsInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\AttributeMapping\AttributeMappingHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\RESTServer;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\WC;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\WP;
use Automattic\WooCommerce\GoogleListingsAndAds\Shipping\ShippingSuggestionService;
use Automattic\WooCommerce\GoogleListingsAndAds\Shipping\ShippingZone;
use Automattic\WooCommerce\GoogleListingsAndAds\Utility\AddressUtility;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\DefinitionInterface;
/**
* Class RESTServiceProvider
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement
*/
class RESTServiceProvider extends AbstractServiceProvider {
/**
* Returns a boolean if checking whether this provider provides a specific
* service or returns an array of provided services if no argument passed.
*
* @param string $service
*
* @return boolean
*/
public function provides( string $service ): bool {
return 'rest_controller' === $service;
}
/**
* 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 {
$this->share( SettingsController::class, ShippingZone::class );
$this->share( ConnectionController::class );
$this->share( AdsAccountController::class, AdsAccountService::class );
$this->share( AdsCampaignController::class, AdsCampaign::class );
$this->share( AdsAssetGroupController::class, AdsAssetGroup::class );
$this->share( AdsReportsController::class );
$this->share( GoogleAccountController::class, Connection::class );
$this->share( JetpackAccountController::class, Manager::class, Middleware::class );
$this->share( MerchantCenterProductStatsController::class, MerchantStatuses::class, ProductSyncStats::class );
$this->share( MerchantCenterIssuesController::class, MerchantStatuses::class, ProductHelper::class );
$this->share( MerchantCenterProductFeedController::class, ProductFeedQueryHelper::class );
$this->share( MerchantCenterProductVisibilityController::class, ProductHelper::class, MerchantIssueQuery::class );
$this->share( MerchantCenterContactInformationController::class, ContactInformation::class, Settings::class, AddressUtility::class );
$this->share( AdsBudgetRecommendationController::class, BudgetRecommendationQuery::class, Ads::class );
$this->share( PhoneVerificationController::class, PhoneVerification::class );
$this->share( MerchantCenterAccountController::class, MerchantAccountService::class );
$this->share( MerchantCenterRequestReviewController::class, Middleware::class, Merchant::class, RequestReviewStatuses::class, TransientsInterface::class );
$this->share( MerchantCenterReportsController::class );
$this->share( ShippingRateBatchController::class, ShippingRateQuery::class );
$this->share( ShippingRateController::class, ShippingRateQuery::class );
$this->share( ShippingRateSuggestionsController::class, ShippingSuggestionService::class );
$this->share( ShippingTimeBatchController::class );
$this->share( ShippingTimeController::class );
$this->share( TargetAudienceController::class, WP::class, WC::class, ShippingZone::class, GoogleHelper::class );
$this->share( SupportedCountriesController::class, WC::class, GoogleHelper::class );
$this->share( SettingsSyncController::class, Settings::class );
$this->share( DisconnectController::class );
$this->share( SetupCompleteController::class, MerchantMetrics::class );
$this->share( AssetSuggestionsController::class, AdsAssetSuggestionsService::class );
$this->share( SyncableProductsCountController::class, JobRepository::class );
$this->share( PolicyComplianceCheckController::class, PolicyComplianceCheck::class );
$this->share( AttributeMappingDataController::class, AttributeMappingHelper::class );
$this->share( AttributeMappingRulesController::class, AttributeMappingHelper::class, AttributeMappingRulesQuery::class );
$this->share( AttributeMappingCategoriesController::class );
$this->share( AttributeMappingSyncerController::class, ProductSyncStats::class );
$this->share( TourController::class );
$this->share( RestAPIAuthController::class, OAuthService::class, MerchantAccountService::class );
$this->share( GTINMigrationController::class, JobRepository::class );
}
/**
* Share a class.
*
* Overridden to include the RESTServer proxy with all classes.
*
* @param string $class_name The class name to add.
* @param mixed ...$arguments Constructor arguments for the class.
*
* @return DefinitionInterface
*/
protected function share( string $class_name, ...$arguments ): DefinitionInterface {
return parent::share( $class_name, RESTServer::class, ...$arguments )->addTag( 'rest_controller' );
}
}
ThirdPartyServiceProvider.php 0000644 00000004727 15155156354 0012427 0 ustar 00 <?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' )
);
}
);
}
}