<commit_before><?php

namespace Rcm\SecureRepo;

use Doctrine\ORM\EntityManager;
use Rcm\Acl\AclActions;
use Rcm\Acl\AssertIsAllowed;
use Rcm\Acl\Exception\NotAllowedBySecurityPropGenerationFailure;
use Rcm\Acl\GetCurrentUser;
use Rcm\Acl\NotAllowedException;
use Rcm\Acl\SecurityPropertiesProviderInterface;
use Rcm\Entity\Container;
use Rcm\Entity\Country;
use Rcm\Entity\Domain;
use Rcm\Entity\Language;
use Rcm\Entity\Page;
use Rcm\Entity\Site;
use Rcm\ImmutableHistory\Page\PageContentFactory;
use Rcm\ImmutableHistory\Site\SiteContent;
use Rcm\ImmutableHistory\Site\SiteLocator;
use Rcm\ImmutableHistory\SiteWideContainer\ContainerContent;
use Rcm\ImmutableHistory\SiteWideContainer\SiteWideContainerLocator;
use Rcm\ImmutableHistory\VersionRepositoryInterface;
use Rcm\Page\PageTypes\PageTypes;
use Rcm\SecurityPropertiesProvider\SiteSecurityPropertiesProvider;
use Rcm\Service\LayoutManager;
use Rcm\Tracking\Exception\TrackingException;
use Rcm\Tracking\Model\Tracking;
use RcmAdmin\InputFilter\SiteInputFilter;
use RcmUser\Service\RcmUserService;
use RcmUser\User\Entity\UserInterface;
use Rcm\Exception\InputFilterFoundInvalidDataException;
use Doctrine\ORM\Tools\Pagination\Paginator as ORMPaginator;
use DoctrineORMModule\Paginator\Adapter\DoctrinePaginator;
use Interop\Container\ContainerInterface;
use Rcm\Acl\ResourceName;
use Rcm\Http\Response;
use Rcm\RequestContext\RequestContext;
use Rcm\View\Model\ApiJsonModel;
use Rcm\Http\NotAllowedResponseJsonZf2;
use Zend\Paginator\Paginator;
use Zend\View\Model\JsonModel;

class SiteSecureRepo
{
    /**
     * @var array
     */
    protected $config;

    /**
     * @var EntityManager
     */
    protected $entityManager;

    protected $pageMutationService;

    protected $siteVersionRepo;

    protected $immutableSiteWideContainerRepo;

    protected $pageContentFactory;
    protected $getCurrentUser;
    protected $siteSecurityPropertiesProvider;
    protected $assertIsAllowed;
    protected $currentUser;
    protected $siteSecureRepoPaginatorFactory;
    protected $currentSite;
    protected $layoutManager;

    public function __construct(
        $config,
        EntityManager $entityManager,
        PageSecureRepo $pageMutationService,
        VersionRepositoryInterface $siteVersionRepo,
        VersionRepositoryInterface $immutableSiteWideContainerRepo,
        PageContentFactory $pageContentFactory,
        GetCurrentUser $getCurrentUser,
        SiteSecurityPropertiesProvider $siteSecurityPropertiesProvider,
        AssertIsAllowed $assertIsAllowed,
        SiteSecureRepoPaginatorFactory $siteSecureRepoPaginatorFactory,
        Site $currentSite,
        LayoutManager $layoutManager
    ) {
        $this->config = $config;
        $this->entityManager = $entityManager;
        $this->pageMutationService = $pageMutationService;
        $this->siteVersionRepo = $siteVersionRepo;
        $this->immutableSiteWideContainerRepo = $immutableSiteWideContainerRepo;
        $this->pageContentFactory = $pageContentFactory;
        $this->currentUser = $getCurrentUser->__invoke();
        $this->siteSecurityPropertiesProvider = $siteSecurityPropertiesProvider;
        $this->assertIsAllowed = $assertIsAllowed;
        $this->siteSecureRepoPaginatorFactory = $siteSecureRepoPaginatorFactory;
        $this->currentSite = $currentSite;
        $this->layoutManager = $layoutManager;
    }

    public function assertIsAllowed(string $action, $resourceData)
    {
        $this->assertIsAllowed->__invoke(
            $action, $this->siteSecurityPropertiesProvider->findSecurityProperties($resourceData)
        );
    }

