Skip to content

Commit

Permalink
chore
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Nov 20, 2024
1 parent c725a8f commit 5bde54c
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions framework/core/src/Foundation/AbstractValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down

0 comments on commit 5bde54c

Please sign in to comment.