Skip to content

Commit

Permalink
Adjust interfaces to check on
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandoorn committed Feb 1, 2021
1 parent c93f2a2 commit d16a3f0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace StefanDoorn\SyliusStreetNumberPlugin\Form\EventSubscriber;

use StefanDoorn\SyliusStreetNumberPlugin\Entity\Interfaces\AddressInterface;
use StefanDoorn\SyliusStreetNumberPlugin\Entity\Interfaces\StreetNumberAwareInterface;
use Sylius\Component\Core\Model\AddressInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
Expand All @@ -20,10 +21,10 @@ public static function getSubscribedEvents(): array

public function onPostSubmit(FormEvent $event): void
{
/** @var AddressInterface $data */
/** @var StreetNumberAwareInterface|AddressInterface $data */
$data = $event->getData();

if (!$data instanceof AddressInterface) {
if (!$data instanceof StreetNumberAwareInterface) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace StefanDoorn\SyliusStreetNumberPlugin\Form\EventSubscriber;

use StefanDoorn\SyliusStreetNumberPlugin\Entity\Interfaces\AddressInterface;
use StefanDoorn\SyliusStreetNumberPlugin\Entity\Interfaces\StreetNumberAwareInterface;
use Sylius\Component\Core\Model\AddressInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
Expand All @@ -20,7 +21,7 @@ public static function getSubscribedEvents(): array

public function onPreSetData(FormEvent $event): void
{
/** @var AddressInterface $data */
/** @var StreetNumberAwareInterface|AddressInterface $data */
$data = $event->getData();

if (!$data instanceof AddressInterface) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder->addEventSubscriber($this->removeDuplicateAdditionEventSubscriber);
}

public function getExtendedType()
public static function getExtendedTypes(): array
{
return AddressType::class;
return [AddressType::class];
}
}
4 changes: 2 additions & 2 deletions src/Form/Extension/AddressTypeStreetNumberExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder->addEventSubscriber($this->appendNumberDataToStreetFieldEventSubscriber);
}

public function getExtendedType()
public static function getExtendedTypes(): array
{
return AddressType::class;
return [AddressType::class];
}
}

0 comments on commit d16a3f0

Please sign in to comment.