HEX
Server: LiteSpeed
System: Linux eko108.isimtescil.net 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: uyarreklamcomtr (11202)
PHP: 7.4.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/Infrastructure.tar
Activateable.php000064400000000733151545571560007662 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure;

/**
 * Something that can be activated.
 *
 * By implementing a class with this interface, the plugin will automatically hook
 * it up to the WordPress activation hook. This means we don't have to worry about
 * manually writing activation code.
 */
interface Activateable {

	/**
	 * Activate the service.
	 *
	 * @return void
	 */
	public function activate(): void;
}
AdminConditional.php000064400000000645151545571560010514 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure;

/**
 * Trait AdminConditional
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure
 */
trait AdminConditional {

	/**
	 * Check whether this object is currently needed.
	 *
	 * @return bool Whether the object is needed.
	 */
	public static function is_needed(): bool {
		return is_admin();
	}
}
Conditional.php000064400000001204151545571560007533 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure;

/**
 * Conditional interface.
 *
 * This interface allows objects to be instantiated only as needed. A static method is used to
 * determine whether an object needs to be instantiated. This prevents needless instantiation of
 * objects that won't be used in the current request.
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure
 */
interface Conditional {

	/**
	 * Check whether this object is currently needed.
	 *
	 * @return bool Whether the object is needed.
	 */
	public static function is_needed(): bool;
}
Deactivateable.php000064400000000747151545571560010200 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure;

/**
 * Something that can be deactivated.
 *
 * By implementing a class with this interface, the plugin will automatically hook
 * it up to the WordPress deactivation hook. This means we don't have to worry about
 * manually writing deactivation code.
 */
interface Deactivateable {

	/**
	 * Deactivate the service.
	 *
	 * @return void
	 */
	public function deactivate(): void;
}
GoogleListingsAndAdsPlugin.php000064400000007021151545571560012456 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure;

use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\JobInitializer;
use Automattic\WooCommerce\GoogleListingsAndAds\Internal\Requirements\PluginValidator;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\OptionsInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\Psr\Container\ContainerInterface;

/**
 * Class GoogleListingsAndAdsPlugin
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure
 */
final class GoogleListingsAndAdsPlugin implements Plugin {

	/**
	 * The hook for registering our plugin's services.
	 *
	 * @var string
	 */
	private const SERVICE_REGISTRATION_HOOK = 'plugins_loaded';

	/**
	 * @var ContainerInterface
	 */
	private $container;

	/**
	 * @var Service[]
	 */
	private $registered_services;

	/**
	 * GoogleListingsAndAdsPlugin constructor.
	 *
	 * @param ContainerInterface $container
	 */
	public function __construct( ContainerInterface $container ) {
		$this->container = $container;
	}

	/**
	 * Activate the plugin.
	 *
	 * @return void
	 */
	public function activate(): void {
		// Delay activation if a required plugin is missing or an incompatible plugin is active.
		if ( ! PluginValidator::validate() ) {
			// Using update_option because we cannot access the option service
			// when the services have not been registered.
			update_option( 'gla_' . OptionsInterface::DELAYED_ACTIVATE, true );
			return;
		}

		$this->maybe_register_services();

		foreach ( $this->registered_services as $service ) {
			if ( $service instanceof Activateable ) {
				$service->activate();
			}
		}
	}

	/**
	 * Deactivate the plugin.
	 *
	 * @return void
	 */
	public function deactivate(): void {
		$this->maybe_register_services();

		foreach ( $this->registered_services as $service ) {
			if ( $service instanceof Deactivateable ) {
				$service->deactivate();
			}
		}
	}

