Symfony2 Sonata Classification Bundle Extends - symfony

I installed Sonata Classification bundle (part of Sonata Project Sandbox) which include Categories, Tags and Collections. Now I need create custom categories class, for example Categories for Restaurants, which should be identical to the Categories, but must contain several custom options, and save all data to another mysql table.
I can't do it in Application folder because I can't override some config files, such as routes and admin.xml, because of DI. Vendor\Sonata\ClassificationBundle have DI folder, and configs connects through Dependency Injection. I can't override it in Applications folder.
How can I perform this task??
Thank you.

If you cannot do this with doctrine, then you cannot do that with SonataAdminBundle.

Related

Use bundle error templates in Symfony 3 app

I have a MyBundle bundle which I use in many Symfony applications.
This bundle provides common things which are shared across these applications, such as Controllers, Entities, templates, etc.
I would like the bundle to provide error templates as well.
I tried to put the templates in MyBundle/Resources/TwigBundle/views/Exception folder but the application does not use them.
When I copy TwigBundle folder from MyBundle/Resources into app/Resources then the templates are used as expected. However I do not want to copy the templates into every application's app/Resources folder.
Is it possible to override error templates using MyBundle/Resources instead of app/Resources?
TwigBundle always by default checks directory app/Resources/TwigBundle/views/Exception/ for templates.
If you want to use custom directory you have to override ExceptionController.
You can do this in config
// app/config/config.yml
twig:
exception_controller: MyBundle:Exception:showException
Default Twig ExceptionController can be found here.
Documentation

Showing configuration options depending on users access to bundle

I am creating an app that will be extended by several bundles. Users will have access to different bundles based on roles. Some of these bundles will have configuration options, and I want one page with all config forms.
What I want to do is create a page that every bundle will "hook" into, and show the configuration form if the bundle has one.
There will also be a dashboard page that each bundle should "hook" into and show a dashboard widget.
Is there any way of achieving this in symfony? And if so, how?
I finally understood the The DependencyInjection Component so I guess the answer lies there. In detail, I will try to create an event in the configuration controller, and all bundles will have a subscriber to this event, and somehow have the forms available for the configuration twig file. But that is another question.

Crud with FOSUserBundle

I 'm a new with Symfony2!. Can you tell me please if I can user CRUD with FOSUserBundle?? Is that even possible ? Actually, i want create a Manager role who can edit and delete users form database !
FosUserBundle doesn't provide such functionality. You can generate CRUD using Symfony standard edition built in task:
php app/console doctrine:generate:crud
for your User entity.
For more complex purposes you need to check some admin bundles, maybe SonataAdminBundle . This will provide admin generator in which you can manage (CRUD) your entities.
Also note, that using all kinds of code generators is considered as not-so-good-practice
For those who are facing this issue :
- if you override the parent classe with custom fields (let's say "firstname" + "lastname") in you User entity
- and then re-generate the CRUD
you will see that the 2 custom field became editable.
The Doctrine CRUD generator looks incompatible with FOSUserBundle in the present state, as we create inheritance with a User master class.
There is a same issue if you try to use the Group Model of FOSUserBundle.

Generating a CRUD Controller in a different bundle

I want to generate some CRUD controllers with the following command:
php app/console generate:doctrine:crud
my problem is that I made 2 bundles (1 front end and 1 for the admin section) my entities are in the defaultbundle, but I'd like to generate the CRUD controllers in my admin bundle, is there a way to do this?
Generating CRUD controllers in a bundle different of the entity's one is, as far as I know, impossible.
Indeed, CRUD controllers generator is just here for test. But if you really want to use it, you can actually copy the controller, views and form in the other bundle. You'll just need to change the templates' paths and the namespaces at the beginning of the controller and the Form type.

Symfony2 division project into bundles

I am new in Symfony2 and I am starting new project where will be articles, blogs with posts, polls, etc. The application will have administration part.
I would like to know how much should be the application divided into the bundles. What are the best practices.
Should I make:
One bundle with all logic (public and private).
Public bundle for whole portal and administration bundle for private part.
Article bundle, Blog bundle, Poll bundle, etc. and Administration bundle (maybe divided on AdminArticle bundle, AdminBlog bundle,...)
I would recommend you divide application into logical bundles, in other words, which is your third option.
For example: Main Bundle, Article bundle, Blog bundle, Poll bundle, and AdminBundle
In the Main Bundle, you can make global methods, homepage, twig extensions etc.

Resources