-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Setono\SyliusAgeVerificationPlugin\EventSubscriber\Admin; | ||
|
||
use Sylius\Bundle\AdminBundle\Event\ProductMenuBuilderEvent; | ||
use Sylius\Bundle\AdminBundle\Menu\ProductFormMenuBuilder; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
final class AddAgeVerificationTabSubscriber implements EventSubscriberInterface | ||
{ | ||
public static function getSubscribedEvents(): array | ||
Check failure on line 13 in src/EventSubscriber/Admin/AddAgeVerificationTabSubscriber.php GitHub Actions / Static Code Analysis (PHP8.1 | Deps: highest | SF~6.4.0)MixedReturnTypeCoercion
Check failure on line 13 in src/EventSubscriber/Admin/AddAgeVerificationTabSubscriber.php GitHub Actions / Static Code Analysis (PHP8.2 | Deps: highest | SF~6.4.0)MixedReturnTypeCoercion
|
||
{ | ||
return [ | ||
Check failure on line 15 in src/EventSubscriber/Admin/AddAgeVerificationTabSubscriber.php GitHub Actions / Static Code Analysis (PHP8.1 | Deps: highest | SF~6.4.0)MixedArrayOffset
Check failure on line 15 in src/EventSubscriber/Admin/AddAgeVerificationTabSubscriber.php GitHub Actions / Static Code Analysis (PHP8.1 | Deps: highest | SF~6.4.0)MixedReturnTypeCoercion
Check failure on line 15 in src/EventSubscriber/Admin/AddAgeVerificationTabSubscriber.php GitHub Actions / Static Code Analysis (PHP8.2 | Deps: highest | SF~6.4.0)MixedArrayOffset
Check failure on line 15 in src/EventSubscriber/Admin/AddAgeVerificationTabSubscriber.php GitHub Actions / Static Code Analysis (PHP8.2 | Deps: highest | SF~6.4.0)MixedReturnTypeCoercion
|
||
ProductFormMenuBuilder::EVENT_NAME => 'addTab', | ||
Check failure on line 16 in src/EventSubscriber/Admin/AddAgeVerificationTabSubscriber.php GitHub Actions / Static Code Analysis (PHP8.1 | Deps: highest | SF~6.4.0)UndefinedClass
Check failure on line 16 in src/EventSubscriber/Admin/AddAgeVerificationTabSubscriber.php GitHub Actions / Static Code Analysis (PHP8.2 | Deps: highest | SF~6.4.0)UndefinedClass
|
||
]; | ||
} | ||
|
||
public function addTab(ProductMenuBuilderEvent $event): void | ||
Check failure on line 20 in src/EventSubscriber/Admin/AddAgeVerificationTabSubscriber.php GitHub Actions / Static Code Analysis (PHP8.1 | Deps: highest | SF~6.4.0)UndefinedClass
Check failure on line 20 in src/EventSubscriber/Admin/AddAgeVerificationTabSubscriber.php GitHub Actions / Static Code Analysis (PHP8.2 | Deps: highest | SF~6.4.0)UndefinedClass
|
||
{ | ||
$event->getMenu() | ||
->addChild('age_verification') | ||
->setAttribute('template', '@SetonoSyliusAgeVerificationPlugin/admin/product/tab/_age_verification.html.twig') | ||
->setLabel('setono_sylius_age_verification.ui.age_verification') | ||
; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Setono\SyliusAgeVerificationPlugin\Form\Extension; | ||
|
||
use Sylius\Bundle\ProductBundle\Form\Type\ProductType; | ||
use Symfony\Component\Form\AbstractTypeExtension; | ||
use Symfony\Component\Form\Extension\Core\Type\IntegerType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
final class ProductTypeExtension extends AbstractTypeExtension | ||
{ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder->add('minimumAge', IntegerType::class, [ | ||
'label' => 'setono_sylius_age_verification.form.product.minimum_age', | ||
'required' => false, | ||
]); | ||
} | ||
|
||
public static function getExtendedTypes(): \Generator | ||
{ | ||
yield ProductType::class; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
setono_sylius_age_verification: | ||
form: | ||
product: | ||
minimum_age: Minimum age | ||
ui: | ||
age_verification: Age verification |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="ui tab" data-tab="age_verification"> | ||
<h3 class="ui top attached header">{{ 'setono_sylius_age_verification.ui.age_verification'|trans }}</h3> | ||
|
||
<div class="ui attached segment"> | ||
{{ form_row(form.minimumAge) }} | ||
</div> | ||
</div> |