-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ButtonTypeExtension to lower default priority
- Loading branch information
1 parent
1aed3ee
commit be42bf8
Showing
4 changed files
with
68 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Siganushka\GenericBundle\Form\Extension; | ||
|
||
use Symfony\Component\Form\AbstractTypeExtension; | ||
use Symfony\Component\Form\Extension\Core\Type\ButtonType; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
class ButtonTypeExtension extends AbstractTypeExtension | ||
{ | ||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver->setDefault('priority', -16); | ||
} | ||
|
||
public static function getExtendedTypes(): iterable | ||
{ | ||
return [ | ||
ButtonType::class, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Siganushka\GenericBundle\Tests\Form\Extension; | ||
|
||
use Siganushka\GenericBundle\Form\Extension\ButtonTypeExtension; | ||
use Symfony\Component\Form\Extension\Core\Type\ButtonType; | ||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | ||
use Symfony\Component\Form\Test\TypeTestCase; | ||
|
||
class ButtonTypeExtensionTest extends TypeTestCase | ||
{ | ||
public function testAll(): void | ||
{ | ||
$button = $this->factory->create(ButtonType::class); | ||
$submit = $this->factory->create(SubmitType::class); | ||
|
||
$buttonView = $button->createView(); | ||
$submitView = $submit->createView(); | ||
static::assertSame(-16, $buttonView->vars['priority']); | ||
static::assertSame(-16, $submitView->vars['priority']); | ||
} | ||
|
||
protected function getTypeExtensions(): array | ||
{ | ||
return [ | ||
new ButtonTypeExtension(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters