problème d’auto wiring et d’argument dans une fonction construct symfony [closed]

Bonjour à tous,

j’ai passé 3 heures cette nuit à essayer de comprendre ce qui n’allait pas, j’ai un problème par rapport à ma classe qui n’est pas détectée;

j’ai ce message d’erreur : Cannot autowire service “AppControllerMissionsController”: argument “$repository” of method “__construct()” has type “AppControllerMissionRepository” but this class was not found.

Je suis largé

Merci par avance 🙂

voici mon message d’erreur en photo

et voici le code de mon missioncontroller

<?php

namespace AppController;


use DoctrineCommonPersistenceObjectManager;
use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentRoutingAnnotationRoute;


class MissionsController extends AbstractController
{
   /**
    *@var MissionRepository
    */

    private $repository;

    /**
    *@var ObjectManager
    */

    private $em;


    public function __construct( MissionRepository $repository , ObjectManager $em)
    {
        $this ->repository = $repository;
        $this-> em = $em;
    }


    /**
     * @Route("/missions", name="missions")
     * 
     */
    public function index():Response
    {


        $repository = $this -> repository ->findAllvisible();


        return $this->render('missions/index.html.twig', [
            'controller_name' => 'MissionsController',
        ]);
    }

}

et voici celui de missionrepository

<?php

namespace AppRepository;

use AppEntityMission;
use DoctrineBundleDoctrineBundleRepositoryServiceEntityRepository;
use DoctrinePersistenceManagerRegistry;

/**
 * @method Mission|null find($id, $lockMode = null, $lockVersion = null)
 * @method Mission|null findOneBy(array $criteria, array $orderBy = null)
 * @method Mission[]    findAll()
 * @method Mission[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */
class MissionRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry )
    {
        parent::__construct($registry, Mission::class);
    }



    public function findAllVisible()
    {
        return $this -> createQueryBuilder('m')
        -> where ('m.accepted = false') 
        ->getQuery()
        ->getResult();
    }



    // /**
    //  * @return Mission[] Returns an array of Mission objects
    //  */
    /*
    public function findByExampleField($value)
    {
        return $this->createQueryBuilder('m')
            ->andWhere('m.exampleField = :val')
            ->setParameter('val', $value)
            ->orderBy('m.id', 'ASC')
            ->setMaxResults(10)
            ->getQuery()
            ->getResult()
        ;
    }
    */

    /*
    public function findOneBySomeField($value): ?Mission
    {
        return $this->createQueryBuilder('m')
            ->andWhere('m.exampleField = :val')
            ->setParameter('val', $value)
            ->getQuery()
            ->getOneOrNullResult()
        ;
    }
    */
}

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *