<commit_before><?php

namespace Bundle\CommonBundle\Entity\Core;

use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\ORMException;
use Bundle\CommonBundle\Constants\SearchConstant;
use Bundle\CommonBundle\Entity\Group\GroupRepository;
use Bundle\CommonBundle\Entity\User\UserRepository;
use Symfony\Component\Security\Core\SecurityContext;

/**
 * BaseRepository
 */
class BaseRepository extends EntityRepository
{
    /**
     * @var array
     */
    protected $repositories = array();

    /**
     * @var \Bundle\CommonBundle\Entity\User\User
     */
    private $currentUser;

    /**
     * @param BaseRepository $repository
     * @param string $name
     */
    public function addRepository(BaseRepository $repository, $name)
    {
        if (!isset($this->repositories[$name])) {
            $this->repositories[$name] = $repository;
        }
    }

    /**
     * @param string $name
     * @return BaseRepository
     */
    protected function getRepository($name)
    {
        if (isset($this->repositories[$name])) {
            return $this->repositories[$name];
        }
    }

    /**
     * Устанавливает авторизованного пользователя в св-во currentUser из SecurityContext
     * @param \Symfony\Component\Security\Core\SecurityContext $securityContext
     */
    public function setSecurityContext(SecurityContext $securityContext)
    {
        if ($token = $securityContext->getToken()) {
            $this->currentUser = $token->getUser();
        }
    }

    //TODO: depricated, remove this
    public function setCurrentUser($currentUser)
    {
        $this->currentUser = $currentUser;
    }

    /**
     * @return mixed
     */
    public function getCurrentUser()<commit_msg>Updated #setSecurityContext method<commit_after><?php

namespace Bundle\CommonBundle\Entity\Core;

use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\ORMException;
use Bundle\CommonBundle\Constants\SearchConstant;
use Bundle\CommonBundle\Entity\Group\GroupRepository;
use Bundle\CommonBundle\Entity\User\UserRepository;
use Symfony\Component\Security\Core\SecurityContext;
use Bundle\CommonBundle\Entity\User\User;

/**
 * BaseRepository
 */
class BaseRepository extends EntityRepository
{
    /**
     * @var array
     */
    protected $repositories = array();

    /**
     * @var \Bundle\CommonBundle\Entity\User\User
     */
    private $currentUser;

    /**
     * @param BaseRepository $repository
     * @param string $name
     */
    public function addRepository(BaseRepository $repository, $name)
    {
        if (!isset($this->repositories[$name])) {
            $this->repositories[$name] = $repository;
        }
    }

    /**
     * @param string $name
     * @return BaseRepository
     */
    protected function getRepository($name)
    {
        if (isset($this->repositories[$name])) {
            return $this->repositories[$name];
        }
    }

    /**
     * Устанавливает авторизованного пользователя в св-во currentUser из SecurityContext
     * @param \Symfony\Component\Security\Core\SecurityContext $securityContext
     */
    public function setSecurityContext(SecurityContext $securityContext)
    {
        if ($token = $securityContext->getToken()) {
            if ($token->getUser() instanceof User) {
                $this->currentUser = $token->getUser();
            }
        }
    }

    //TODO: depricated, remove this
    public function setCurrentUser($currentUser)
    {
        $this->currentUser = $currentUser;
    }

    /**
     * @return mixed
     */
    public function getCurrentUser()
{'fraction_non_alphanumeric': 0.12007874015748031, 'fraction_numerical': 0.0, 'mean_word_length': 2.7207112970711296, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '6716173', 'n_tokens_mistral': 1005, 'n_tokens_neox': 980, 'n_words': 187}