public function preSetData(FormEvent $event)
{
$resource = $event->getData();
$disabled = false;
if ($resource instanceof CodeAwareInterface) {
$disabled = null !== $resource->getCode();
} elseif (null !== $resource) {
throw new UnexpectedTypeException($resource, CodeAwareInterface::class);
}
$form = $event->getForm();
$form->add('code', $this->type, array_merge(['label' => 'sylius.ui.code'], $this->options, ['disabled' => $disabled]));
}