[Lock] rename and deprecate Factory into LockFactory
This commit is contained in:
parent
f1dff5e269
commit
fc75eb9bef
@ -12,8 +12,8 @@
|
||||
namespace Symfony\Component\Console\Command;
|
||||
|
||||
use Symfony\Component\Console\Exception\LogicException;
|
||||
use Symfony\Component\Lock\Factory;
|
||||
use Symfony\Component\Lock\Lock;
|
||||
use Symfony\Component\Lock\LockFactory;
|
||||
use Symfony\Component\Lock\Store\FlockStore;
|
||||
use Symfony\Component\Lock\Store\SemaphoreStore;
|
||||
|
||||
@ -48,7 +48,7 @@ trait LockableTrait
|
||||
$store = new FlockStore();
|
||||
}
|
||||
|
||||
$this->lock = (new Factory($store))->createLock($name ?: $this->getName());
|
||||
$this->lock = (new LockFactory($store))->createLock($name ?: $this->getName());
|
||||
if (!$this->lock->acquire($blocking)) {
|
||||
$this->lock = null;
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace Symfony\Component\Console\Tests\Command;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Symfony\Component\Lock\Factory;
|
||||
use Symfony\Component\Lock\LockFactory;
|
||||
use Symfony\Component\Lock\Store\FlockStore;
|
||||
use Symfony\Component\Lock\Store\SemaphoreStore;
|
||||
|
||||
@ -47,7 +47,7 @@ class LockableTraitTest extends TestCase
|
||||
$store = new FlockStore();
|
||||
}
|
||||
|
||||
$lock = (new Factory($store))->createLock($command->getName());
|
||||
$lock = (new LockFactory($store))->createLock($command->getName());
|
||||
$lock->acquire();
|
||||
|
||||
$tester = new CommandTester($command);
|
||||
|
@ -19,6 +19,8 @@ use Psr\Log\NullLogger;
|
||||
* Factory provides method to create locks.
|
||||
*
|
||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||
*
|
||||
* @deprecated "Symfony\Component\Lock\Factory" is deprecated since Symfony 4.4 and will be removed in 5.0 use "Symfony\Component\Lock\LockFactory" instead
|
||||
*/
|
||||
class Factory implements LoggerAwareInterface
|
||||
{
|
||||
|
22
src/Symfony/Component/Lock/LockFactory.php
Normal file
22
src/Symfony/Component/Lock/LockFactory.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Lock;
|
||||
|
||||
/**
|
||||
* Factory provides method to create locks.
|
||||
*
|
||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||
* @author Hamza Amrouche <hamza.simperfit@gmail.com>
|
||||
*/
|
||||
class LockFactory extends Factory
|
||||
{
|
||||
}
|
36
src/Symfony/Component/Lock/Tests/LockFactoryTest.php
Normal file
36
src/Symfony/Component/Lock/Tests/LockFactoryTest.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Lock\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Lock\LockFactory;
|
||||
use Symfony\Component\Lock\LockInterface;
|
||||
use Symfony\Component\Lock\StoreInterface;
|
||||
|
||||
/**
|
||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||
*/
|
||||
class LockFactoryTest extends TestCase
|
||||
{
|
||||
public function testCreateLock()
|
||||
{
|
||||
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
|
||||
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
|
||||
$factory = new LockFactory($store);
|
||||
$factory->setLogger($logger);
|
||||
|
||||
$lock = $factory->createLock('foo');
|
||||
|
||||
$this->assertInstanceOf(LockInterface::class, $lock);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user