<commit_before><?php

namespace Opifer\CmsBundle\Security;

use Opifer\CmsBundle\Entity\User;
use Opifer\ContentBundle\Model\Content;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\Security;

class ContentVoter extends Voter
{
    private $security;
    private $container;
    private $roles;

    public function __construct(Security $security, ContainerInterface $container, $roles)
    {
        $this->security = $security;
        $this->container= $container;
        $this->roles = $roles;
    }

    protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
    {
        $user = $token->getUser();

        if (!$user instanceof User) {
            // the user must be logged in; if not, deny access<commit_msg>Allow super admins to see/edit all content items<commit_after><?php

namespace Opifer\CmsBundle\Security;

use Opifer\CmsBundle\Entity\Content;
use Opifer\CmsBundle\Entity\User;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\Security;

class ContentVoter extends Voter
{
    private $security;
    private $container;
    private $roles;

    public function __construct(Security $security, ContainerInterface $container, $roles)
    {
        $this->security = $security;
        $this->container= $container;
        $this->roles = $roles;
    }

    protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
    {
        // ROLE_SUPER_ADMIN can access all content items
        if ($this->security->isGranted('ROLE_SUPER_ADMIN')) {
            return true;
        }

        $user = $token->getUser();

        if (!$user instanceof User) {
            // the user must be logged in; if not, deny access
{'fraction_non_alphanumeric': 0.10405471421592574, 'fraction_numerical': 0.0, 'mean_word_length': 3.602247191011236, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '6121601', 'n_tokens_mistral': 576, 'n_tokens_neox': 573, 'n_words': 136}