move module.local to module

This commit is contained in:
David Remer 2020-09-01 14:21:58 +03:00
parent c443e4053c
commit f8e82bdfaf
217 changed files with 8 additions and 2 deletions

View file

@ -0,0 +1,33 @@
<?php
/**
* The Null logger is used, when logging is disabled. It does not log at all
* but complies with the LoggerInterface.
*
* @package Inpsyde\Woocommerce\Logging\Logger
*/
declare(strict_types=1);
namespace Inpsyde\Woocommerce\Logging\Logger;
use Psr\Log\LoggerInterface;
use Psr\Log\LoggerTrait;
/**
* Class NullLogger
*/
class NullLogger implements LoggerInterface {
use LoggerTrait;
/**
* Logs a message. Since its a NullLogger, it does not log at all.
*
* @param mixed $level The logging level.
* @param string $message The message.
* @param array $context The context.
*/
public function log( $level, $message, array $context = array() ) {
}
}

View file

@ -0,0 +1,64 @@
<?php
/**
* WooCommerce includes a logger interface, which is fully compatible to PSR-3,
* but for some reason does not extend/implement it.
*
* This is a decorator that makes any WooCommerce Logger PSR-3-compatible
*
* @package Inpsyde\Woocommerce\Logging\Logger
*/
declare(strict_types=1);
namespace Inpsyde\Woocommerce\Logging\Logger;
use Psr\Log\LoggerInterface;
use Psr\Log\LoggerTrait;
/**
* Class WooCommerceLogger
*/
class WooCommerceLogger implements LoggerInterface {
use LoggerTrait;
/**
* The Woocommerce logger.
*
* @var \WC_Logger_Interface
*/
private $wc_logger;
/**
* The source (Plugin), which logs the message.
*
* @var string The source.
*/
private $source;
/**
* WooCommerceLogger constructor.
*
* @param \WC_Logger_Interface $wc_logger The Woocommerce logger.
* @param string $source The source.
*/
public function __construct( \WC_Logger_Interface $wc_logger, string $source ) {
$this->wc_logger = $wc_logger;
$this->source = $source;
}
/**
* Logs a message.
*
* @param mixed $level The logging level.
* @param string $message The message.
* @param array $context The context.
*/
public function log( $level, $message, array $context = array() ) {
if ( ! isset( $context['source'] ) ) {
$context['source'] = $this->source;
}
$this->wc_logger->log( $level, $message, $context );
}
}

View file

@ -0,0 +1,41 @@
<?php
/**
* The logging module.
*
* @package Inpsyde\Woocommerce\Logging
*/
declare(strict_types=1);
namespace Inpsyde\Woocommerce\Logging;
use Dhii\Container\ServiceProvider;
use Dhii\Modular\Module\ModuleInterface;
use Interop\Container\ServiceProviderInterface;
use Psr\Container\ContainerInterface;
/**
* Class WoocommerceLoggingModule
*/
class WoocommerceLoggingModule implements ModuleInterface {
/**
* Setup the module.
*
* @return ServiceProviderInterface
*/
public function setup(): ServiceProviderInterface {
return new ServiceProvider(
require __DIR__ . '/../services.php',
require __DIR__ . '/../extensions.php'
);
}
/**
* Run the module.
*
* @param ContainerInterface $container The container.
*/
public function run( ContainerInterface $container ) {
}
}