You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classDesignBatchDeleteDataTransformerimplementsDataTransformerInterface
{
publicfunctiontransform($object, string$to, array$context = [])
{
$this->validator->validate($object);
$em = $this->entityManager;
$idList = $object->ids;
if (!isset($idList[0])) {
thrownewBadRequestHttpException('selection of "design" is required');
}
if (preg_match('/design/', $idList[0])) {
thrownewBadRequestHttpException('submit id instead of @id');
}
$idsExplode = implode("','", $idList);
$q = $this->entityManager->createQuery("SELECT d FROM $to d WHERE d.id IN('$idsExplode')");
$batchSize = 20;
$i = 1;
foreach ($q->toIterable() as$design) {
/** @var Design $design */$test = $this->validator->validate($design);
$em->remove($design);
if (($i % $batchSize) === 0) {
$em->flush(); // Executes all updates.$em->clear(); // Detaches all objects from Doctrine!
}
++$i;
}
$this->entityManager->flush();
}
publicfunctionsupportsTransformation($data, string$to, array$context = []): bool
{
return$context['input']['class'] === DesignBatchDeleteInput::class&&is_array($data);
}
}
but it seems like there are unnecessary populations in the context[object_to_populate]
how to get rid of them?
I am using a custom filter, for now, that returns nothing, but it dependes on the front-end for it
also, I am applying filters in the request and get the correct object_to_populate array of data and after that for each of object_to_populate I filter user input and serialize but the relation serialization is not nice
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello
I am implementing batch update/delete actions ,I am dealing with around 100 updates per request so I decided to go for it
but it seems like there are unnecessary populations in the context[object_to_populate]
how to get rid of them?
I am using a custom filter, for now, that returns nothing, but it dependes on the front-end for it
also, I am applying filters in the request and get the correct object_to_populate array of data and after that for each of object_to_populate I filter user input and serialize but the relation serialization is not nice
and there is a trait in the entity
is there a nicer way to serialize dto or batch update?
Beta Was this translation helpful? Give feedback.
All reactions