<commit_before><?php
/**
 *
 */

namespace Commercetools\Symfony\StateBundle\Cache;

use Commercetools\Symfony\StateBundle\Model\Repository\StateRepository;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;

class StateWarmer implements CacheWarmerInterface
{
    private $stateKeyResolver;

    public function __construct(StateKeyResolver $stateKeyResolver)
    {
        $this->stateKeyResolver = $stateKeyResolver;
    }

    public function isOptional()
    {
        return true;
    }

    public function warmUp($cacheDir)
    {
        $this->stateKeyResolver->fillCache();
    }
}<commit_msg>fix(StateBundle): fix state cache warmer<commit_after><?php
/**
 *
 */

namespace Commercetools\Symfony\StateBundle\Cache;

use Commercetools\Core\Error\ApiException;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;

class StateWarmer implements CacheWarmerInterface
{
    private $stateKeyResolver;
    private $logger;

    public function __construct(StateKeyResolver $stateKeyResolver, LoggerInterface $logger)
    {
        $this->stateKeyResolver = $stateKeyResolver;
        $this->logger = $logger;
    }

    public function isOptional()
    {
        return true;
    }

    public function warmUp($cacheDir)
    {
        try {
            $this->stateKeyResolver->fillCache();
        } catch (ApiException $exception) {
            $this->logger->info("Could not fetch states from commercetools");
        }
    }
}
{'fraction_non_alphanumeric': 0.09921671018276762, 'fraction_numerical': 0.0, 'mean_word_length': 3.4693877551020407, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '233942', 'n_tokens_mistral': 444, 'n_tokens_neox': 436, 'n_words': 80}