2323use Phpfastcache \Exceptions \PhpfastcacheDriverException ;
2424use Phpfastcache \Exceptions \PhpfastcacheDriverNotFoundException ;
2525use Phpfastcache \Exceptions \PhpfastcacheExtensionNotFoundException ;
26+ use Phpfastcache \Exceptions \PhpfastcacheExtensionNotInstalledException ;
2627use Phpfastcache \Exceptions \PhpfastcacheInstanceNotFoundException ;
2728use Phpfastcache \Exceptions \PhpfastcacheInvalidArgumentException ;
2829use Phpfastcache \Exceptions \PhpfastcacheLogicException ;
@@ -59,6 +60,11 @@ class CacheManager
5960 */
6061 protected static array $ driverCustoms = [];
6162
63+ /**
64+ * @var string[]
65+ */
66+ protected static array $ driverExtensions = [];
67+
6268 /**
6369 * @param string $instanceId
6470 * @return ExtendedCacheItemPoolInterface
@@ -91,6 +97,7 @@ public static function getInstances(): array
9197 * @throws PhpfastcacheDriverCheckException
9298 * @throws PhpfastcacheDriverException
9399 * @throws PhpfastcacheDriverNotFoundException
100+ * @throws PhpfastcacheExtensionNotInstalledException
94101 * @throws PhpfastcacheLogicException
95102 */
96103 public static function getInstance (string $ driver , ?ConfigurationOptionInterface $ config = null , ?string $ instanceId = null ): ExtendedCacheItemPoolInterface
@@ -116,22 +123,19 @@ public static function getInstance(string $driver, ?ConfigurationOptionInterface
116123 );
117124 } else {
118125 try {
119- ExtensionManager::loadExtension ($ driver );
126+ self :: $ driverExtensions [ $ driver ] = ExtensionManager::getExtension ($ driver );
120127 return CacheManager::getInstance ($ driver , $ config , $ instanceId );
121128 } catch (PhpfastcacheExtensionNotFoundException ) {
122- // Temporary check until v10
123- $ extensionWarning = '' ;
124- if (in_array ($ driver , ['Arangodb ' , 'Couchdb ' , 'Dynamodb ' , 'Firestore ' , 'Mongodb ' , 'Solr ' ], true )) {
125- $ extensionWarning .= sprintf (
126- 'However, it seems that you are using a driver which is now an extension. Run the following command to solve this issue: %s ' ,
129+ if (in_array ($ driver , ExtensionManager::KNOWN_EXTENSION_NAMES , true )) {
130+ throw new PhpfastcacheExtensionNotInstalledException (sprintf (
131+ 'You requested a driver which is now an extension. Run the following command to solve this issue: %s ' ,
127132 sprintf ('composer install phpfastcache/%s-extension ' , strtolower ($ driver ))
128- );
133+ )) ;
129134 }
130135 throw new PhpfastcacheDriverNotFoundException (sprintf (
131- 'The driver "%s" does not exist or does not implement %s. %s ' ,
136+ 'The driver "%s" does not exist or does not implement %s. ' ,
132137 $ driver ,
133138 ExtendedCacheItemPoolInterface::class,
134- $ extensionWarning ,
135139 ));
136140 }
137141 }
@@ -191,7 +195,9 @@ public static function normalizeDriverName(string $driverName): string
191195 */
192196 public static function getDriverClass (string $ driverName ): string
193197 {
194- if (!empty (self ::$ driverCustoms [$ driverName ])) {
198+ if (!empty (self ::$ driverExtensions [$ driverName ])) {
199+ $ driverClass = self ::$ driverExtensions [$ driverName ];
200+ } elseif (!empty (self ::$ driverCustoms [$ driverName ])) {
195201 $ driverClass = self ::$ driverCustoms [$ driverName ];
196202 } elseif (!empty (self ::$ driverOverrides [$ driverName ])) {
197203 $ driverClass = self ::$ driverOverrides [$ driverName ];
0 commit comments