	/**
	 * Register the plugin with the WordPress system.
	 *
	 * @return void
	 */
	public function register(): void {
		add_action(
			self::SERVICE_REGISTRATION_HOOK,
			function () {
				$this->maybe_register_services();
			},
			20
		);

		add_action(
			'init',
			function () {
				// Register the job initializer only if it is available, see JobInitializer::is_needed.
				// Note: ActionScheduler must be loaded after the init hook, so we can't load JobInitializer like a regular Service.
				if ( $this->container->has( JobInitializer::class ) ) {
					$this->container->get( JobInitializer::class )->register();
				}

				// Check if activation is still pending.
				if ( $this->container->get( OptionsInterface::class )->get( OptionsInterface::DELAYED_ACTIVATE ) ) {
					$this->activate();
					// Remove the DELAYED_ACTIVATE flag.
					$this->container->get( OptionsInterface::class )->delete( OptionsInterface::DELAYED_ACTIVATE );
				}
			}
		);
	}

	/**
	 * Register our services if dependency validation passes.
	 */
	protected function maybe_register_services(): void {
		// Don't register anything if a required plugin is missing or an incompatible plugin is active.
		if ( ! PluginValidator::validate() ) {
			$this->registered_services = [];
			return;
		}

		static $registered = false;
		if ( $registered ) {
			return;
		}

		/** @var Service[] $services */
		$services = $this->container->get( Service::class );
		foreach ( $services as $service ) {
			if ( $service instanceof Registerable ) {
				$service->register();
			}
			$this->registered_services[ get_class( $service ) ] = $service;
		}

		$registered = true;
	}
}
Plugin.php000064400000000426151545571560006533 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure;

/**
 * Interface Plugin
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure
 */
interface Plugin extends Activateable, Deactivateable, Registerable {}
Registerable.php000064400000000561151545571560007705 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure;

/**
 * Registerable interface.
 *
 * Used to designate an object that can be registered.
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure
 */
interface Registerable {

	/**
	 * Register a service.
	 */
	public function register(): void;
}
Renderable.php000064400000001175151545571560007342 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure;

defined( 'ABSPATH' ) || exit;

/**
 * Interface Renderable
 *
 * Used to designate an object that can be rendered (e.g. views, blocks, shortcodes, etc.).
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure
 */
interface Renderable {

	/**
	 * Render the renderable.
	 *
	 * @param array $context Optional. Contextual information to use while
	 *                       rendering. Defaults to an empty array.
	 *
	 * @return string Rendered result.
	 */
	public function render( array $context = [] ): string;
}
Service.php000064400000000577151545571560006704 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure;

/**
 * Service interface.
 *
 * A services is one piece of functionality within the plugin as a whole. It aims to encapsulate
 * a particular functionality within a single class.
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure
 */
interface Service {}
View.php000064400000002766151545571560006220 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure;

use Automattic\WooCommerce\GoogleListingsAndAds\View\ViewException;

defined( 'ABSPATH' ) || exit;

interface View extends Renderable {
	/**
	 * Render the current view with a given context.
	 *
	 * @param array $context Context in which to render.
	 *
	 * @return string Rendered HTML.
	 *
	 * @throws ViewException If the view could not be loaded.
	 */
	public function render( array $context = [] ): string;

	/**
	 * Render a partial view.
	 *
	 * This can be used from within a currently rendered view, to include
	 * nested partials.
	 *
	 * The passed-in context is optional, and will fall back to the parent's
	 * context if omitted.
	 *
	 * @param string     $path    Path of the partial to render.
	 * @param array|null $context Context in which to render the partial.
	 *
	 * @return string Rendered HTML.
	 *
	 * @throws ViewException If the view could not be loaded or provided path was not valid.
	 */
	public function render_partial( string $path, ?array $context = null ): string;

	/**
	 * Return the raw value of a context property.
	 *
	 * By default, properties are automatically escaped when accessing them
	 * within the view. This method allows direct access to the raw value
	 * instead to bypass this automatic escaping.
	 *
	 * @param string $property Property for which to return the raw value.
	 *
	 * @return mixed Raw context property value.
	 */
	public function raw( string $property );
}
ViewFactory.php000064400000000721151545571560007535 0ustar00<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure;

defined( 'ABSPATH' ) || exit;

/**
 * Interface ViewFactory
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure
 */
interface ViewFactory {

	/**
	 * Create a new view object.
	 *
	 * @param string $path Path to the view file to render.
	 *
	 * @return View Instantiated view object.
	 */
	public function create( string $path ): View;
}