b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / a / home / dev2.destoffenstraat.com / vendor / magento / framework / Lock /
Filename/home/a/home/dev2.destoffenstraat.com/vendor/magento/framework/Lock/LockBackendFactory.php
Size2.87 kb
Permissionrw-r--r--
Ownerroot : root
Create time21-Aug-2025 12:26
Last modified07-Jan-2021 21:08
Last accessed23-Aug-2025 08:00
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Framework\Lock;

use Magento\Framework\Phrase;
use Magento\Framework\Exception\RuntimeException;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\Lock\Backend\Database as DatabaseLock;
use Magento\Framework\Lock\Backend\Zookeeper as ZookeeperLock;
use Magento\Framework\Lock\Backend\Cache as CacheLock;
use Magento\Framework\Lock\Backend\FileLock;

/**
* The factory to create object that implements LockManagerInterface
*/
class LockBackendFactory
{
/**
* The Object Manager instance
*
* @var ObjectManagerInterface
*/
private $objectManager;

/**
* The Application deployment configuration
*
* @var DeploymentConfig
*/
private $deploymentConfig;

/**
* DB lock provider name
*
* @const string
*/
const LOCK_DB = 'db';

/**
* Zookeeper lock provider name
*
* @const string
*/
const LOCK_ZOOKEEPER = 'zookeeper';

/**
* Cache lock provider name
*
* @const string
*/
const LOCK_CACHE = 'cache';

/**
* File lock provider name
*
* @const string
*/
const LOCK_FILE = 'file';

/**
* The list of lock providers with mapping on classes
*
* @var array
*/
private $lockers = [
self::LOCK_DB => DatabaseLock::class,
self::LOCK_ZOOKEEPER => ZookeeperLock::class,
self::LOCK_CACHE => CacheLock::class,
self::LOCK_FILE => FileLock::class,
];

/**
* @param ObjectManagerInterface $objectManager The Object Manager instance
* @param DeploymentConfig $deploymentConfig The Application deployment configuration
*/
public function __construct(
ObjectManagerInterface $objectManager,
DeploymentConfig $deploymentConfig
) {
$this->objectManager = $objectManager;
$this->deploymentConfig = $deploymentConfig;
}

/**
* Creates an instance of LockManagerInterface using information from deployment config
*
* @return LockManagerInterface
* @throws RuntimeException
*/
public function create(): LockManagerInterface
{
$provider = $this->deploymentConfig->get('lock/provider', self::LOCK_DB);
$config = $this->deploymentConfig->get('lock/config', []);

if (!isset($this->lockers[$provider])) {
throw new RuntimeException(new Phrase('Unknown locks provider: %1', [$provider]));
}

if (self::LOCK_ZOOKEEPER === $provider && !extension_loaded(self::LOCK_ZOOKEEPER)) {
throw new RuntimeException(new Phrase('php extension Zookeeper is not installed.'));
}

return $this->objectManager->create($this->lockers[$provider], $config);
}
}