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

CustomerOption targetEntity must be the CustomerOptionInterface on CustomerOptionTranslation Entity #152

Closed
mbutl opened this issue May 2, 2024 · 5 comments

Comments

@mbutl
Copy link
Contributor

mbutl commented May 2, 2024

To be able to add custom fields on CustomerOptionValue and CustomerOption entiies, i overwrite these classes and use the following doctrine configuration to use my new entities :

        resolve_target_entities:
            Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\CustomerOptionValueInterface: App\Entity\CustomerOption\CustomerOptionValue
            Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\CustomerOptionInterface: App\Entity\CustomerOption\CustomerOption

However, for the CustomerOption, i have this error :

[Doctrine\ORM\ORMInvalidArgumentException]                                                                                                                                                               
  Expected value of type "Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\CustomerOption" for association field "Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\CustomerOptionTr  
  anslation#$translatable", got "App\Entity\CustomerOption\CustomerOption" instead.

After checking join configuration in CustomerOptionTranslation entity, i see that:

#[ORM\ManyToOne(targetEntity: CustomerOption::class, inversedBy: 'translations')]
#[ORM\JoinColumn(onDelete: 'CASCADE')]
protected ?TranslatableInterface $translatable = null;

The CustomerOptionInterface must be used here

#[ORM\ManyToOne(targetEntity: CustomerOptionInterface::class, inversedBy: 'translations')]
#[ORM\JoinColumn(onDelete: 'CASCADE')]
protected ?TranslatableInterface $translatable = null;
@mamazu
Copy link
Collaborator

mamazu commented May 6, 2024

Hey thank you for reporting this bug. We haven't tested this use case. But if you have made it work with your setup like this feel free to create a pull request. I'd be happy to merge it.

@mbutl
Copy link
Contributor Author

mbutl commented May 13, 2024

Hello, thank you for your answer.

I was actually able to test this modification with my setup (directly in vendor ^^)

I would like to create the pull request, but I don't have the permissions to do so.

@mamazu
Copy link
Collaborator

mamazu commented May 13, 2024

That's good to hear.
While working in the vendor directory is great for testing changes its a little tricky to push from there. Because by default composer clones this repository into the vendor directory (which you don't have write access to). What you would need to do is fork this repository, put the changes in the fork and then create a pull request from your fork to this repository.

If you need any further explanation feel free to say so.

@mbutl
Copy link
Contributor Author

mbutl commented May 13, 2024

Thanks for the explanation.

There is the pull request #153

@mamazu
Copy link
Collaborator

mamazu commented May 15, 2024

Closing this here as the PR is merged. If you still have issues with it feel free to open this again.

@mamazu mamazu closed this as completed May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants