Moved hardcoded class alias to a namespaced constant

This commit is contained in:
Alejandro Celaya
2020-03-22 17:42:56 +01:00
parent 9ad0561cac
commit 4539ab2dcf
4 changed files with 12 additions and 6 deletions

View File

@@ -5,13 +5,16 @@ declare(strict_types=1);
use Laminas\ServiceManager\ServiceManager;
use Symfony\Component\Lock;
use const Shlinkio\Shlink\Core\LOCAL_LOCK_FACTORY;
chdir(dirname(__DIR__));
require 'vendor/autoload.php';
// This class alias tricks the ConfigAbstractFactory to return Lock\Factory instances even with a different service name
if (! class_exists('Shlinkio\Shlink\LocalLockFactory')) {
class_alias(Lock\LockFactory::class, 'Shlinkio\Shlink\LocalLockFactory');
// It needs to be placed here as individual config files will not be loaded once config is cached
if (! class_exists(LOCAL_LOCK_FACTORY)) {
class_alias(Lock\LockFactory::class, LOCAL_LOCK_FACTORY);
}
// Build container