/** * @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; }
/** * 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; }
/** * 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()]]); } }