File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/Container.php.tar
var/www/vhosts/uyarreklam.com.tr/httpdocs/wp-content/plugins/woocommerce/src/Container.php 0000644 00000013326 15154010461 0026235 0 ustar 00 <?php
/**
* Container class file.
*/
namespace Automattic\WooCommerce;
use Automattic\WooCommerce\Internal\DependencyManagement\ExtendedContainer;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\COTMigrationServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\DownloadPermissionsAdjusterServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\AssignDefaultCategoryServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\FeaturesServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\MarketingServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\MarketplaceServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\OrdersControllersServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\OrderAdminServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\OrderMetaBoxServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\ObjectCacheServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\OrdersDataStoreServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\OptionSanitizerServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\ProductAttributesLookupServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\ProductDownloadsServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\ProductReviewsServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\ProxiesServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\RestockRefundedItemsAdjusterServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\UtilsClassesServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\BatchProcessingServiceProvider;
use Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\BlockTemplatesServiceProvider;
/**
* PSR11 compliant dependency injection container for WooCommerce.
*
* Classes in the `src` directory should specify dependencies from that directory via an 'init' method having arguments
* with type hints. If an instance of the container itself is needed, the type hint to use is \Psr\Container\ContainerInterface.
*
* Classes in the `src` directory should interact with anything outside (especially code in the `includes` directory
* and WordPress functions) by using the classes in the `Proxies` directory. The exception is idempotent
* functions (e.g. `wp_parse_url`), those can be used directly.
*
* Classes in the `includes` directory should use the `wc_get_container` function to get the instance of the container when
* they need to get an instance of a class from the `src` directory.
*
* Class registration should be done via service providers that inherit from Automattic\WooCommerce\Internal\DependencyManagement
* and those should go in the `src\Internal\DependencyManagement\ServiceProviders` folder unless there's a good reason
* to put them elsewhere. All the service provider class names must be in the `SERVICE_PROVIDERS` constant.
*/
final class Container {
/**
* The list of service provider classes to register.
*
* @var string[]
*/
private $service_providers = array(
AssignDefaultCategoryServiceProvider::class,
DownloadPermissionsAdjusterServiceProvider::class,
OptionSanitizerServiceProvider::class,
OrdersDataStoreServiceProvider::class,
ProductAttributesLookupServiceProvider::class,
ProductDownloadsServiceProvider::class,
ProductReviewsServiceProvider::class,
ProxiesServiceProvider::class,
RestockRefundedItemsAdjusterServiceProvider::class,
UtilsClassesServiceProvider::class,
COTMigrationServiceProvider::class,
OrdersControllersServiceProvider::class,
ObjectCacheServiceProvider::class,
BatchProcessingServiceProvider::class,
OrderMetaBoxServiceProvider::class,
OrderAdminServiceProvider::class,
FeaturesServiceProvider::class,
MarketingServiceProvider::class,
MarketplaceServiceProvider::class,
BlockTemplatesServiceProvider::class,
);
/**
* The underlying container.
*
* @var \League\Container\Container
*/
private $container;
/**
* Class constructor.
*/
public function __construct() {
$this->container = new ExtendedContainer();
// Add ourselves as the shared instance of ContainerInterface,
// register everything else using service providers.
$this->container->share( __CLASS__, $this );
foreach ( $this->service_providers as $service_provider_class ) {
$this->container->addServiceProvider( $service_provider_class );
}
}
/**
* Finds an entry of the container by its identifier and returns it.
*
* @param string $id Identifier of the entry to look for.
*
* @throws NotFoundExceptionInterface No entry was found for **this** identifier.
* @throws Psr\Container\ContainerExceptionInterface Error while retrieving the entry.
*
* @return mixed Entry.
*/
public function get( string $id ): object {
return $this->container->get( $id );
}
/**
* Returns true if the container can return an entry for the given identifier.
* Returns false otherwise.
*
* `has($id)` returning true does not mean that `get($id)` will not throw an exception.
* It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`.
*
* @param string $id Identifier of the entry to look for.
*
* @return bool
*/
public function has( string $id ): bool {
return $this->container->has( $id );
}
}
httpdocs/wp-content/plugins/woocommerce/lib/packages/League/Container/Container.php 0000644 00000015204 15155140560 0033041 0 ustar 00 var/www/vhosts/uyarreklam.com.tr <?php declare(strict_types=1);
namespace Automattic\WooCommerce\Vendor\League\Container;
use Automattic\WooCommerce\Vendor\League\Container\Definition\{DefinitionAggregate, DefinitionInterface, DefinitionAggregateInterface};
use Automattic\WooCommerce\Vendor\League\Container\Exception\{NotFoundException, ContainerException};
use Automattic\WooCommerce\Vendor\League\Container\Inflector\{InflectorAggregate, InflectorInterface, InflectorAggregateInterface};
use Automattic\WooCommerce\Vendor\League\Container\ServiceProvider\{
ServiceProviderAggregate,
ServiceProviderAggregateInterface,
ServiceProviderInterface
};
use Automattic\WooCommerce\Vendor\Psr\Container\ContainerInterface;
class Container implements ContainerInterface
{
/**
* @var boolean
*/
protected $defaultToShared = false;
/**
* @var DefinitionAggregateInterface
*/
protected $definitions;
/**
* @var ServiceProviderAggregateInterface
*/
protected $providers;
/**
* @var InflectorAggregateInterface
*/
protected $inflectors;
/**
* @var ContainerInterface[]
*/
protected $delegates = [];
/**
* Construct.
*
* @param DefinitionAggregateInterface|null $definitions
* @param ServiceProviderAggregateInterface|null $providers
* @param InflectorAggregateInterface|null $inflectors
*/
public function __construct(
DefinitionAggregateInterface $definitions = null,
ServiceProviderAggregateInterface $providers = null,
InflectorAggregateInterface $inflectors = null
) {
$this->definitions = $definitions ?? new DefinitionAggregate;
$this->providers = $providers ?? new ServiceProviderAggregate;
$this->inflectors = $inflectors ?? new InflectorAggregate;
if ($this->definitions instanceof ContainerAwareInterface) {
$this->definitions->setLeagueContainer($this);
}
if ($this->providers instanceof ContainerAwareInterface) {
$this->providers->setLeagueContainer($this);
}
if ($this->inflectors instanceof ContainerAwareInterface) {
$this->inflectors->setLeagueContainer($this);
}
}
/**
* Add an item to the container.
*
* @param string $id
* @param mixed $concrete
* @param boolean $shared
*
* @return DefinitionInterface
*/
public function add(string $id, $concrete = null, bool $shared = null) : DefinitionInterface
{
$concrete = $concrete ?? $id;
$shared = $shared ?? $this->defaultToShared;
return $this->definitions->add($id, $concrete, $shared);
}
/**
* Proxy to add with shared as true.
*
* @param string $id
* @param mixed $concrete
*
* @return DefinitionInterface
*/
public function share(string $id, $concrete = null) : DefinitionInterface
{
return $this->add($id, $concrete, true);
}
/**
* Whether the container should default to defining shared definitions.
*
* @param boolean $shared
*
* @return self
*/
public function defaultToShared(bool $shared = true) : ContainerInterface
{
$this->defaultToShared = $shared;
return $this;
}
/**
* Get a definition to extend.
*
* @param string $id [description]
*
* @return DefinitionInterface
*/
public function extend(string $id) : DefinitionInterface
{
if ($this->providers->provides($id)) {
$this->providers->register($id);
}
if ($this->definitions->has($id)) {
return $this->definitions->getDefinition($id);
}
throw new NotFoundException(
sprintf('Unable to extend alias (%s) as it is not being managed as a definition', $id)
);
}
/**
* Add a service provider.
*
* @param ServiceProviderInterface|string $provider
*
* @return self
*/
public function addServiceProvider($provider) : self
{
$this->providers->add($provider);
return $this;
}
/**
* {@inheritdoc}
*/
public function get($id, bool $new = false)
{
if ($this->definitions->has($id)) {
$resolved = $this->definitions->resolve($id, $new);
return $this->inflectors->inflect($resolved);
}
if ($this->definitions->hasTag($id)) {
$arrayOf = $this->definitions->resolveTagged($id, $new);
array_walk($arrayOf, function (&$resolved) {
$resolved = $this->inflectors->inflect($resolved);
});
return $arrayOf;
}
if ($this->providers->provides($id)) {
$this->providers->register($id);
if (!$this->definitions->has($id) && !$this->definitions->hasTag($id)) {
throw new ContainerException(sprintf('Service provider lied about providing (%s) service', $id));
}
return $this->get($id, $new);
}
foreach ($this->delegates as $delegate) {
if ($delegate->has($id)) {
$resolved = $delegate->get($id);
return $this->inflectors->inflect($resolved);
}
}
throw new NotFoundException(sprintf('Alias (%s) is not being managed by the container or delegates', $id));
}
/**
* {@inheritdoc}
*/
public function has($id) : bool
{
if ($this->definitions->has($id)) {
return true;
}
if ($this->definitions->hasTag($id)) {
return true;
}
if ($this->providers->provides($id)) {
return true;
}
foreach ($this->delegates as $delegate) {
if ($delegate->has($id)) {
return true;
}
}
return false;
}
/**
* Allows for manipulation of specific types on resolution.
*
* @param string $type
* @param callable|null $callback
*
* @return InflectorInterface
*/
public function inflector(string $type, callable $callback = null) : InflectorInterface
{
return $this->inflectors->add($type, $callback);
}
/**
* Delegate a backup container to be checked for services if it
* cannot be resolved via this container.
*
* @param ContainerInterface $container
*
* @return self
*/
public function delegate(ContainerInterface $container) : self
{
$this->delegates[] = $container;
if ($container instanceof ContainerAwareInterface) {
$container->setLeagueContainer($this);
}
return $this;
}
}
httpdocs/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Registry/Container.php 0000644 00000006025 15155251137 0035344 0 ustar 00 var/www/vhosts/uyarreklam.com.tr <?php
namespace Automattic\WooCommerce\Blocks\Registry;
use Closure;
use Exception;
/**
* A simple Dependency Injection Container
*
* This is used to manage dependencies used throughout the plugin.
*
* @since 2.5.0
*/
class Container {
/**
* A map of Dependency Type objects used to resolve dependencies.
*
* @var AbstractDependencyType[]
*/
private $registry = [];
/**
* Public api for adding a factory to the container.
*
* Factory dependencies will have the instantiation callback invoked
* every time the dependency is requested.
*
* Typical Usage:
*
* ```
* $container->register( MyClass::class, $container->factory( $mycallback ) );
* ```
*
* @param Closure $instantiation_callback This will be invoked when the
* dependency is required. It will
* receive an instance of this
* container so the callback can
* retrieve dependencies from the
* container.
*
* @return FactoryType An instance of the FactoryType dependency.
*/
public function factory( Closure $instantiation_callback ) {
return new FactoryType( $instantiation_callback );
}
/**
* Interface for registering a new dependency with the container.
*
* By default, the $value will be added as a shared dependency. This means
* that it will be a single instance shared among any other classes having
* that dependency.
*
* If you want a new instance every time it's required, then wrap the value
* in a call to the factory method (@see Container::factory for example)
*
* Note: Currently if the provided id already is registered in the container,
* the provided value is ignored.
*
* @param string $id A unique string identifier for the provided value.
* Typically it's the fully qualified name for the
* dependency.
* @param mixed $value The value for the dependency. Typically, this is a
* closure that will create the class instance needed.
*/
public function register( $id, $value ) {
if ( empty( $this->registry[ $id ] ) ) {
if ( ! $value instanceof FactoryType ) {
$value = new SharedType( $value );
}
$this->registry[ $id ] = $value;
}
}
/**
* Interface for retrieving the dependency stored in the container for the
* given identifier.
*
* @param string $id The identifier for the dependency being retrieved.
* @throws Exception If there is no dependency for the given identifier in
* the container.
*
* @return mixed Typically a class instance.
*/
public function get( $id ) {
if ( ! isset( $this->registry[ $id ] ) ) {
// this is a developer facing exception, hence it is not localized.
throw new Exception(
sprintf(
'Cannot construct an instance of %s because it has not been registered.',
$id
)
);
}
return $this->registry[ $id ]->get( $this );
}
}