/**
     * read config in db configured in Symfony BO
     *
     * @param $featureCode
     * @param $value
     *
     * @return mixed
     */
    public static function feature($featureCode, $value)
    {
        if(eZINI::instance()->hasVariable("Environment", "Type"))
            $env = eZINI::instance()->variable("Environment", "Type");
        else
            $env = "dev";

        $featureLocalized = CacheFeatureTool::getFeatureLocalizedByCode($featureCode);

        if(!$featureLocalized)
            return false;

        $features = $featureLocalized->getParameter($value);
        if(!$features)
            return false;

        $featureDefinition = $featureLocalized->featureDefinition();
        $definition = $featureDefinition->getValuesDefinition($value);

        if($definition["envDependent"])
            return $features[$env];
        else
            return $features;
    }
) );


$options = $script->getOptions( "[clusterIdentifier:]", "", array(
    'clusterIdentifier' => 'Cluster identifier',
) );

$script->startup();
$script->initialize();

$clusters = array();
if( $options['clusterIdentifier'] )
{
    $clusters = array( $options['clusterIdentifier'] );
}
else 
{
    foreach( glob( 'extension/cluster_*') as $f )
        $clusters[] = basename( $f );
}


foreach( $clusters as $clusterIdentifier )
{
    $cli->output("generating feature cache for $clusterIdentifier");
    ClusterTool::setCurrentCluster( $clusterIdentifier );
    CacheFeatureTool::buildClusterFeatures();
    ClusterTool::resetCurrentCluster();
}

$script->shutdown();
    /**
     * @param string $featureCode
     * @param bool $force
     * @param bool $store
     * @return FeatureLocalized
     */
    public static function getFeatureLocalizedByCode($featureCode, $force = false, $store = true)
    {
        if(!$featureCode)
            return null;

        if ( !$force )
        {
            $featureLocalized = CacheFeatureTool::getValue('featureLocalizedByCode', $featureCode);

            if (!is_null($featureLocalized))
            {
                return $featureLocalized;
            }
        }

        if ( $force || !($featureLocalized instanceof FeatureLocalized))
        {
            $featureDefinition = FeatureDefinition::getFeatureDefintion($featureCode);
            if ($featureDefinition instanceof FeatureDefinition)
            {
                $featureLocalized = FeatureLocalized::getLocalizedFeatureByDefinitionId(
                    $featureDefinition->attribute('id')
                );
                if ($featureLocalized instanceof FeatureLocalized)
                {
                    self::buildCache($featureLocalized, $store);

                    return $featureLocalized;
                }
            }
        }

        return null;
    }
 /**
  *
  * @param string $user Usually get from MMUsers::getCurrentUserObject() function
  */
 protected function getSubsForOptin($user) {
     if( $user && SolrSafeOperatorHelper::featureIsActive('newsletterPopin') ) {
         if (SolrSafeOperatorHelper::featureIsActive('UUMP')) {
             // not yet activated for UUMP clusters
             //$instance = new ServiceUserUUMP();
         }
         else {
             $instance = new ServiceUser();
             $userSubs = $instance->subsread();
             $userSubs = $userSubs['Data']['Subs'];
             $toCheck = array();
             $subs = json_decode(CacheFeatureTool::getFeatureLocalizedByCode('newsletterPopin')->parameters, true);
             foreach ( $subs as $key => $value ) {
                 if ( $value ) {
                     $toCheck[] = $key;
                 }
             }
             $filteredSubs = array();
             if(is_array($userSubs)){
                 foreach ( $userSubs as $key => $value ) {
                     $filteredSubs[] = $value['offerId'];
                 }
             }
             $listOfChecks = array();
             if ( !empty($toCheck) ) {
                 foreach ( $toCheck as $value ) {
                     if ( !in_array( $value, $filteredSubs ) && $value != "daysToCheck" ){
                         $listOfChecks[] = $value;
                     }
                 }
             }
             if (!empty($listOfChecks)) {
                 eZSession::set('listOfChecks', $listOfChecks);
             }
         }
     }
 }