/**
  * @param EntryDistribution $entryDistribution
  * @param entry $entry
  * @param DistributionProfile $distributionProfile
  * @return boolean true if the list of flavors modified
  */
 public static function assignFlavorAssets(EntryDistribution $entryDistribution, entry $entry, DistributionProfile $distributionProfile)
 {
     $submittingStatuses = array(EntryDistributionStatus::PENDING, EntryDistributionStatus::QUEUED, EntryDistributionStatus::SUBMITTING, EntryDistributionStatus::IMPORT_SUBMITTING, EntryDistributionStatus::ERROR_SUBMITTING);
     // if not in first submmiting status then it's an update and need to check if update is supported.
     if (!in_array($entryDistribution->getStatus(), $submittingStatuses)) {
         $distributionProvider = $distributionProfile->getProvider();
         if (!$distributionProvider) {
             KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] provider not found");
             return false;
         }
         if (!$distributionProvider->isUpdateEnabled() || !$distributionProvider->isMediaUpdateEnabled()) {
             KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] provider [" . $distributionProvider->getName() . "] does not support update");
             return false;
         }
     }
     $requiredFlavorParamsIds = $distributionProfile->getRequiredFlavorParamsIdsArray();
     $optionalFlavorParamsIds = $distributionProfile->getOptionalFlavorParamsIdsArray();
     $flavorParamsIds = array_merge($requiredFlavorParamsIds, $optionalFlavorParamsIds);
     $flavorAssetIds = array();
     if (!is_array($flavorParamsIds)) {
         return false;
     }
     $originalList = $entryDistribution->getFlavorAssetIds();
     // remove deleted flavor assets
     if ($originalList) {
         $assignedFlavorAssetIds = explode(',', $originalList);
         $assignedFlavorAssets = assetPeer::retrieveByIds($assignedFlavorAssetIds);
         foreach ($assignedFlavorAssets as $assignedFlavorAsset) {
             if (in_array($assignedFlavorAsset->getFlavorParamsId(), $flavorParamsIds)) {
                 $flavorAssetIds[] = $assignedFlavorAsset->getId();
             }
         }
     }
     // adds added flavor assets
     $newFlavorAssetIds = assetPeer::retrieveReadyFlavorsIdsByEntryId($entry->getId(), $flavorParamsIds);
     foreach ($newFlavorAssetIds as $newFlavorAssetId) {
         $flavorAssetIds[] = $newFlavorAssetId;
     }
     $entryDistribution->setFlavorAssetIds($flavorAssetIds);
     return $originalList != $entryDistribution->getFlavorAssetIds();
 }
 /**
  * @param EntryDistribution $entryDistribution
  * @param entry $entry
  * @param DistributionProfile $distributionProfile
  * @return boolean true if the list of flavors modified
  */
 public static function assignFlavorAssets(EntryDistribution $entryDistribution, entry $entry, DistributionProfile $distributionProfile)
 {
     $requiredFlavorParamsIds = $distributionProfile->getRequiredFlavorParamsIdsArray();
     $optionalFlavorParamsIds = $distributionProfile->getRequiredFlavorParamsIdsArray();
     $flavorParamsIds = array_merge($requiredFlavorParamsIds, $optionalFlavorParamsIds);
     $flavorAssetIds = array();
     if (!is_array($flavorParamsIds)) {
         return false;
     }
     $originalList = $entryDistribution->getFlavorAssetIds();
     // remove deleted flavor assets
     if ($originalList) {
         $assignedFlavorAssetIds = explode(',', $originalList);
         $assignedFlavorAssets = flavorAssetPeer::retrieveByIds($assignedFlavorAssetIds);
         foreach ($assignedFlavorAssets as $assignedFlavorAsset) {
             if (in_array($assignedFlavorAsset->getFlavorParamsId(), $flavorParamsIds)) {
                 $flavorAssetIds[] = $assignedFlavorAsset->getId();
             }
         }
     }
     // adds added flavor assets
     $newFlavorAssetIds = flavorAssetPeer::getReadyIdsByParamsIds($entry->getId(), $flavorParamsIds);
     foreach ($newFlavorAssetIds as $newFlavorAssetId) {
         $flavorAssetIds[] = $newFlavorAssetId;
     }
     $entryDistribution->setFlavorAssetIds($flavorAssetIds);
     return $originalList != $entryDistribution->getFlavorAssetIds();
 }