Skip to content

Commit

Permalink
add satis config options abandoned and blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
ramunasd committed Dec 10, 2022
1 parent 4e03248 commit 7e2a472
Show file tree
Hide file tree
Showing 12 changed files with 477 additions and 13 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"laminas/laminas-diactoros": "^2.3",
"symfony/monolog-bundle": "^3.8",
"symfony/dependency-injection": "^5.4",
"symfony/event-dispatcher": "^5.4"
"symfony/event-dispatcher": "^5.4",
"symfony/proxy-manager-bridge": "^6.0"
},
"require-dev": {
"mikey179/vfsstream": "^1.6",
Expand Down
228 changes: 221 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions src/Playbloom/Satisfy/Form/Type/AbandonedType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Playbloom\Satisfy\Form\Type;

use Playbloom\Satisfy\Model\Abandoned;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;

class AbandonedType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add(
'package',
TextType::class,
[
'required' => true,
'empty_data' => '',
'constraints' => [
new Assert\NotBlank(),
],
'attr' => [
'placeholder' => 'Abandoned package name',
],
]
)
->add('replacement', TextType::class, [
'required' => true,
'empty_data' => '',
'attr' => [
'placeholder' => 'Package name/URL pointing to a recommended alternative(can be empty)',
],
]);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Abandoned::class,
'empty_data' => new Abandoned('', null),
]);
}

public function getBlockPrefix()
{
return 'AbandonedType';
}
}
33 changes: 33 additions & 0 deletions src/Playbloom/Satisfy/Form/Type/ConfigurationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Playbloom\Satisfy\Form\Type;

use Playbloom\Satisfy\Form\DataTransformer\JsonTextTransformer;
use Playbloom\Satisfy\Model\Abandoned;
use Playbloom\Satisfy\Model\Configuration;
use Playbloom\Satisfy\Model\PackageStability;
use Symfony\Component\Form\AbstractType;
Expand Down Expand Up @@ -57,6 +58,38 @@ public function buildForm(FormBuilderInterface $builder, array $options)
new Assert\Valid(),
],
])
->add('blacklist', CollectionType::class, [
'required' => false,
'allow_add' => true,
'allow_delete' => true,
'delete_empty' => true,
'entry_type' => PackageConstraintType::class,
'prototype' => true,
'attr' => [
'class' => 'collection_require',
'rel' => 'tooltip',
'data-title' => 'Package name (keys) and version constraints (values) to exclude after selecting packages',
],
'constraints' => [
new Assert\Valid(),
],
])
->add('abandoned', CollectionType::class, [
'required' => false,
'allow_add' => true,
'allow_delete' => true,
'delete_empty' => true,
'entry_type' => AbandonedType::class,
'prototype' => true,
'attr' => [
'class' => 'collection_require',
'rel' => 'tooltip',
'data-title' => 'List of packages marked as abandoned for this repository',
],
'constraints' => [
new Assert\Valid(),
],
])
->add('requireAll', Type\CheckboxType::class, [
'required' => false,
'attr' => [
Expand Down
Loading

0 comments on commit 7e2a472

Please sign in to comment.