Reputation: 1357
Getting strange error from Symfony2 + Doctrine. Class is in it's place, no typos.
Uncaught PHP Exception Doctrine\Common\Persistence\Mapping\MappingException: "The class 'AppBundle\Repository\ORM\ImageRepository' was not found in the chain configured namespaces AppBundle\Entity" at /Users/macbook/Projects/stfalcon_test/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php line 37 {"exception":"[object] (Doctrine\\Common\\Persistence\\Mapping\\MappingException(code: 0): The class 'AppBundle\\Repository\\ORM\\ImageRepository' was not found in the chain configured namespaces AppBundle\\Entity at /Users/macbook/Projects/stfalcon_test/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php:37)"} []
Beginning of Entity class:
/**
* Image
*
* @ORM\Table(name="image")
* @ORM\Entity(repositoryClass="AppBundle\Repository\ORM\ImageRepository")
* @Vich\Uploadable
*/
class Image
{
Beginning of Repository class:
namespace AppBundle\Repository\ORM;
use AppBundle\Repository\Interfaces\ImageRepositoryInterface;
use Doctrine\ORM\EntityRepository;
/**
* ImageRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class ImageRepository extends EntityRepository implements ImageRepositoryInterface
{
Upvotes: 0
Views: 2091
Reputation: 1357
The solution was simple. The error was in service class, because I wanted to inject repository into manager. There was my service file:
services:
app.repository.orm.image_repository:
class: Doctrine\ORM\EntityRepository
factory: ['@doctrine.orm.default_entity_manager', getRepository]
arguments:
- AppBundle\Repository\ORM\ImageRepository
app.manager.image_manager:
class: AppBundle\Manager\ImageManager
arguments:
- "@app.repository.orm.image_repository
And in first service there should be entity class in arguments, not a repository class! I've made this mistake by inattention. So first service definition should look look this:
app.repository.orm.image_repository:
class: Doctrine\ORM\EntityRepository
factory: ['@doctrine.orm.default_entity_manager', getRepository]
arguments:
- AppBundle\Entity\Image
Upvotes: 1