<commit_before>{% block security_use %}
    use Symfony\Component\Security\Core\Exception\AccessDeniedException;
    {% if(admingenerator_config('use_jms_security')) %}
        use JMS\SecurityExtraBundle\Security\Authorization\Expression\Expression;
    {% endif %}
{% endblock %}

{% block security_check %}
    /**
    * Check user credentials
    *
    * @param string $credentials
    * @param \{{ model }} ${{ builder.ModelClass }}
    * @return boolean
    */
    protected function validateCredentials($credentials, \{{ model }} ${{ builder.ModelClass }} = null)
    {
    {% if(admingenerator_config('use_jms_security')) %}
        $credentials = new Expression($credentials);
    {% endif %}

    return $this->isGranted($credentials, ${{ builder.ModelClass }});
    }

    /**
    * Throws exception if credentials are not validated
    *
    * @param string $credentials
    * @param \{{ model }} ${{ builder.ModelClass }}
    * @throws AccessDeniedException if is not allowed
    */
    protected function denyAccessUnlessValidateCredentials($credentials, \{{ model }} ${{ builder.ModelClass }} = null)
    {
    if (!$this->validateCredentials($credentials, ${{ builder.ModelClass }})) {
    throw $this->createAccessDeniedException('Credentials unsatisfied');
    }
    }
{% endblock %}

{% block security_action %}
    {% if builder.yamlKey is same as('actions')  %}
        {% if action is defined and action.credentials and action.credentials is not same as('AdmingenAllowed') %}
            $this->denyAccessUnlessValidateCredentials('{{ action.credentials }}');
        {% endif %}
    {% elseif credentials is defined and credentials is not same as('AdmingenAllowed') %}
        $this->denyAccessUnlessValidateCredentials('{{ credentials }}');
    {% endif %}
{% endblock %}

{% block security_action_with_object %}
    {% if builder.yamlKey is same as('actions') %}
        {% if action is defined and action.credentials and action.credentials is not same as('AdmingenAllowed') %}
            $this->denyAccessUnlessValidateCredentials('{{ action.credentials }}', ${{ builder.ModelClass }});
        {% endif %}
    {% elseif credentials and credentials is not same as('AdmingenAllowed') %}
        $this->denyAccessUnlessValidateCredentials('{{ credentials }}', ${{ builder.ModelClass }});
    {% endif %}
{% endblock %}<commit_msg>Fix #251<commit_after>{% block security_use %}
    use Symfony\Component\Security\Core\Exception\AccessDeniedException;
    {% if(admingenerator_config('use_jms_security')) %}
        use JMS\SecurityExtraBundle\Security\Authorization\Expression\Expression;
    {% endif %}
{% endblock %}

{% block security_check %}
    /**
    * Check user credentials
    *
    * @param string $credentials
    * @param \{{ model }} ${{ builder.ModelClass }}
    * @return boolean
    */
    protected function validateCredentials($credentials, \{{ model }} ${{ builder.ModelClass }} = null)
    {
    {% if(admingenerator_config('use_jms_security')) %}
        $credentials = new Expression($credentials);
    {% endif %}

    return $this->isGranted($credentials, ${{ builder.ModelClass }});
    }

    /**
    * Throws exception if credentials are not validated
    *
    * @param string $credentials
    * @param \{{ model }} ${{ builder.ModelClass }}
    * @throws AccessDeniedException if is not allowed
    */
    protected function denyAccessUnlessValidateCredentials($credentials, \{{ model }} ${{ builder.ModelClass }} = null)
    {
    if (!$this->validateCredentials($credentials, ${{ builder.ModelClass }})) {
    throw $this->createAccessDeniedException('Credentials unsatisfied');
    }
    }
{% endblock %}

{% block security_action %}
    {% if builder.yamlKey is same as('actions')  %}
        {% if action is defined and action.credentials and action.credentials is not same as('AdmingenAllowed') %}
            $this->denyAccessUnlessValidateCredentials('{{ action.credentials }}');
        {% endif %}
    {% elseif credentials is defined and credentials is not empty and credentials is not same as('AdmingenAllowed') %}
        $this->denyAccessUnlessValidateCredentials('{{ credentials }}');
    {% endif %}
{% endblock %}

{% block security_action_with_object %}
    {% if builder.yamlKey is same as('actions') %}
        {% if action is defined and action.credentials and action.credentials is not same as('AdmingenAllowed') %}
            $this->denyAccessUnlessValidateCredentials('{{ action.credentials }}', ${{ builder.ModelClass }});
        {% endif %}
    {% elseif credentials is defined and credentials is not empty and credentials is not same as('AdmingenAllowed') %}
        $this->denyAccessUnlessValidateCredentials('{{ credentials }}', ${{ builder.ModelClass }});
    {% endif %}
{% endblock %}
{'fraction_non_alphanumeric': 0.1430666108085463, 'fraction_numerical': 0.0006284038542103058, 'mean_word_length': 3.626937984496124, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '5040975', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1282, 'n_words': 295}