<commit_before><?php
/* 
 * Copyright 2017 <NAME> <http://jacksleight.com/>
 * This source file is subject to the MIT license that is bundled with this package in the file LICENCE. 
 */

namespace Coast\Doctrine\ORM;

use Doctrine\ORM\QueryBuilder,
    Doctrine\ORM\Query,
    Doctrine\ORM\Tools\Pagination\Paginator,
    Doctrine\Common\EventSubscriber;

class EntityManager extends \Doctrine\ORM\Decorator\EntityManagerDecorator implements \Coast\App\Access
{
    protected $_listeners = [];
    
    use \Coast\App\Access\Implementation;
    
    public function __construct($wraped)
    {
        parent::__construct($wraped);

        $config = $this->getConfiguration();
        $functions = [
            'CEILING'         => 'Coast\Doctrine\ORM\Query\MySql\Ceiling',
            'DATE_FORMAT'     => 'Coast\Doctrine\ORM\Query\MySql\DateFormat',
            'FIELD'           => 'Coast\Doctrine\ORM\Query\MySql\Field',
            'FLOOR'           => 'Coast\Doctrine\ORM\Query\MySql\Floor',
            'IF'              => 'Coast\Doctrine\ORM\Query\MySql\IfElse',
            'MONTH'           => 'Coast\Doctrine\ORM\Query\MySql\Month',
            'RAND'            => 'Coast\Doctrine\ORM\Query\MySql\Rand',
            'ROUND'           => 'Coast\Doctrine\ORM\Query\MySql\Round',
            'UTC_DATE'        => 'Coast\Doctrine\ORM\Query\MySql\UtcDate',
            'UTC_TIME'        => 'Coast\Doctrine\ORM\Query\MySql\UtcTime',
            'UTC_TIMESTAMP'   => 'Coast\Doctrine\ORM\Query\MySql\UtcTimestamp',
            'YEAR'            => 'Coast\Doctrine\ORM\Query\MySql\Year',
            'SUBSTRING_INDEX' => 'Coast\Doctrine\ORM\Query\MySql\SubstringIndex',
        ];
        foreach ($functions as $name => $class) {
            $config->addCustomStringFunction($name, $class);
        }
        
        $config->addCustomHydrationMode('coast_array', 'Coast\Doctrine\ORM\Internal\Hydration\ArrayHydrator');
    } 

    public function getWrapped()
    {
        return $this->wrapped;
    }

    public function __invoke($class)
    {
        return $this->getRepository($class);
    }

    public function ref($class, $id)
    {
        return $this->getReference(Chalk::info($class)->class, $id);
    }

    public function dir($name, \Coast\Dir $dir)
    {
        $this
            ->getConfiguration()
            ->getMetadataDriverImpl()
            ->addPaths([$name => $dir->name()]);
    }

    public function listener($name, EventSubscriber $listener = null)<commit_msg>Rename ref to proxy<commit_after><?php
/* 
 * Copyright 2017 <NAME> <http://jacksleight.com/>
 * This source file is subject to the MIT license that is bundled with this package in the file LICENCE. 
 */

namespace Coast\Doctrine\ORM;

use Doctrine\ORM\QueryBuilder,
    Doctrine\ORM\Query,
    Doctrine\ORM\Tools\Pagination\Paginator,
    Doctrine\Common\EventSubscriber;

class EntityManager extends \Doctrine\ORM\Decorator\EntityManagerDecorator implements \Coast\App\Access
{
    protected $_listeners = [];
    
    use \Coast\App\Access\Implementation;
    
    public function __construct($wraped)
    {
        parent::__construct($wraped);

        $config = $this->getConfiguration();
        $functions = [
            'CEILING'         => 'Coast\Doctrine\ORM\Query\MySql\Ceiling',
            'DATE_FORMAT'     => 'Coast\Doctrine\ORM\Query\MySql\DateFormat',
            'FIELD'           => 'Coast\Doctrine\ORM\Query\MySql\Field',
            'FLOOR'           => 'Coast\Doctrine\ORM\Query\MySql\Floor',
            'IF'              => 'Coast\Doctrine\ORM\Query\MySql\IfElse',
            'MONTH'           => 'Coast\Doctrine\ORM\Query\MySql\Month',
            'RAND'            => 'Coast\Doctrine\ORM\Query\MySql\Rand',
            'ROUND'           => 'Coast\Doctrine\ORM\Query\MySql\Round',
            'UTC_DATE'        => 'Coast\Doctrine\ORM\Query\MySql\UtcDate',
            'UTC_TIME'        => 'Coast\Doctrine\ORM\Query\MySql\UtcTime',
            'UTC_TIMESTAMP'   => 'Coast\Doctrine\ORM\Query\MySql\UtcTimestamp',
            'YEAR'            => 'Coast\Doctrine\ORM\Query\MySql\Year',
            'SUBSTRING_INDEX' => 'Coast\Doctrine\ORM\Query\MySql\SubstringIndex',
        ];
        foreach ($functions as $name => $class) {
            $config->addCustomStringFunction($name, $class);
        }
        
        $config->addCustomHydrationMode('coast_array', 'Coast\Doctrine\ORM\Internal\Hydration\ArrayHydrator');
    } 

    public function getWrapped()
    {
        return $this->wrapped;
    }

    public function __invoke($class)
    {
        return $this->getRepository($class);
    }

    public function proxy($class, $id)
    {
        return $this->getReference(Chalk::info($class)->class, $id);
    }

    public function dir($name, \Coast\Dir $dir)
    {
        $this
            ->getConfiguration()
            ->getMetadataDriverImpl()
            ->addPaths([$name => $dir->name()]);
    }

    public function listener($name, EventSubscriber $listener = null)
{'fraction_non_alphanumeric': 0.14006384676775738, 'fraction_numerical': 0.0015961691939345571, 'mean_word_length': 2.205242966751918, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 59, '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': '2336014', 'n_tokens_mistral': 1581, 'n_tokens_neox': 1551, 'n_words': 234}