|
|
@@ -19,23 +19,19 @@ class SubscriptionManager extends AbstractManager |
|
|
|
|
|
|
|
public function deleteProductInSubscriptionsIfUnavailableForSubscriptions(Product $product): void |
|
|
|
{ |
|
|
|
$messageFlashSubscriptionsWithProductDeleted = ''; |
|
|
|
$subscriptionsWithProductDeletedArray = []; |
|
|
|
if(!$product->is_available_for_subscriptions) { |
|
|
|
$subscriptionsArray = $this->subscriptionRepository->findSubscriptions(); |
|
|
|
|
|
|
|
foreach($subscriptionsArray as $subscription) { |
|
|
|
if($this->deleteProductUnavailableInSubscriptions($subscription, $product)) { |
|
|
|
$messageFlashSubscriptionsWithProductDeleted .= $this->subscriptionSolver->getUsername($subscription).', '; |
|
|
|
$subscriptionsWithProductDeletedArray[] = $subscription; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(strlen($messageFlashSubscriptionsWithProductDeleted)) { |
|
|
|
$messageFlashSubscriptionsWithProductDeleted = substr($messageFlashSubscriptionsWithProductDeleted, 0, strlen($messageFlashSubscriptionsWithProductDeleted) - 2); |
|
|
|
} |
|
|
|
|
|
|
|
if(strlen($messageFlashSubscriptionsWithProductDeleted) > 0) { |
|
|
|
\Yii::$app->session->addFlash('warning', 'Pour information, le produit a été supprimé des abonnements suivants : '.$messageFlashSubscriptionsWithProductDeleted); |
|
|
|
if(count($subscriptionsWithProductDeletedArray)) { |
|
|
|
\Yii::$app->session->addFlash('warning', 'Le produit a été supprimé des abonnements suivants : '.$this->subscriptionSolver->getSubscriptionsListAsHtml($subscriptionsWithProductDeletedArray)); |
|
|
|
} |
|
|
|
} |
|
|
|
|