You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
privatefunctionvalidateRecurringPrice(string$set, string$feature, array$price): void
{
// If emmpty, may be because it doesn't exist and the TreeBuilder created it as an empty array, else...if (false === empty($price)) {
// ... It contains Currency codes: validate each one of them and their subscription periodsforeach ($priceas$currency => $subscriptions) {
// Validate the currency$this->validateCurrency($set, $feature, $currency);
// Validate the subscription periods$this->validateSubscriptionPeriods($set, $feature, $currency, $subscriptions);
}
}
}
to
privatefunctionvalidateRecurringPrice(string$set, string$feature, array$price): void
{
if (empty($price)) {
thrownewInvalidConfigurationException(\Safe\sprintf("You MUST set a price for %s.features.%s.", $set, $feature));
}
// ... It contains Currency codes: validate each one of them and their subscription periodsforeach ($priceas$currency => $subscriptions) {
// Validate the currency$this->validateCurrency($set, $feature, $currency);
// Validate the subscription periods$this->validateSubscriptionPeriods($set, $feature, $currency, $subscriptions);
}
}
from
privatefunction processPackages(array$packs, $subscriptionType)
{
$subscriptionHasFreePackage = false;
foreach ($packsas$numOfUnits => $prices) {
switch ($subscriptionType) {
caseself::RECURRING:
$packs[$numOfUnits] = $this->processRecurringPrice($prices);
// If this is a free packageif (empty($prices)) {
// We have a free package so we haven't to create it$subscriptionHasFreePackage = true;
}
break;
caseself::UNATANTUM:
$packs[$numOfUnits] = $this->processUnatantumPrice($prices);
break;
}
}
// If we are processing a recurring feature that hasn't a free package...if (self::RECURRING === $subscriptionType && false === $subscriptionHasFreePackage) {
// ... We have to create it with 0 $numOfUnits as we always need a free package for a subscribed feature$packs[0] = [];
}
$packs['_pricesType'] = $this->pricesType;
return$packs;
to
privatefunction processPackages(array$packs, $subscriptionType)
{
$subscriptionHasFreePackage = false;
foreach ($packsas$numOfUnits => $prices) {
switch ($subscriptionType) {
caseself::RECURRING:
$packs[$numOfUnits] = $this->processRecurringPrice($prices);
// If this is a free packageif (empty($prices)) {
// We have a free package so we haven't to create it$subscriptionHasFreePackage = true;
}
break;
caseself::UNATANTUM:
$packs[$numOfUnits] = $this->processUnatantumPrice($prices);
break;
}
}
$packs['_pricesType'] = $this->pricesType;
return$packs;
Also, understand why we always need a free package for subscribed features.
The text was updated successfully, but these errors were encountered:
Currently it is possible to set a free plan with this config:
This causes an empty array in the config that causes a lot of troubles in the code because we have to deal with an empty array.
What to do
Do not allow an empty configuration. Instead, require an explicit configuration set to 0:
v0.12.0
SerendipityHQ\Bundle\FeaturesBundle\DependencyInjection\Configuration
not allow an empty configConfiguration.php
from
to
from
to
Also, understand why we always need a free package for subscribed features.
The text was updated successfully, but these errors were encountered: