Class does not exist (ReflectionException)

337 views
Skip to first unread message

Yannick Boursin

unread,
Feb 25, 2015, 5:58:46 AM2/25/15
to sonat...@googlegroups.com
Hello,

        First, I'd like to thank you for the work you've been doing with sonata. It is really great and I guess it will help me gain some time. I guess I'm making some dumb mistake, but I couldn't figure it out myself, so I hope someone here will be able to guide me since I'm pretty new to symfony and even newer to the sonata admin bundle.
        I've been hitting an error since yesterday while trying to add my own entities to sonata admin, so they could be listed / modified / deleted

        The error seems like the one Deker hit ( https://groups.google.com/forum/#!topic/sonata-devs/VSH9vYugLx4 ) but I did not notince any namespace problem.
        After seeing this post, I moved my CRUD controllers to Platform\ProjectBundle\Controller\Admin namespace, but that made it worse, so I tried to use the default controller in the service declaration (didn't work either).
        Thank you !

        Here's the stack trace:

[1] ReflectionException: Class  does not exist
    at n/a
        in /var/www/Project/app/cache/dev/classes.php line 6756

    at ReflectionClass->__construct('')
        in /var/www/Project/app/cache/dev/classes.php line 6756

    at Doctrine\Common\Persistence\AbstractManagerRegistry->getManagerForClass(null)
        in /var/www/Project/vendor/sonata-project/doctrine-orm-admin-bundle/Model/ModelManager.php line 220

    at Sonata\DoctrineORMAdminBundle\Model\ModelManager->getEntityManager(null)
        in /var/www/Project/vendor/sonata-project/doctrine-orm-admin-bundle/Model/ModelManager.php line 54

    at Sonata\DoctrineORMAdminBundle\Model\ModelManager->getMetadata(null)
        in /var/www/Project/vendor/sonata-project/doctrine-orm-admin-bundle/Model/ModelManager.php line 317

    at Sonata\DoctrineORMAdminBundle\Model\ModelManager->getIdentifierFieldNames(null)
        in /var/www/Project/app/cache/dev/classes.php line 12663

    at Sonata\AdminBundle\Form\ChoiceList\ModelChoiceList->__construct(object(ModelManager), null, null, null, null)
        in /var/www/Project/app/cache/dev/classes.php line 13690

    at Sonata\AdminBundle\Form\Type\ModelType->Sonata\AdminBundle\Form\Type\{closure}(object(OptionsResolver), object(SimpleChoiceList))
        in /var/www/Project/vendor/symfony/symfony/src/Symfony/Component/OptionsResolver/OptionsResolver.php line 836

    at Symfony\Component\OptionsResolver\OptionsResolver->offsetGet('choice_list')
        in /var/www/Project/vendor/symfony/symfony/src/Symfony/Component/OptionsResolver/OptionsResolver.php line 769

    at Symfony\Component\OptionsResolver\OptionsResolver->resolve(array('sonata_field_description' => object(FieldDescription), 'class' => null, 'model_manager' => object(ModelManager), 'multiple' => false, 'label_render' => false, 'label' => 'Description'))
        in /var/www/Project/vendor/symfony/symfony/src/Symfony/Component/Form/ResolvedFormType.php line 109

    at Symfony\Component\Form\ResolvedFormType->createBuilder(object(FormFactory), 'description', array('sonata_field_description' => object(FieldDescription), 'class' => null, 'model_manager' => object(ModelManager), 'multiple' => false, 'label_render' => false, 'label' => 'Description'))
        in /var/www/Project/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php line 82

    at Symfony\Component\Form\Extension\DataCollector\Proxy\ResolvedTypeDataCollectorProxy->createBuilder(object(FormFactory), 'description', array('sonata_field_description' => object(FieldDescription), 'class' => null, 'model_manager' => object(ModelManager), 'multiple' => false, 'label_render' => false, 'label' => 'Description'))
        in /var/www/Project/vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php line 87

    at Symfony\Component\Form\FormFactory->createNamedBuilder('description', 'sonata_type_model', null, array('sonata_field_description' => object(FieldDescription), 'class' => null, 'model_manager' => object(ModelManager), 'multiple' => false, 'label_render' => false, 'label' => 'Description'))
        in /var/www/Project/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php line 106

    at Symfony\Component\Form\FormBuilder->create('description', 'sonata_type_model', array('sonata_field_description' => object(FieldDescription), 'class' => null, 'model_manager' => object(ModelManager), 'multiple' => false, 'label_render' => false, 'label' => 'Description'))
        in /var/www/Project/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php line 268

    at Symfony\Component\Form\FormBuilder->resolveChildren()
        in /var/www/Project/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php line 216

    at Symfony\Component\Form\FormBuilder->getForm()
        in /var/www/Project/app/cache/dev/classes.php line 9671

    at Sonata\AdminBundle\Admin\Admin->buildForm()
        in /var/www/Project/app/cache/dev/classes.php line 9930

    at Sonata\AdminBundle\Admin\Admin->getForm()
        in /var/www/Project/vendor/sonata-project/admin-bundle/Controller/CRUDController.php line 353

    at Sonata\AdminBundle\Controller\CRUDController->editAction('1')
        in  line 

    at call_user_func_array(array(object(CRUDController), 'editAction'), array('1'))
        in /var/www/Project/app/bootstrap.php.cache line 3022

    at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
        in /var/www/Project/app/bootstrap.php.cache line 2984

    at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
        in /var/www/Project/app/bootstrap.php.cache line 3133

    at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
        in /var/www/Project/app/bootstrap.php.cache line 2377

    at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
        in /var/www/Project/web/app_dev.php line 28


Here's the corresponding entry in service.yml (imported in config.yml):

platform.project.admin.biosample:
        class: Platform\ProjectBundle\Admin\BiosampleAdmin
        tags:
            - { name: sonata.admin, manager_type: orm, group: Project Manager, label: Biosample }
        arguments: [null, Platform\ProjectBundle\Entity\Biosample, ~]


I provide you will my entity (Biosample.php) and my Admin file (BiosampleAdmin.php)

 

BiosampleAdmin.php
Biosample.php

Yannick Boursin

unread,
Feb 25, 2015, 7:10:10 AM2/25/15
to sonat...@googlegroups.com
By the way, this problem occurs when trying to modify an entry, or create a new one.

Yannick Boursin

unread,
Feb 25, 2015, 8:19:00 AM2/25/15
to sonat...@googlegroups.com
I've also tried to move BiosampleAdminController inside Platform\ProjectBundle\Controller\Admin folder, to put both BiosampleController and BiosampleControllerAdmin in the same namespace, or other combinations, without any success (sorry for the amount of messages)
Reply all
Reply to author
Forward
0 new messages