-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
78 additions
and
1 deletion.
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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Product\AttributeType; | ||
|
||
use Sylius\Component\Attribute\AttributeType\AttributeTypeInterface; | ||
use Sylius\Component\Attribute\Model\AttributeValueInterface; | ||
use Symfony\Component\Validator\Context\ExecutionContextInterface; | ||
|
||
final class RangeAttributeType implements AttributeTypeInterface | ||
{ | ||
public const TYPE = 'range'; | ||
|
||
public function getStorageType(): string | ||
{ | ||
return AttributeValueInterface::STORAGE_JSON; | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return self::TYPE; | ||
} | ||
|
||
public function validate( | ||
AttributeValueInterface $attributeValue, | ||
ExecutionContextInterface $context, | ||
array $configuration, | ||
): void { | ||
return; | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Product\Form\Type; | ||
|
||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\NumberType; | ||
use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
final class RangeAttributeTypeType extends AbstractType | ||
{ | ||
public function buildForm(FormBuilderInterface $builder, array $options) | ||
{ | ||
$builder | ||
->add('min', NumberType::class, [ | ||
'label' => 'sylius.ui.min', | ||
]) | ||
->add('max', NumberType::class, [ | ||
'label' => 'sylius.ui.max', | ||
]) | ||
->add('unit', TextType::class, [ | ||
'label' => 'sylius.ui.unit', | ||
]) | ||
; | ||
} | ||
|
||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver | ||
->setDefaults([ | ||
'label' => false, | ||
]) | ||
->setRequired('configuration') | ||
->setDefined('locale_code') | ||
; | ||
} | ||
} |
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 @@ | ||
{{ attribute.value.min }} - {{ attribute.value.max }} {{ attribute.value.unit }} |