    /**
     * Note: this code was moved here durring the ACL2 project from ApiAdminManageSitesController
     *
     * Note: this function will omit any sites the user doesn't have access to read from the returned list
     *
     * @return mixed|JsonModel
     */
    public function getList($searchQuery, $page, $pageSize)
    {
        /** @var \Doctrine\ORM\EntityManagerInterface $entityManager */
        $entityManager = $this->getEntityManager();

        /** @var \Rcm\Repository\Site $siteRepo */
        $siteRepo = $entityManager->getRepository(\Rcm\Entity\Site::class);
        $createQueryBuilder = $siteRepo->createQueryBuilder('site')
            ->select('site')
            ->leftJoin('site.domain', 'domain')
            ->leftJoin('site.country', 'country')
            ->leftJoin('site.language', 'language')
            ->orderBy('domain.domain', 'ASC');

        $query = $createQueryBuilder->getQuery();<commit_msg>fix code style for axo 20483<commit_after><?php

namespace Rcm\SecureRepo;

use Doctrine\ORM\EntityManager;
use Rcm\Acl\AclActions;
use Rcm\Acl\AssertIsAllowed;
use Rcm\Acl\Exception\NotAllowedBySecurityPropGenerationFailure;
use Rcm\Acl\GetCurrentUser;
use Rcm\Acl\NotAllowedException;
use Rcm\Acl\SecurityPropertiesProviderInterface;
use Rcm\Entity\Container;
use Rcm\Entity\Country;
use Rcm\Entity\Domain;
use Rcm\Entity\Language;
use Rcm\Entity\Page;
use Rcm\Entity\Site;
use Rcm\ImmutableHistory\Page\PageContentFactory;
use Rcm\ImmutableHistory\Site\SiteContent;
use Rcm\ImmutableHistory\Site\SiteLocator;
use Rcm\ImmutableHistory\SiteWideContainer\ContainerContent;
use Rcm\ImmutableHistory\SiteWideContainer\SiteWideContainerLocator;
use Rcm\ImmutableHistory\VersionRepositoryInterface;
use Rcm\Page\PageTypes\PageTypes;
use Rcm\SecurityPropertiesProvider\SiteSecurityPropertiesProvider;
use Rcm\Service\LayoutManager;
use Rcm\Tracking\Exception\TrackingException;
use Rcm\Tracking\Model\Tracking;
use RcmAdmin\InputFilter\SiteInputFilter;
use RcmUser\Service\RcmUserService;
use RcmUser\User\Entity\UserInterface;
use Rcm\Exception\InputFilterFoundInvalidDataException;
use Doctrine\ORM\Tools\Pagination\Paginator as ORMPaginator;
use DoctrineORMModule\Paginator\Adapter\DoctrinePaginator;
use Interop\Container\ContainerInterface;
use Rcm\Acl\ResourceName;
use Rcm\Http\Response;
use Rcm\RequestContext\RequestContext;
use Rcm\View\Model\ApiJsonModel;
use Rcm\Http\NotAllowedResponseJsonZf2;
use Zend\Paginator\Paginator;
use Zend\View\Model\JsonModel;

class SiteSecureRepo
{
    /**
     * @var array
     */
    protected $config;

    /**
     * @var EntityManager
     */
    protected $entityManager;

    protected $pageMutationService;

    protected $siteVersionRepo;

    protected $immutableSiteWideContainerRepo;

    protected $pageContentFactory;
    protected $getCurrentUser;
    protected $siteSecurityPropertiesProvider;
    protected $assertIsAllowed;
    protected $currentUser;
    protected $siteSecureRepoPaginatorFactory;
    protected $currentSite;
    protected $layoutManager;

    public function __construct(
        $config,
        EntityManager $entityManager,
        PageSecureRepo $pageMutationService,
        VersionRepositoryInterface $siteVersionRepo,
        VersionRepositoryInterface $immutableSiteWideContainerRepo,
        PageContentFactory $pageContentFactory,
        GetCurrentUser $getCurrentUser,
        SiteSecurityPropertiesProvider $siteSecurityPropertiesProvider,
        AssertIsAllowed $assertIsAllowed,
        SiteSecureRepoPaginatorFactory $siteSecureRepoPaginatorFactory,
        Site $currentSite,
        LayoutManager $layoutManager
    ) {
        $this->config = $config;
        $this->entityManager = $entityManager;
        $this->pageMutationService = $pageMutationService;
        $this->siteVersionRepo = $siteVersionRepo;
        $this->immutableSiteWideContainerRepo = $immutableSiteWideContainerRepo;
        $this->pageContentFactory = $pageContentFactory;
        $this->currentUser = $getCurrentUser->__invoke();
        $this->siteSecurityPropertiesProvider = $siteSecurityPropertiesProvider;
        $this->assertIsAllowed = $assertIsAllowed;
        $this->siteSecureRepoPaginatorFactory = $siteSecureRepoPaginatorFactory;
        $this->currentSite = $currentSite;
        $this->layoutManager = $layoutManager;
    }

    public function assertIsAllowed(string $action, $resourceData)
    {
        $this->assertIsAllowed->__invoke(
            $action,
            $this->siteSecurityPropertiesProvider->findSecurityProperties($resourceData)
        );
    }

    /**
     * Note: this code was moved here durring the ACL2 project from ApiAdminManageSitesController
     *
     * Note: this function will omit any sites the user doesn't have access to read from the returned list
     *
     * @return mixed|JsonModel
     */
    public function getList($searchQuery, $page, $pageSize)
    {
        /** @var \Doctrine\ORM\EntityManagerInterface $entityManager */
        $entityManager = $this->getEntityManager();

        /** @var \Rcm\Repository\Site $siteRepo */
        $siteRepo = $entityManager->getRepository(\Rcm\Entity\Site::class);
        $createQueryBuilder = $siteRepo->createQueryBuilder('site')
            ->select('site')
            ->leftJoin('site.domain', 'domain')
            ->leftJoin('site.country', 'country')
            ->leftJoin('site.language', 'language')
            ->orderBy('domain.domain', 'ASC');

        $query = $createQueryBuilder->getQuery();
{'fraction_non_alphanumeric': 0.09477946809674948, 'fraction_numerical': 0.00098500601948123, 'mean_word_length': 4.03193832599119, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, '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': '7542730', 'n_tokens_mistral': 2566, 'n_tokens_neox': 2631, 'n_words': 466}