Added:
- Refactor MangaScraperService (not used everywhere now) - Added JavascriptScraper.php - Added alternatives slugs in Manga.php - Improvement in manga edit form
This commit is contained in:
@@ -28,6 +28,10 @@ class ContentSourceType extends AbstractType
|
||||
'label' => 'Next Page Selector (let empty if vertical reader)',
|
||||
'required' => false,
|
||||
])
|
||||
->add('ChapterSelector', TextType::class, [
|
||||
'label' => 'Chapter Selector (required for Javascript scraping)',
|
||||
'required' => false,
|
||||
])
|
||||
->add('scrapingType', ChoiceType::class, [
|
||||
'label' => 'Scraping Type',
|
||||
'choices' => [
|
||||
|
||||
95
src/Form/MangaEditType.php
Normal file
95
src/Form/MangaEditType.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Manga;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class MangaEditType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('title', TextType::class, [
|
||||
'label' => 'Titre',
|
||||
'attr' => ['class' => 'w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500']
|
||||
])
|
||||
->add('slug', TextType::class, [
|
||||
'label' => 'Slug',
|
||||
'attr' => [
|
||||
'readonly' => true,
|
||||
'class' => 'bg-gray-100 w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500'
|
||||
],
|
||||
])
|
||||
->add('alternativeSlugs', CollectionType::class, [
|
||||
'entry_type' => TextType::class,
|
||||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
'by_reference' => false,
|
||||
'label' => false,
|
||||
'prototype' => true,
|
||||
'entry_options' => ['attr' => ['class' => 'w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500'], 'label' => false],
|
||||
'required' => false,
|
||||
])
|
||||
->add('publicationYear', NumberType::class, [
|
||||
'label' => 'Année de publication',
|
||||
'attr' => ['class' => 'w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500']
|
||||
])
|
||||
->add('description', TextareaType::class, [
|
||||
'label' => 'Description',
|
||||
'attr' => ['class' => 'w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500', 'rows' => 8]
|
||||
])
|
||||
->add('genres', CollectionType::class, [
|
||||
'entry_type' => TextType::class,
|
||||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
'by_reference' => false,
|
||||
'label' => 'Genres',
|
||||
'entry_options' => ['attr' => ['class' => 'w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500']],
|
||||
'required' => false,
|
||||
])
|
||||
->add('rating', NumberType::class, [
|
||||
'label' => 'Note',
|
||||
'attr' => ['class' => 'w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500'],
|
||||
'required' => false,
|
||||
])
|
||||
->add('author', TextType::class, [
|
||||
'label' => 'Auteur',
|
||||
'attr' => ['class' => 'w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500'],
|
||||
'required' => false,
|
||||
])
|
||||
->add('status', TextType::class, [
|
||||
'label' => 'Statut',
|
||||
'attr' => ['class' => 'w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500'],
|
||||
'required' => false,
|
||||
])
|
||||
;
|
||||
|
||||
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
|
||||
$data = $event->getData();
|
||||
$manga = $event->getForm()->getData();
|
||||
|
||||
if ($manga && $manga->getSlug()) {
|
||||
$data['slug'] = $manga->getSlug();
|
||||
}
|
||||
|
||||
$event->setData($data);
|
||||
});
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Manga::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user