示例#1
0
 /**
  * @param ContextInterface $context
  * @return FeatureInterface[]
  */
 public function getFeatures(ContextInterface $context)
 {
     $factory = new Factory();
     $features = $factory->fromConfiguration($this->getConfiguration(), $this);
     foreach ($features as $feature) {
         $feature->context($context);
     }
     return $features;
 }
 /**
  * @param FormFeature $value
  * @return \Pheat\Feature\FeatureInterface
  */
 public function reverseTransform($value)
 {
     if (!$value instanceof FormFeature) {
         throw new TransformationFailedException('Invalid form feature');
     }
     $provider = $this->manager->getProvider($value->provider);
     if (!$provider) {
         throw new TransformationFailedException('Invalid provider name');
     }
     $factory = new Factory();
     $feature = $factory->singleFragment($value->name, ['enabled' => $value->status, 'ratio' => $value->ratio, 'variants' => $value->variants], $provider);
     if (!$feature) {
         throw new TransformationFailedException('Invalid configuration fragment');
     }
     return $feature;
 }
示例#3
0
 public function setFeature(ContextInterface $context, FeatureInterface $feature)
 {
     $factory = new Factory();
     $this->persistConfiguration($context, $feature->getName(), $factory->toConfiguration($feature));
 }