1

I created Document manually, and tried to save data using persist.its show me following error.

The class 'Kdm\\SettingBundle\\Document\\Discount' was not found in the chain configured namespaces FOS\\UserBundle\\Entity, Ivory\\GoogleMapBundle\\Entity at
 /var/www/project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php:37)"}

Here is my document file Discount.php

<?php
namespace Kdm\SettingBundle\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;


/**
 * Discount
 * @MongoDB\Document(repositoryClass="Kdm\SettingBundle\Repository\SettingRepository")
 */

class Discount
{
    /**
     * @MongoDB\Id(strategy="auto")
     */
    protected $id;

    /**
     * @MongoDB\Field(type="integer")
    */
    protected $value;


    /**
     * Get id
     *
     * @return string $id
     */
    public function getId()
    {
        return $this->id;
    }



    /**
     * @param integer $value
    */
    public function setValue($value)
    {
        $this->value = $value;
    }

    /**
     * @return integer
     */
    public function getValue()
    {
        return $this->value;
    }
}

Here is my SettingController.php

<?php
namespace Kdm\SettingBundle\Controller;

use Kdm\KdmBundle\Controller\RefController as KdmController;
use Kdm\SettingBundle\Document\Discount as Setting;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

/**
 * @Route("/setting")
 */
class SettingController extends KdmController
{
    /**
     * Constructor
     */
    public function __construct()
    {
        parent::__construct('Kdm', 'Setting', 'setting','Discount');
    }

    /**
     * @Route
     * (
     *      path="/",
     *      name="kdm_setting"
     * )
     * @Template("::KdmSetting/Front/index.html.twig")
     */
    public function indexAction()
    {
        $setting = new Setting();
        $setting->setValue('5');

        $em = $this->getDoctrine()->getManager();
        $em->persist($setting);
        $em->flush();

        $form = $this->createFormBuilder($setting)
        ->add('value','integer')
        ->add('save','submit')
        ->getForm();


        return array(
            'form' => $form->createView()
        );
    }
}

i try to solve this error since last 2 days :( Can you help?

Kaushik Makwana
  • 2,422
  • 9
  • 31
  • 50
  • check this out: https://stackoverflow.com/questions/22813300/symfony-error-the-class-xxx-was-not-found-in-the-chain-configured-namespaces-xxx – Marçal Berga Dec 20 '18 at 07:54
  • Possible duplicate of [Symfony error The class XXX was not found in the chain configured namespaces XXX](https://stackoverflow.com/questions/22813300/symfony-error-the-class-xxx-was-not-found-in-the-chain-configured-namespaces-xxx) – Michael Sivolobov Dec 20 '18 at 07:56
  • @MichaelSivolobov, Ya almost same error, but i am sung MongoDB so need to work on Document. – Kaushik Makwana Dec 20 '18 at 08:16
  • what's your configured namespace for your Documents in your config ? – Etshy Dec 20 '18 at 10:46

0 Answers0