Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues v2.3.0 and PR #50 #51

Closed
Mopster opened this issue Aug 2, 2019 · 2 comments

Comments

@Mopster
Copy link

commented Aug 2, 2019

I'm having issues with version 2.3.0 with PR #50
Installed this version and it broke my app. Getting the following error :

Class "Craue\ConfigBundle\Entity\Setting" sub class of "Craue\ConfigBundle\Entity\BaseSetting" is not a valid entity or mapped super class.

I had a custom Setting class, I had to shorten the name to 191 chars for indexing (multibyte).

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

class Setting extends \Craue\ConfigBundle\Entity\Setting
{
    /**
     * @ORM\Id
     * @ORM\Column(name="name", type="string", length=191, nullable=false, unique=true)
     * @Assert\NotBlank()
     */
    protected $name;
}

I did not have anything else in my config.yml or other code.

Checking the change and the readme, I changed my code to

use Craue\ConfigBundle\Entity\BaseSetting;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity(repositoryClass="Craue\ConfigBundle\Repository\SettingRepository")
 * @ORM\Table(name="config_setting")
 */
class Setting extends BaseSetting
{
    /**
     * @ORM\Id
     * @ORM\Column(name="name", type="string", length=191, nullable=false, unique=true)
     * @Assert\NotBlank()
     */
    protected $name;
}

and updated the config.yml to contain :

craue_config:
    entity_name: Tamago\DefaultBundle\Entity\Setting

Then made a DoctrineMigration to rename the craue_config_setting table to config_setting

But after all that, when getting a value, it returns null. I discovered the entity is not being hydrated correctly (value = null). Any changes to the value (setting a value) is not getting saved to the database.

Am I missing another setting somewhere ?

@craue

This comment has been minimized.

Copy link
Owner

commented Aug 2, 2019

When using a custom entity, you must provide a mapping for the value field as well. I wonder whether this worked before 2.3.0.

@Mopster

This comment has been minimized.

Copy link
Author

commented Aug 2, 2019

@craue that looks to have fixed it, thanks!

It might've not correctly picked up my custom entity before. But I was storing values :-)

@Mopster Mopster closed this Aug 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.