Пример #1
0
 public function resolve(FeatureInterface $previous)
 {
     $status = $previous->getStatus();
     if ($status === Status::INACTIVE || $this->status === Status::UNKNOWN || $status === $this->status) {
         return $previous;
     }
     return $this;
 }
 /**
  * @param FeatureInterface $value
  * @return FormFeature
  */
 public function transform($value)
 {
     if (!$value instanceof FeatureInterface) {
         throw new TransformationFailedException('Expected FeatureInterface');
     }
     $view = new FormFeature();
     $view->provider = $value->getProvider()->getName();
     $view->name = $value->getName();
     $view->status = $value->getStatus();
     $configuration = $value->getConfiguration();
     if (!empty($configuration['ratio']) && is_scalar($configuration['ratio'])) {
         $view->ratio = $configuration['ratio'];
     }
     return $view;
 }
Пример #3
0
 /**
  * Set the feature to the enclosed status, under the given context
  *
  * @param ContextInterface $context
  * @param FeatureInterface $feature
  * @return void
  */
 public function setFeature(ContextInterface $context, FeatureInterface $feature)
 {
     $this->bag->set($feature->getName(), $feature->getConfiguration());
     //$this->session->save();
 }
Пример #4
0
 /**
  * @param FeatureInterface $feature
  * @return array
  */
 public function toConfiguration(FeatureInterface $feature)
 {
     return $feature->getConfiguration();
 }
Пример #5
0
 /**
  * Given a feature, resolves a status, reports on it and returns it
  *
  * @param FeatureInterface $feature
  * @return bool|null
  */
 protected function returnStatusFromFeature(FeatureInterface $feature)
 {
     $status = $feature->getStatus();
     $this->logger->info('Feature {feature} returned as {status} due to {provider} provider', ['feature' => $feature->getName(), 'status' => Status::$messages[$status], 'provider' => $feature->getProvider()->getName()]);
     return $status;
 }
Пример #6
0
 /**
  * Conditionally marks a feature instance as canonical for a name
  *
  * @param FeatureInterface $feature
  */
 protected function storeToCanonical(FeatureInterface $feature)
 {
     $name = $feature->getName();
     $was = $this->getFeature($name);
     $new = $feature->resolve($was);
     $this->canonical[$name] = $new;
     if ($was !== $new) {
         $this->logger->debug('New canonical feature: {feature} from {provider}, {was} -> {new}', ['feature' => $name, 'provider' => $feature->getProvider()->getName(), 'was' => Status::$messages[$was->getStatus()], 'new' => Status::$messages[$this->canonical[$name]->getStatus()]]);
     }
 }
Пример #7
0
 public function setFeature(ContextInterface $context, FeatureInterface $feature)
 {
     $factory = new Factory();
     $this->persistConfiguration($context, $feature->getName(), $factory->toConfiguration($feature));
 }