We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I need some of my relations to be indexed for easier access. Therefore i Use the following property annotation:
/** * @ORM\OneToMany(targetEntity="App\Entity\Category", mappedBy="parent", indexBy="slug") */ private $subcategories;
->getSubcategories()->toArray()
does return an array indexed with the slug. so it does work. but the serializer does respect that.
On the other hand, the serializer does respect it when I use doctrine directly via
$categories = $doctrine ->getRepository(Category::class) ->createQueryBuilder('c', 'c.slug');
My current solution is to not expose the property directly but use the dumbest virtualproperty ever:
/** * @return Collection * * @Serializer\VirtualProperty() * @Serializer\SerializedName("subcategories") * @Serializer\Expose() */ public function getSubCategoriesWithKey() { return $this->getSubcategories(); }
but that feels pretty silly :x
The text was updated successfully, but these errors were encountered:
I do not see any @Serializer\Type annotation in your snippets...
@Serializer\Type
You might need something as @Serializer\Type("ArrayCollection<string,App\Entity\Category>")
@Serializer\Type("ArrayCollection<string,App\Entity\Category>")
Sorry, something went wrong.
well. that fixed it. Thanks!
No branches or pull requests
I need some of my relations to be indexed for easier access. Therefore i Use the following property annotation:
->getSubcategories()->toArray()
does return an array indexed with the slug. so it does work. but the serializer does respect that.
On the other hand, the serializer does respect it when I use doctrine directly via
My current solution is to not expose the property directly but use the dumbest virtualproperty ever:
but that feels pretty silly :x
The text was updated successfully, but these errors were encountered: