entity manager not defined in sonata bundle - symfony

I have integrated sonata admin bundle. I then integrate sonata news bundle successfully . Then I created a custom bundle. I want to configure this bundle as my CMS bundle using sonata bundle. I am able to display my CMS bundle in admin section but when I try to to edit or add new item I am getting an error:
No entity manager defined for class Fcse\CmsBundle\Entity\Book 500
Internal Server Error - RuntimeException
Book is my entity when i run command
app/console doctrine:schema:update --force
Book table is also not creating. Am I missing something in configuration?
my config file is large. i am posting the code of my cms bundle.
fcse_cms:
title: Sonata Project
link: http://local.demo
description: Cool bundles on top of Symfony2
salt: 'secureToken'
class:
book: Fcse\CmsBundle\Entity\Book
admin:
book:
class: Fcse\CmsBundle\Admin\BookAdmin
controller: SonataAdminBundle:CRUD
translation: CmsBundle
doctrine:
orm:
entity_managers:
default:
#metadata_cache_driver: apc
#query_cache_driver: apc
#result_cache_driver: apc
mappings:
FcseCmsBundle: ~
and i import this file in app/config.yml.

Related

Symfony bundle registration

I am maintaining an app that registers bundles in two different place:
In app/AppKernel.php, in the $bundles array
In app/config/config.yml, under the bundles key
ie, in config.yml:
bundles:
# Defaults (all currently registered bundles):
- FrameworkBundle
- SecurityBundle
- TwigBundle
- MonologBundle
- SwiftmailerBundle
- DoctrineBundle
- AsseticBundle
- FOSUserBundle
Registering in AppKernel.php was usual for me, but where/why is the registration in the config.yml file used?

The class sylius.model.product_archetype.class does not exist.

I am working on a Symfony 2 app and in the process of integrating the Sylius product bundle I get the following error when running
php app/console doctrine:schema:update --force
The error is
The class sylius.model.product_archetype.class does not exist.
Configuration
This is my confi.yml file
sylius_cart:
resolver: app.cart_item_resolver # The id of our newly created service.
classes: ~ # This key can be empty but it must be present in the configuration.
sylius_order:
driver: doctrine/orm # Configure the doctrine orm driver used in documentation.
sylius_money: ~
sylius_product:
driver: doctrine/orm
stof_doctrine_extensions:
orm:
default:
sluggable: true
timestampable: true
#sylius_archetype:
sylius_archetype:
driver: doctrine/orm # Configure the doctrine orm driver used in the documentation.
sylius_translation:
default_locale: en
And the bundles I have include are
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle($this),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
new Sylius\Bundle\ProductBundle\SyliusProductBundle(),
new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
new Sylius\Bundle\AttributeBundle\SyliusAttributeBundle(),
new Sylius\Bundle\VariationBundle\SyliusVariationBundle(),
new Sylius\Bundle\TranslationBundle\SyliusTranslationBundle(),
new Sylius\Bundle\CartBundle\SyliusCartBundle(),
new Sylius\Bundle\OrderBundle\SyliusOrderBundle(),
new Sylius\Bundle\MoneyBundle\SyliusMoneyBundle(),
new Sylius\Bundle\ArchetypeBundle\SyliusArchetypeBundle(),
Any idea what I am doing wrong here. It seems that the docs does not match the code any more.
The core team is working hard to cleanup the documentation (see here), aiming to the 1.0 beta release.
It seems you require a lot of components from Sylius. What about starting from the standard edition and create you own bundle to change whatever you want ? The customization guide is freshly up to date (here).
Core config reference for product archetype is the following:
sylius_archetype:
resources:
product:
archetype:
classes:
model: Sylius\Component\Core\Model\Archetype
interface: Sylius\Component\Product\Model\ArchetypeInterface
translation:
classes:
model: Sylius\Component\Product\Model\ArchetypeTranslation
interface: Sylius\Component\Product\Model\ArchetypeTranslationInterface
subject: Sylius\Component\Core\Model\Product
attribute: Sylius\Component\Product\Model\Attribute
option: Sylius\Component\Product\Model\Option
You have to change, I guess
Sylius\Component\Core\Model\Archetype
by
Sylius\Component\Product\Model\Archetype
And
Sylius\Component\Core\Model\Product
by
Sylius\Component\Product\Model\Product
Hope this helps :)

EasyAdminBundle ReflectionException at create Backend section of install

Having an issue with the final stage of the setup of Easy Admin in a fresh Symfony 3 install,
at the "Your First Backend" : Creating the backend for those entities just require you to add the following configuration in the app/config/config.yml file:
# app/config/config.yml
easy_admin:
entities:
- AppBundle\Entity\Product
- AppBundle\Entity\Category
- AppBundle\Entity\User
When I do this I get error :
[ReflectionException] Class
AppBundle\Entity\Product does not exist
All the previous commands for setup installed without error, including installing the assets.
In documentation of EasyAdminBundle You have
Let's suppose that your Symfony application defines three Doctrine ORM entities called Product, Category and User.
In entities section you need to list already existing in your app Entities. If you don't have any - create it.
Docs: https://github.com/javiereguiluz/EasyAdminBundle/blob/master/Resources/doc/getting-started/2-first-backend.md

Entity alias in new symfony 2.7 directory structure

after adapting to new recommended structure in Symfony 2.7 I'm not able to access entity alias through $em->getRepository('Bundle:Entity').
This is my directory structure:
MyBundle
- Component
- Catalog
- Model
Product.php
And my mapping definitition in config.yml:
mappings:
mybundle:
type: annotation
dir: %kernel.root_dir%/../src/mybundle/Component/Product/Model
prefix: MyBundle\Component\Product\Model
alias: ??? # I tried different things
What should I write in $em->getRepository('MyBundle:Product') instead of MyBundle:Product to succesfully accesing the entity?
If possible I would like to use default Symfony alias, so I don't need to specify an alias for every entity in config.yml
Actually I didn't need generate:bundle as it's not a real bundle but a namespace and a logical organization of files.
The solution is to specify the complete namespace in getRespository():
$em->getRepository('MyBundle\\Component\\Product\\Model\\CFGProduct)
Thanks

Sylius Product Bundle as dependency

I have an existing Symfony2 project which I'm attempting to install and use certain bundles from the Sylius project as dependencies. Here is my problem, I've added the SyliusProductBundle and all of its dependencies; however, when I attempt to update my database schema with:
app/console doctrine:scheme:update --force
I get the following error:
[Doctrine\Common\Persistence\Mapping\MappingException]
Class 'Sylius\Bundle\ProductBundle\Model\ProductInterface' does not exist
I'm not sure why this is happening, although it seems to be some sort of namespacing issue?
I have the following configuration:
sylius_resource:
resources:
src.user:
driver: doctrine/orm
templates: App:User
classes:
model: SRC\Bundle\UserBundle\Entity\User
sylius_product:
driver: doctrine/orm
classes:
product:
model: Sylius\Bundle\CoreBundle\Model\Product
controller: Sylius\Bundle\CoreBundle\Controller\ProductController
repository: Sylius\Bundle\CoreBundle\Repository\ProductRepository
form: Sylius\Bundle\CoreBundle\Form\Type\ProductType
Please register the bundle before DoctrineBundle. This is important as we use listeners which have to be processed first.

Resources