<commit_before><?php 

namespace Admingenerator\GeneratorBundle\CacheWarmer;

use Symfony\Component\Yaml\Yaml;

use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Generate all admingenerated bundle on warmup
 * 
 * @author <NAME>
 */
class GeneratorCacheWarmer implements CacheWarmerInterface
{

    protected $container;
    
    protected $finder;
    
    protected $yaml_datas = array();
    
    /**
     * Constructor.
     *
     * @param ContainerInterface      $container The dependency injection container
     */
    public function __construct(ContainerInterface $container, GeneratorFinder $finder)
    {
        $this->container = $container;
        $this->finder = $finder;
    }

    /**
     * Warms up the cache.
     *
     * @param string $cacheDir The cache directory
     */
    public function warmUp($cacheDir)
    {
        foreach($this->finder->findAllGeneratorYamls() as $yaml)
        {
            $this->buildFromYaml($yaml);
        }
    }
    
    /**
     * Checks whether this warmer is optional or not.
     *
     * @return Boolean always true
     */
    public function isOptional()
    {
        return false;
    }
    
    protected function buildFromYaml($file)
    {
        $this->parseYaml($file);
        $service = $this->yaml_datas['generator'];
        
        $generator = $this->container->get($service);
        /*$generator = new $class($this->container->getParameter('kernel.root_dir'), $this->container->getParameter('kernel.cache_dir'));
        $generator->setContainer($this->container);
        $generator->setFieldGuesser($this->container->get('admingenerator.fieldguesser.doctrine'));*/
        $generator->setGeneratorYml($file);
        $generator->build();        
    }
    
    protected function parseYaml($file)
    {
       $this->yaml_datas = Yaml::parse($file);
    }<commit_msg>Remove commented code<commit_after><?php 

namespace Admingenerator\GeneratorBundle\CacheWarmer;

use Symfony\Component\Yaml\Yaml;

use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Generate all admingenerated bundle on warmup
 * 
 * @author <NAME>
 */
class GeneratorCacheWarmer implements CacheWarmerInterface
{

    protected $container;
    
    protected $finder;
    
    protected $yaml_datas = array();
    
    /**
     * Constructor.
     *
     * @param ContainerInterface      $container The dependency injection container
     */
    public function __construct(ContainerInterface $container, GeneratorFinder $finder)
    {
        $this->container = $container;
        $this->finder = $finder;
    }

    /**
     * Warms up the cache.
     *
     * @param string $cacheDir The cache directory
     */
    public function warmUp($cacheDir)
    {
        foreach($this->finder->findAllGeneratorYamls() as $yaml)
        {
            $this->buildFromYaml($yaml);
        }
    }
    
    /**
     * Checks whether this warmer is optional or not.
     *
     * @return Boolean always true
     */
    public function isOptional()
    {
        return false;
    }
    
    protected function buildFromYaml($file)
    {
        $this->parseYaml($file);
        $service = $this->yaml_datas['generator'];
        
        $generator = $this->container->get($service);
        $generator->setGeneratorYml($file);
        $generator->build();        
    }
    
    protected function parseYaml($file)
    {
       $this->yaml_datas = Yaml::parse($file);
    }
{'fraction_non_alphanumeric': 0.11763070077864293, 'fraction_numerical': 0.0, 'mean_word_length': 2.54384236453202, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 38, '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': '4038088', 'n_tokens_mistral': 1017, 'n_tokens_neox': 1005, 'n_words': 198}