Answer the question
In order to leave comments, you need to log in
Do I need to delete temporary variables in the hydrator?
If you need to hydrate many objects, do you need to delete variables?
public function hydrate(array $data, $object)
{
if (!$object instanceof PostInterface) {
return $object;
}
$tagString = $data['tagsString'];
if (empty($tagString)) {
return $object;
}
$tags = explode(",", $tagString);
$itemList = $object->getTags();
$item = $itemList->offsetGet(0);
for($i=0, $countTags = count($tags); $i < $countTags; $i++)
{
parent::hydrate(array('title' => $tags[$i]), $tagClone = clone $item);
$itemList->offsetSet($i, $tagClone);
}
unset($itemList);
unset($tagClone);
unset($item);
unset($countTags);
unset($tags);
unset($tagString);
return $object;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question