fix: separates preference options from db to files
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
namespace App\User\Framework\Form;
|
||||
|
||||
use Aimeos\Map;
|
||||
use App\User\Database\CodecList;
|
||||
use App\User\Database\CountryLanguages;
|
||||
use App\User\Database\ProviderList;
|
||||
use App\User\Database\QualityList;
|
||||
use App\User\Database\ResolutionList;
|
||||
use App\User\Framework\Repository\PreferenceOptionRepository;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
@@ -17,7 +19,6 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
class UserMediaPreferencesForm extends AbstractType
|
||||
{
|
||||
public function __construct(
|
||||
private readonly PreferenceOptionRepository $preferenceOptionRepository,
|
||||
private readonly UrlGeneratorInterface $urlGenerator,
|
||||
) {}
|
||||
|
||||
@@ -26,8 +27,8 @@ class UserMediaPreferencesForm extends AbstractType
|
||||
$this->addChoiceField($builder, 'language', CountryLanguages::asSelectOptions());
|
||||
$this->addChoiceField($builder, 'quality', QualityList::asSelectOptions());
|
||||
$this->addChoiceField($builder, 'provider', ProviderList::asSelectOptions());
|
||||
$this->addChoiceField($builder, 'resolution', $this->getPreferenceChoices('resolution'));
|
||||
$this->addChoiceField($builder, 'codec', $this->getPreferenceChoices('codec'));
|
||||
$this->addChoiceField($builder, 'resolution', ResolutionList::asSelectOptions());
|
||||
$this->addChoiceField($builder, 'codec', CodecList::asSelectOptions());
|
||||
}
|
||||
|
||||
private function addChoiceField(FormBuilderInterface $builder, string $fieldName, array $choices): void
|
||||
@@ -48,16 +49,6 @@ class UserMediaPreferencesForm extends AbstractType
|
||||
]);
|
||||
}
|
||||
|
||||
private function getPreferenceChoices(string $preference): array
|
||||
{
|
||||
$options = $this->preferenceOptionRepository->findBy(['preference' => $preference]);
|
||||
$result = [];
|
||||
foreach ($options as $item) {
|
||||
$result[$item->getName()] = $item->getId();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function addDefaultChoice(array $choices): iterable
|
||||
{
|
||||
return ['n/a' => ''] + $choices;
|
||||
|
||||
Reference in New Issue
Block a user