<commit_before><?php

namespace Ilios\AuthenticationBundle\Voter;

use Ilios\CoreBundle\Entity\CompetencyInterface;
use Ilios\CoreBundle\Entity\UserInterface;

/**
 * Class CompetencyVoter
 * @package Ilios\AuthenticationBundle\Voter
 */
class CompetencyVoter extends AbstractVoter
{
    /**
     * {@inheritdoc}
     */
    protected function getSupportedClasses()
    {
        return array('Ilios\CoreBundle\Entity\CompetencyInterface');
    }

    /**
     * @param string $attribute
     * @param CompetencyInterface $competency
     * @param UserInterface $user
     * @return bool
     */
    protected function isGranted($attribute, $competency, $user = null)
    {
        if (!$user instanceof UserInterface) {
            return false;
        }

        switch ($attribute) {
            case self::VIEW:
                return true;
                break;
            case self::EDIT:
            case self::DELETE:
                if ($competency->getSchool()->getId() === $user->getPrimarySchool()) {
                    return $this->userHasRole($user, ['Developer', 'Faculty',]);
                }
                break;
        }

        return false;
    }
}
<commit_msg>tuned perms check in competency voter.<commit_after><?php

namespace Ilios\AuthenticationBundle\Voter;

use Ilios\CoreBundle\Entity\CompetencyInterface;
use Ilios\CoreBundle\Entity\UserInterface;

/**
 * Class CompetencyVoter
 * @package Ilios\AuthenticationBundle\Voter
 */
class CompetencyVoter extends AbstractVoter
{
    /**
     * {@inheritdoc}
     */
    protected function getSupportedClasses()
    {
        return array('Ilios\CoreBundle\Entity\CompetencyInterface');
    }

    /**
     * @param string $attribute
     * @param CompetencyInterface $competency
     * @param UserInterface $user
     * @return bool
     */
    protected function isGranted($attribute, $competency, $user = null)
    {
        if (!$user instanceof UserInterface) {
            return false;
        }

        switch ($attribute) {
            case self::VIEW:
                return true;
                break;
            case self::EDIT:
            case self::DELETE:
                if ($competency->getSchool()->getId() === $user->getPrimarySchool()) {
                    return $this->userHasRole($user, ['Developer', 'Course Director']);
                }
                break;
        }

        return false;
    }
}

{'fraction_non_alphanumeric': 0.11350455675227837, 'fraction_numerical': 0.0, 'mean_word_length': 2.088235294117647, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5392698', 'n_tokens_mistral': 669, 'n_tokens_neox': 654, 'n_words': 136}