<p dir="auto">Right now all constraint configuration should be defined in the <code class="notranslate">validator.xml</code> or <code class="notranslate">validator.yaml</code> file. Once you have a lot of entities this file becomes overly large. As I'm completely unfamiliar with the way metadata is handled by the validation component I need some suggestions before I can open a PR.</p>
<p dir="auto">This might be related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2679697" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/2992" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/2992/hovercard" href="https://github.com/symfony/symfony/issues/2992">#2992</a> and <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2682152" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/2996" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/2996/hovercard" href="https://github.com/symfony/symfony/pull/2996">#2996</a> but I'm not sure.</p>
<p dir="auto">I have a website splitted in 2 areas:</p>
<ul dir="auto">
<li>public customers</li>
<li>professional customers</li>
</ul>
<p dir="auto">Both areas contains the same organization (a list of the same activities).</p>
<p dir="auto">I am trying to generate the sames urls for both areas (just adding a prefix on pro area) and share the configuration so I don't need to duplicate all urls.</p>
<p dir="auto">The goal is to have something looking like this:</p>
<p dir="auto">Public area:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- /activity-1/
- /activity-2/
- /reuse-same-slug/"><pre class="notranslate"><code class="notranslate">- /activity-1/
- /activity-2/
- /reuse-same-slug/
</code></pre></div>
<p dir="auto">Pro area (reuse same slugs without prefix):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- /pro/activity-1/
- /pro/activity-2/
- /pro/reuse-same-slug/"><pre class="notranslate"><code class="notranslate">- /pro/activity-1/
- /pro/activity-2/
- /pro/reuse-same-slug/
</code></pre></div>
<p dir="auto">My controllers are stored in 2 distinct folders using same controller names:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="App\Controller\Pub\Activity1Controller.php
App\Controller\Pub\Activity2Controller.php

App\Controller\Pro\Activity1Controller.php
App\Controller\Pro\Activity2Controller.php"><pre class="notranslate"><code class="notranslate">App\Controller\Pub\Activity1Controller.php
App\Controller\Pub\Activity2Controller.php

App\Controller\Pro\Activity1Controller.php
App\Controller\Pro\Activity2Controller.php
</code></pre></div>
<p dir="auto">So I am able to load the same route configuration on both <code class="notranslate">Pub</code> and <code class="notranslate">Pro</code> controllers with this configuration:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="activity-1:
    resource: ../../src/Controller/*/Activity1Controller.php
    type: annotation
    name_prefix: activity-1_
    prefix: /activity-1

activity-2:
    resource: ../../src/Controller/*/Activity2Controller.php
    type: annotation
    name_prefix: activity-2_
    prefix: /activity-2"><pre class="notranslate"><span class="pl-ent">activity-1</span>:
    <span class="pl-ent">resource</span>: <span class="pl-s">../../src/Controller/*/Activity1Controller.php</span>
    <span class="pl-ent">type</span>: <span class="pl-s">annotation</span>
    <span class="pl-ent">name_prefix</span>: <span class="pl-s">activity-1_</span>
    <span class="pl-ent">prefix</span>: <span class="pl-s">/activity-1</span>

<span class="pl-ent">activity-2</span>:
    <span class="pl-ent">resource</span>: <span class="pl-s">../../src/Controller/*/Activity2Controller.php</span>
    <span class="pl-ent">type</span>: <span class="pl-s">annotation</span>
    <span class="pl-ent">name_prefix</span>: <span class="pl-s">activity-2_</span>
    <span class="pl-ent">prefix</span>: <span class="pl-s">/activity-2</span></pre></div>
<p dir="auto">But now, in order to distinguish public and professional routes, I need to the same custom annotation on each Pro controllers:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/**
 * @Route(&quot;/professional&quot;, name=&quot;professional_&quot;)
 */"><pre class="notranslate"><code class="notranslate">/**
 * @Route("/professional", name="professional_")
 */
</code></pre></div>
<p dir="auto">I am wondering if there is a better way to do this or if there is a way to not duplicate the annotation in all controllers?</p>