<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>yes</td>
</tr>
<tr>
<td>Feature request?</td>
<td>no</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>2.8+</td>
</tr>
</tbody>
</table>
<p dir="auto">If I register a custom expression language function via a class implementing <code class="notranslate">ExpressionFunctionProviderInterface</code> and tagging it with <code class="notranslate">security.expression_language_provider</code> then I cannot use this function within an <code class="notranslate">allow_if</code> expression in my access control config.</p>
<p dir="auto">Specifically in my case I have the <code class="notranslate">is_granted</code> function registered with a custom provider. Using it with the authorization checker for example works fine:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$authorizationChecker-&gt;isGranted(new Expression(&quot;is_granted('something') and/or ...&quot;));"><pre class="notranslate"><span class="pl-s1"><span class="pl-c1">$</span>authorizationChecker</span>-&gt;<span class="pl-en">isGranted</span>(<span class="pl-k">new</span> <span class="pl-v">Expression</span>("<span class="pl-s">is_granted('something') and/or ...</span>"));</pre></div>
<p dir="auto">However using it inside the access control config results in an error:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    access_control:
         - { path: ^/, allow_if: &quot;is_granted('some_custom_attribute')&quot; }"><pre class="notranslate">    <span class="pl-ent">access_control</span>:
         - <span class="pl-s">{ path: ^/, allow_if: "is_granted('some_custom_attribute')" }</span></pre></div>
<p dir="auto">=&gt;</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="(1/1) SyntaxErrorThe function &quot;is_granted&quot; does not exist around position 1 for expression `is_granted('some_custom_attribute')`.
--
in Parser.php (line 198)
at Parser-&gt;parsePrimaryExpression()in Parser.php (line 149)
at Parser-&gt;getPrimary()in Parser.php (line 110)
at Parser-&gt;parseExpression()in Parser.php (line 100)
at Parser-&gt;parse(object(TokenStream), array('object', 'request', 'roles', 'token', 'trust_resolver', 'user'))in ExpressionLanguage.php (line 108)
at ExpressionLanguage-&gt;parse('is_granted(\'some_custom_attribute\')', array('object', 'request', 'roles', 'token', 'trust_resolver', 'user'))in SecurityExtension.php (line 671)
at SecurityExtension-&gt;createExpression(object(ContainerBuilder), 'is_granted(\'some_custom_attribute\')')in SecurityExtension.php (line 224)"><pre class="notranslate"><code class="notranslate">(1/1) SyntaxErrorThe function "is_granted" does not exist around position 1 for expression `is_granted('some_custom_attribute')`.
--
in Parser.php (line 198)
at Parser-&gt;parsePrimaryExpression()in Parser.php (line 149)
at Parser-&gt;getPrimary()in Parser.php (line 110)
at Parser-&gt;parseExpression()in Parser.php (line 100)
at Parser-&gt;parse(object(TokenStream), array('object', 'request', 'roles', 'token', 'trust_resolver', 'user'))in ExpressionLanguage.php (line 108)
at ExpressionLanguage-&gt;parse('is_granted(\'some_custom_attribute\')', array('object', 'request', 'roles', 'token', 'trust_resolver', 'user'))in SecurityExtension.php (line 671)
at SecurityExtension-&gt;createExpression(object(ContainerBuilder), 'is_granted(\'some_custom_attribute\')')in SecurityExtension.php (line 224)
</code></pre></div>
<p dir="auto">This happens because custom function providers are not loaded at all within the <code class="notranslate">SecurityExtension</code>:</p>
<p dir="auto"><a href="https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php#L741">https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php#L741</a></p>
<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>yes</td>
</tr>
<tr>
<td>Feature request?</td>
<td>no</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>3.2.9</td>
</tr>
</tbody>
</table>
<p dir="auto">It's exactly the same problem of this issue : <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="201036074" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/21305" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/21305/hovercard" href="https://github.com/symfony/symfony/issues/21305">#21305</a></p>
<p dir="auto">Except i using it in securty.yml allow_if and i got :<br>
Error: The function "test" does not exist around position 1.</p>
<p dir="auto">With @Security annotation everything is ok.</p>