diff --git a/framework/core/src/Foundation/AbstractValidator.php b/framework/core/src/Foundation/AbstractValidator.php index 3d8b00a7da..b134610845 100644 --- a/framework/core/src/Foundation/AbstractValidator.php +++ b/framework/core/src/Foundation/AbstractValidator.php @@ -19,7 +19,10 @@ abstract class AbstractValidator { use ExtensionIdTrait; - public static string $CORE_VALIDATION_CACHE_KEY = 'core.validation.extension_id_class_names'; + /** + * @var string + */ + public static $CORE_VALIDATION_CACHE_KEY = 'core.validation.extension_id_class_names'; /** * @var array @@ -46,20 +49,14 @@ public function addConfiguration($callable) */ protected $translator; - /** - * @var Cache - */ - protected $cache; - /** * @param Factory $validator * @param TranslatorInterface $translator */ - public function __construct(Factory $validator, TranslatorInterface $translator, Cache $cache) + public function __construct(Factory $validator, TranslatorInterface $translator) { $this->validator = $validator; $this->translator = $translator; - $this->cache = $cache; } /** @@ -97,8 +94,10 @@ protected function getMessages() */ protected function getAttributeNames() { - if ($this->cache->get(self::$CORE_VALIDATION_CACHE_KEY) !== null) { - return $this->cache->get(self::$CORE_VALIDATION_CACHE_KEY); + $cache = resolve(Cache::class); + + if ($cache->get(self::$CORE_VALIDATION_CACHE_KEY) !== null) { + return $cache->get(self::$CORE_VALIDATION_CACHE_KEY); } $extId = $this->getClassExtensionId(); @@ -109,7 +108,7 @@ protected function getAttributeNames() $attributeNames[$attribute] = $this->translator->trans($key); } - $this->cache->forever(self::$CORE_VALIDATION_CACHE_KEY, $attributeNames); + $cache->forever(self::$CORE_VALIDATION_CACHE_KEY, $attributeNames); return $attributeNames; }