mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-28 09:03:07 +03:00
Merge pull request #447 from acelaya/feature/fix-command-error
Feature/fix command error
This commit is contained in:
commit
9de0cf5c03
6 changed files with 98 additions and 3 deletions
9
build.sh
9
build.sh
|
@ -20,8 +20,14 @@ rsync -av * "${builtcontent}" \
|
|||
--exclude=bin/test \
|
||||
--exclude=data/infra \
|
||||
--exclude=data/travis \
|
||||
--exclude=data/cache/* \
|
||||
--exclude=data/log/* \
|
||||
--exclude=data/locks/* \
|
||||
--exclude=data/proxies/* \
|
||||
--exclude=data/migrations_template.txt \
|
||||
--exclude=data/GeoLite2-City.mmdb \
|
||||
--exclude=data/GeoLite2-City.* \
|
||||
--exclude=data/database.sqlite \
|
||||
--exclude=data/shlink-tests.db \
|
||||
--exclude=**/.gitignore \
|
||||
--exclude=CHANGELOG.md \
|
||||
--exclude=composer.lock \
|
||||
|
@ -47,7 +53,6 @@ ${composerBin} install --no-dev --optimize-autoloader --apcu-autoloader --no-pro
|
|||
# Delete development files
|
||||
echo 'Deleting dev files...'
|
||||
rm composer.*
|
||||
rm -f data/database.sqlite
|
||||
|
||||
# Update shlink version in config
|
||||
sed -i "s/%SHLINK_VERSION%/${version}/g" config/autoload/app_options.global.php
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
"lstrojny/functional-php": "^1.8",
|
||||
"mikehaertl/phpwkhtmltopdf": "^2.2",
|
||||
"monolog/monolog": "^1.21",
|
||||
"ocramius/proxy-manager": "^2.0",
|
||||
"ocramius/proxy-manager": "~2.2.2",
|
||||
"phly/phly-event-dispatcher": "^1.0",
|
||||
"predis/predis": "^1.1",
|
||||
"shlinkio/shlink-installer": "^1.2.1",
|
||||
|
|
|
@ -3,6 +3,7 @@ declare(strict_types=1);
|
|||
|
||||
use Shlinkio\Shlink\Common\Cache\RedisFactory;
|
||||
use Shlinkio\Shlink\Common\Lock\RetryLockStoreDelegatorFactory;
|
||||
use Shlinkio\Shlink\Common\Logger\LoggerAwareDelegatorFactory;
|
||||
use Symfony\Component\Lock;
|
||||
use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory;
|
||||
|
||||
|
@ -27,6 +28,9 @@ return [
|
|||
Lock\Store\RedisStore::class => [
|
||||
RetryLockStoreDelegatorFactory::class,
|
||||
],
|
||||
Lock\Factory::class => [
|
||||
LoggerAwareDelegatorFactory::class,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
|
|
20
module/Common/src/Logger/LoggerAwareDelegatorFactory.php
Normal file
20
module/Common/src/Logger/LoggerAwareDelegatorFactory.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Common\Logger;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Log;
|
||||
|
||||
class LoggerAwareDelegatorFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container, $name, callable $callback)
|
||||
{
|
||||
$instance = $callback();
|
||||
if ($instance instanceof Log\LoggerAwareInterface) {
|
||||
$instance->setLogger($container->get(Log\LoggerInterface::class));
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\Common\Logger;
|
||||
|
||||
use PHPUnit\Framework\Assert;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Log;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Shlinkio\Shlink\Common\Logger\LoggerAwareDelegatorFactory;
|
||||
use stdClass;
|
||||
|
||||
class LoggerAwareDelegatorFactoryTest extends TestCase
|
||||
{
|
||||
/** @var LoggerAwareDelegatorFactory */
|
||||
private $delegator;
|
||||
/** @var ObjectProphecy */
|
||||
private $container;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->container = $this->prophesize(ContainerInterface::class);
|
||||
$this->delegator = new LoggerAwareDelegatorFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideInstances
|
||||
*/
|
||||
public function injectsLoggerOnInstanceWhenImplementingLoggerAware($instance, int $expectedCalls): void
|
||||
{
|
||||
$callback = function () use ($instance) {
|
||||
return $instance;
|
||||
};
|
||||
$getLogger = $this->container->get(Log\LoggerInterface::class)->willReturn(new Log\NullLogger());
|
||||
|
||||
$result = ($this->delegator)($this->container->reveal(), '', $callback);
|
||||
|
||||
$this->assertSame($instance, $result);
|
||||
$getLogger->shouldHaveBeenCalledTimes($expectedCalls);
|
||||
}
|
||||
|
||||
public function provideInstances(): iterable
|
||||
{
|
||||
yield 'no logger aware' => [new stdClass(), 0];
|
||||
yield 'logger aware' => [new class implements Log\LoggerAwareInterface {
|
||||
public function setLogger(LoggerInterface $logger): void
|
||||
{
|
||||
Assert::assertInstanceOf(Log\NullLogger::class, $logger);
|
||||
}
|
||||
}, 1];
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ namespace Shlinkio\Shlink\EventDispatcher;
|
|||
|
||||
use Phly\EventDispatcher as Phly;
|
||||
use Psr\EventDispatcher as Psr;
|
||||
use Zend\ServiceManager\Proxy\LazyServiceFactory;
|
||||
|
||||
return [
|
||||
|
||||
|
@ -21,6 +22,16 @@ return [
|
|||
'aliases' => [
|
||||
Psr\EventDispatcherInterface::class => Phly\EventDispatcher::class,
|
||||
],
|
||||
'delegators' => [
|
||||
Psr\ListenerProviderInterface::class => [
|
||||
LazyServiceFactory::class,
|
||||
],
|
||||
],
|
||||
'lazy_services' => [
|
||||
'class_map' => [
|
||||
Psr\ListenerProviderInterface::class => Psr\ListenerProviderInterface::class,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue