Symfony returns error message “this type has been excluded in “config/services.yaml”

  Kiến thức lập trình

I’m trying to show the database table, i’m using the following composer and twig:

private $doctrine;

    public function __construct(ManagerRegistry $doctrine)
    {
        $this->doctrine = $doctrine;
    }
    #[Route('/', name: 'app_signal_index', methods: ['GET'])]
    public function index(Request $request, Signal $signal): Response
    {
        $priority = $request->query->get('priority');
        $contributor = $request->query->get('contributor');
        $status = $request->query->get('status');
        $transition = null;
        $resolution = null;
    
        if ($priority !== null) {
            $transition = $this->doctrine->getRepository(TransitionSignal::class)->findBy(['transition' => $priority]);
        }
    
        if ($contributor !== null) {
            $transition = $this->doctrine->getRepository(TransitionSignal::class)->findBy(['transition' => $contributor]);
        }
    
        if ($status !== null) {
            $resolution = $this->doctrine->getRepository(ResolutionSignal::class)->findBy(['resolution' => $status]);
        }
    
        return $this->render('signal/index.html.twig', [
            'signal' => $signal,
            'transition' => $transition,
            'resolution' => $resolution,
        ]);

in twig:

{% for signal in signals %}
        <tr>
        <td>{{ signal.id }}</td>
        <td>{{ signal.date ? signal.date|date('Y-m-d H:i:s') : '' }}</td>
        <td>{{ signal.address }}</td>
        <td>{{ signal.description }}</td>
        <td>{{ transition.priority }}</td>
        <td>{{ transition.contributor }}</td>
        <td>{{ resolution.actionPlanStatus }}</td>

            <td>
                <div class="mt-3">
                    <div class="btn-group" role="group" aria-label="Basic example">
                        <a href="{{ path('app_signal_show', {'id': signal.id}) }}" class="btn btn-secondary" role="button">show</a>
                        <a href="{{ path('app_signal_edit', {'id': signal.id}) }}" class="btn btn-secondary" role="button">edit</a>
                    </div>
                </div>
            </td>
        </tr>
    {% else %}
        <tr>
            <td colspan="26">no records found</td>
        </tr>
    {% endfor %}

The server is returning the following error message:
Cannot autowire argument $signal of “AppControllerSignalController::index()”: it needs an instance of “AppEntitySignal” but this type has been excluded in “config/services.yaml”.

I’m expecting to show the table from database

LEAVE A COMMENT