<commit_before><?php

namespace SilexCMS\Set;

use Silex\Application;
use Silex\ServiceProviderInterface;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

use SilexCMS\Repository\GenericRepository;
use SilexCMS\Response\TransientResponse;

class DataSet implements ServiceProviderInterface
{
    public function __construct($block, $table = null)
    {
        if (is_null($table)) {
            $table = $block;
        }
        
        $this->block = $block;
        $this->table = $table;
    }
    
    public function register(Application $app)
    {
        $self = $this;
        
        $this->app = $app;
        
        $app->after(function (Request $req, Response $resp) use ($self, $app) {
            $self->filter($resp);
        });
    }
    
    public function filter(Response $resp)
    {
        if ($resp instanceof TransientResponse) {
            if ($resp->getTemplate()->hasBlock($this->name)) {
                $repository = new GenericRepository($this->app['db'], $this->table);
                $resp->getVariables()->{$this->block} = $this->app[$this->block] = $repository->findAll();
            }
        }
    }
}<commit_msg>Fixes a variable name (again)<commit_after><?php

namespace SilexCMS\Set;

use Silex\Application;
use Silex\ServiceProviderInterface;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

use SilexCMS\Repository\GenericRepository;
use SilexCMS\Response\TransientResponse;

class DataSet implements ServiceProviderInterface
{
    public function __construct($block, $table = null)
    {
        if (is_null($table)) {
            $table = $block;
        }
        
        $this->block = $block;
        $this->table = $table;
    }
    
    public function register(Application $app)
    {
        $self = $this;
        
        $this->app = $app;
        
        $app->after(function (Request $req, Response $resp) use ($self, $app) {
            $self->filter($resp);
        });
    }
    
    public function filter(Response $resp)
    {
        if ($resp instanceof TransientResponse) {
            if ($resp->getTemplate()->hasBlock($this->block)) {
                $repository = new GenericRepository($this->app['db'], $this->table);
                $resp->getVariables()->{$this->block} = $this->app[$this->block] = $repository->findAll();
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.1391519143680527, 'fraction_numerical': 0.0, 'mean_word_length': 2.379694019471488, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '1335034', 'n_tokens_mistral': 702, 'n_tokens_neox': 697, 'n_words': 136}