Answer the question
In order to leave comments, you need to log in
How to remove redundant information from $entity returned by Doctrine2, Symfony?
I have a Product entity which is related to another entity by a relationship
/**
* @ORM\ManyToOne(targetEntity="\бла\бла\Entity\Brand")
*/
protected $brand;
$entities = $entityManager->getRepository('бла бла\Product')->findBy(
$filters,
$orderBy,
$limit,
$offset
);
{
"id": 178,
"sku": "ART9870",
"barcode": "66075392",
"supply_price": {
}
"sell_price": {
}
"properties": {
}
"company": {
}
"brand": {
"id": 632,
"name": "Waelchi, Will and Reinger",
"property_dictionaries": [
{
"name": "velit",
"value_list": [
"error",
"enim",
"aliquid",
"enim",
"suscipit",
"inventore",
"minima",
"aperiam",
"quia",
"officiis"
]
"position": 0,
"id": 1252
}
{
"name": "et",
"value_list": [
"molestiae",
"saepe",
"provident",
"voluptas",
"numquam",
"et",
"harum",
"nemo",
"ut",
"facilis"
]
"position": 1,
"id": 1254
}
]
"company": {
"id": 316,
"name": "Kilback, Gislason and Swift"
}
}
}
Answer the question
In order to leave comments, you need to log in
depending on how you serialize the data. In any case, you can always just go around everything through map in some method. in combination with lazy data loading, you can do this even without much overhead
Look at Partial objects .
Or, if your task allows, use DBAL instead of ORM - only the requested data will be returned to you in the form of an array, without associated objects (well, unless you explicitly specify them in SQL). In general, DBAL is the ability to simply execute any SQL query, without being tied to entities.
So when querying a product like this:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question