diff --git a/composer-require-checker.json b/composer-require-checker.json index cfb90ff2..1674ce8b 100644 --- a/composer-require-checker.json +++ b/composer-require-checker.json @@ -4,6 +4,6 @@ "static", "self", "parent", "array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "mixed", "Composer\\Autoload\\ClassLoader", "Doctrine\\Common\\Cache\\FilesystemCache", "Doctrine\\Common\\Cache\\PhpFileCache", - "BEAR\\Resource\\ReverseLinkInterface" + "BEAR\\Resource\\ReverseLinkInterface", "Doctrine\\Common\\Cache\\ArrayCache" ] } diff --git a/src-deprecated/AppInjector.php b/src-deprecated/AppInjector.php index 67c3e79b..f37bd420 100644 --- a/src-deprecated/AppInjector.php +++ b/src-deprecated/AppInjector.php @@ -6,6 +6,7 @@ use BEAR\AppMeta\AbstractAppMeta; use BEAR\AppMeta\Meta; +use BEAR\Package\Module\CacheModule; use Doctrine\Common\Cache\FilesystemCache; use Ray\Compiler\ScriptInjector; use Ray\Di\AbstractModule; @@ -13,6 +14,7 @@ use Ray\Di\Injector; use Ray\Di\InjectorInterface; use Ray\Di\Name; +use RuntimeException; /** * @deprecated @@ -58,6 +60,7 @@ final class AppInjector implements InjectorInterface public function __construct(string $name, string $context, AbstractAppMeta $appMeta = null, string $cacheNamespace = null) { + $this->checkVersion(); $this->context = $context; $this->appMeta = $appMeta instanceof AbstractAppMeta ? $appMeta : new Meta($name, $context); $this->cacheNamespace = (string) $cacheNamespace; @@ -133,6 +136,7 @@ private function getModule() : AbstractModule return $this->module; } $module = (new Module)($this->appMeta, $this->context); + $module->install(new CacheModule()); /* @var AbstractModule $module */ $container = $module->getContainer(); (new Bind($container, InjectorInterface::class))->toInstance($this->injector); @@ -141,4 +145,11 @@ private function getModule() : AbstractModule return $module; } + + private function checkVersion(): void + { + if (! class_exists('Doctrine\Common\Cache\FilesystemCache')) { + throw new RuntimeException('Doctrine cache ^1.0 is required for AppInjector. Please install doctrine/cache ^1.0'); + } + } } diff --git a/src-deprecated/Module/CacheModule.php b/src-deprecated/Module/CacheModule.php new file mode 100644 index 00000000..5769113e --- /dev/null +++ b/src-deprecated/Module/CacheModule.php @@ -0,0 +1,26 @@ +bind(Cache::class)->to(ArrayCache::class); + } + } +}