symfony2admingenerator / AdmingeneratorGeneratorBundle

(old-legacy) Admingenerator for Symfony2, parse generator.yml files to build classes
http://symfony2admingenerator.org/
MIT License
360 stars 125 forks source link

Non standard bundle namespace, 500 error #708

Open denys281 opened 10 years ago

denys281 commented 10 years ago

When I have bundle for example Acme/Backend/BlogBundle. On any action of this bundle symfony give 500.

 Opps an error occurred in your configuration. If you're in prod try cache:warmup
500 Internal Server Error - CantGenerateException 

But Acme/BackendBlogBundle works perfect.

Stack Trace

in kernel.root_dir/cache/dev/Admingenerated/Acme/BackendBlogBundle/BaseBlogController/ListController.php at line 16  -

Problem is that in cache Admingenerator generate folder with name AcmeBackend\BlogBundle

ioleo commented 10 years ago

@denys281 please post the beggining of your generator.yml file (bundle name, namespace prefix, etc)

denys281 commented 10 years ago

@loostro

Bundle in Webmil/Backend/StaticBundle

generator: admingenerator.generator.doctrine
params:
    model: Webmil\Frontend\StaticBundle\Entity\StaticData
    namespace_prefix: Webmil
    concurrency_lock: ~
    bundle_name: Backend\StaticBundle
    pk_requirement: ~
    fields: ~
    object_actions:
        delete: ~
    batch_actions:
        delete: ~
denys281 commented 10 years ago

Ok, in Generator.php I try change

return $this->cache_dir.'/Admingenerated/'.str_replace('\\', DIRECTORY_SEPARATOR, $namespace).$bundle_name;

to

       return $this->cache_dir.'/Admingenerated/'.str_replace('\\', DIRECTORY_SEPARATOR, $namespace).str_replace('\\', DIRECTORY_SEPARATOR, $bundle_name);

And in start generate folder in cache like AcmeBackend/StaticBundle, but I have next error

FatalErrorException: Error: Call to undefined method Acme\Backend\StaticBundle\Form\Type\Static\FiltersType::setSecurityContext() in /home/dan/WEB/www/project/app/cache/dev/Admingenerated/AcmeBackend/StaticBundle/BaseStaticController/ListController.php line 425

_Update_: it generate wrong namespace in FiltersType.php:

 use Admingenerated\AcmeBackendStaticBundle\Form\BaseStaticType\FiltersType as BaseFiltersType;

I fix it manually and next error:

Unable to find template "AcmeBackend\StaticBundle:StaticList:index.html.twig". 
ioleo commented 10 years ago

@denys281 what happens if you try:

generator: admingenerator.generator.doctrine
params:
    model: Webmil\Frontend\StaticBundle\Entity\StaticData
    namespace_prefix: Webmil\Backend # added Backend
    bundle_name: StaticBundle # removed Backend
denys281 commented 10 years ago

@loostro

Opps an error occurred in your configuration. If you're in prod try cache:warmup
ioleo commented 10 years ago

Can you try also with double slashes Webmil\\Backend? And clear your cache to be sure everything is regenerated.

denys281 commented 10 years ago

same error.

ioleo commented 10 years ago

Hmm.. just to be sure it's not escapeing characters problem, please try also with 3 \\\ and 4 \\\\ slashes.

denys281 commented 10 years ago

Same error.

ioleo commented 10 years ago

Ok, the line

return $this->cache_dir.'/Admingenerated/'.str_replace('\\', DIRECTORY_SEPARATOR, $namespace).$bundle_name;

is fine, but something else is throwing an error and you get the EmptyBuilder generated...

Apolide commented 10 years ago

I've faced the same problem. Followed the official documentation at http://symfony2admingenerator.org/documentation/generator-params.html# and find out the param (subfolder) in generator.yml, that helps in a custom namespace tree. My generator.yml looks now like this:

generator: admingenerator.generator.doctrine
params:
    model: Company\Bundle\AdminBundle\Entity\MyEntity
    namespace_prefix: Company
    subfolder: Bundle
    bundle_name: AdminBundle