feature #26923 [FrameworkBundle] Allow user to specify folder for flock (MaksSlesarenko)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[FrameworkBundle] Allow user to specify folder for flock

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| License       | MIT
| Doc PR        |

In case multiple applications running on same server allow user to specify folder for flock
example:
```

framework:
   lock:` 'flock://var/flock' # var/flock will be provided as path to flock constructor
   lock: 'flock:///var/flock' # /var/flock will be provided as path to flock constructor
   lock: flock # works as usual, null is provided to constructor and system temp folder is used

```

Commits
-------

244d762400 added ability to specify folder for flock
This commit is contained in:
Fabien Potencier 2018-09-04 12:23:36 +02:00
commit 9ad492f312

View File

@ -64,6 +64,7 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Lock\Factory;
use Symfony\Component\Lock\Lock;
use Symfony\Component\Lock\LockInterface;
use Symfony\Component\Lock\Store\FlockStore;
use Symfony\Component\Lock\Store\StoreFactory;
use Symfony\Component\Lock\StoreInterface;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
@ -1405,6 +1406,14 @@ class FrameworkExtension extends Extension
case 'flock' === $storeDsn:
$storeDefinition = new Reference('lock.store.flock');
break;
case 0 === strpos($storeDsn, 'flock://'):
$flockPath = substr($storeDsn, 8);
$storeDefinitionId = '.lock.flock.store.'.$container->hash($storeDsn);
$container->register($storeDefinitionId, FlockStore::class)->addArgument($flockPath);
$storeDefinition = new Reference($storeDefinitionId);
break;
case 'semaphore' === $storeDsn:
$storeDefinition = new Reference('lock.store.semaphore');
break;