protected function persistEntities($propertyValue)
{
if (!$propertyValue instanceof \Iterator && !is_array($propertyValue)) {
$propertyValue = array($propertyValue);
}
foreach ($propertyValue as $possibleEntity) {
if (is_object($possibleEntity) && $possibleEntity instanceof PersistenceMagicInterface) {
$this->persistenceManager->isNewObject($possibleEntity) ? $this->persistenceManager->add($possibleEntity) : $this->persistenceManager->update($possibleEntity);
// TODO: Needed because the originalAsset will not cascade persist. We should find a generic solution to this.
if ($possibleEntity instanceof ImageVariant) {
$asset = $possibleEntity->getOriginalAsset();
$this->persistenceManager->isNewObject($asset) ? $this->persistenceManager->add($asset) : $this->persistenceManager->update($asset);
}
}
}
}