-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
/**
* Calculates the bitmask of the boolean features selected
* by the merchant and returns the corresponding value in binary format.
*
* @return int
*/
protected function calculatePlanId(PremiumStoreEmbeddable $features, array $options)
{
// No feature is selected
$booleanBitmask = 0;
$amount = 0;
if ($features->hasAds()) {
$amount += $this->plans['boolean']['ads']['price'][$options['currency']][$options['interval']];
$booleanBitmask += PremiumStoreEmbeddable::ADS;
}
if ($features->hasSeo()) {
$amount += $this->plans['boolean']['seo']['price'][$options['currency']][$options['interval']];
$booleanBitmask += PremiumStoreEmbeddable::SEO;
}
if ($features->hasSocial()) {
$amount += $this->plans['boolean']['social']['price'][$options['currency']][$options['interval']];
$booleanBitmask += PremiumStoreEmbeddable::SOCIAL;
}
$booleanBitmask = decbin($booleanBitmask);
return
$booleanBitmask
. '_' . $options['interval']
. '_' . $options['trial_period_days']
. '_' . $options['currency']
. '_' . $amount;
}
/**
* Sets the general configurations (as prices, for examples) in the FeatureInterface objects loaded from a
* SubscriptionInterface object.
*/
private function configurePricesInSubscriptionFeatures(SubscriptionInterface $subscription)
{
/** @var FeatureInterface $feature *
foreach ($subscription->getFeatures() as $feature) {
$prices = $this->getConfiguredFeatures()->get($feature->getName())->getPrices();
$feature->setPrices($prices);
}
}This code once was in SerendipityHQ\Bundle\FeaturesBundle\Service\FeaturesManager.
Removed because it causes troubles when applying Rector and PHP CS Fixer.