<commit_before><?php
namespace Psdtg\AdminBundle\Voter;

use FOS\UserBundle\Model\UserInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Acl\Voter\AclVoter;

use Psdtg\SiteBundle\Entity\Circuits\PhoneCircuit;
use Sonata\AdminBundle\Admin\Pool;

class PhoneCircuitAclVoter extends AclVoter
{
    protected $pool;

    public function __construct($aclProvider, $oidRetrievalStrategy, $sidRetrievalStrategy, $permissionMap, Pool $pool, $logger = null, $allowIfObjectIdentityUnavailable = true)
    {
        $this->pool = $pool;
        return parent::__construct($aclProvider, $oidRetrievalStrategy, $sidRetrievalStrategy, $permissionMap, $logger, $allowIfObjectIdentityUnavailable);
    }

    public function vote(TokenInterface $token, $object, array $attributes)
    {
        if(($user = $token->getUser()) instanceof UserInterface && $object instanceof PhoneCircuit) {
            // All users should be able to directly edit noLease circuits
            foreach ($attributes as $attribute) {
                if($attribute == 'EDIT' || $attribute == 'DELETE') {
                    if($object->getConnectivityType()->getNoLease() == true) {
                        return self::ACCESS_GRANTED;
                    }
                }
            }
            // Helpdesk user can do nothing at this point so we deny
            if($user->hasRole('ROLE_HELPDESK')) {
                return self::ACCESS_DENIED;
            } else if($user->hasRole('ROLE_KEDO')) {
                if($attribute == 'EDIT' || $attribute == 'DELETE') {
                    // Kedo user can edit if the circuit is not finalized
                    $admin = $this->pool->getAdminByAdminCode('sonata.admin.phonecircuits.kedo');
                    if(!$admin->circuitNoLease($object) && $admin->circuitFinalized($object)) {
                        return self::ACCESS_DENIED;
                    }
                }
            }
        }
        return self::ACCESS_ABSTAIN;
    }<commit_msg>Show button fix<commit_after><?php
namespace Psdtg\AdminBundle\Voter;

use FOS\UserBundle\Model\UserInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Acl\Voter\AclVoter;

use Psdtg\SiteBundle\Entity\Circuits\PhoneCircuit;
use Sonata\AdminBundle\Admin\Pool;

class PhoneCircuitAclVoter extends AclVoter
{
    protected $pool;

    public function __construct($aclProvider, $oidRetrievalStrategy, $sidRetrievalStrategy, $permissionMap, Pool $pool, $logger = null, $allowIfObjectIdentityUnavailable = true)
    {
        $this->pool = $pool;
        return parent::__construct($aclProvider, $oidRetrievalStrategy, $sidRetrievalStrategy, $permissionMap, $logger, $allowIfObjectIdentityUnavailable);
    }

    public function vote(TokenInterface $token, $object, array $attributes)
    {
        if(($user = $token->getUser()) instanceof UserInterface && $object instanceof PhoneCircuit) {
            // All users should be able to directly edit noLease circuits
            foreach ($attributes as $attribute) {
                if($attribute == 'VIEW') {
                    return self::ACCESS_GRANTED;
                } else if($attribute == 'EDIT' || $attribute == 'DELETE') {
                    if($object->getConnectivityType()->getNoLease() == true) {
                        return self::ACCESS_GRANTED;
                    }
                }
            }
            // Helpdesk user can do nothing at this point so we deny
            if($user->hasRole('ROLE_HELPDESK')) {
                return self::ACCESS_DENIED;
            } else if($user->hasRole('ROLE_KEDO')) {
                if($attribute == 'EDIT' || $attribute == 'DELETE') {
                    // Kedo user can edit if the circuit is not finalized
                    $admin = $this->pool->getAdminByAdminCode('sonata.admin.phonecircuits.kedo');
                    if(!$admin->circuitNoLease($object) && $admin->circuitFinalized($object)) {
                        return self::ACCESS_DENIED;
                    }
                }
            }
        }
        return self::ACCESS_ABSTAIN;
    }
{'fraction_non_alphanumeric': 0.11294568078487677, 'fraction_numerical': 0.0, 'mean_word_length': 2.3628318584070795, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '6266699', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1110, 'n_words': 235}