mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°8771 - Add Symfony form component to iTop core
- IO
This commit is contained in:
30
sources/Forms/FormBuilder/FormHelper.php
Normal file
30
sources/Forms/FormBuilder/FormHelper.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Forms\FormBuilder;
|
||||
|
||||
use Symfony\Component\Form\Event\PostSetDataEvent;
|
||||
use Symfony\Component\Form\Event\PostSubmitEvent;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
|
||||
class FormHelper
|
||||
{
|
||||
/**
|
||||
* Get the event type.
|
||||
*
|
||||
* @param FormEvent $event
|
||||
*
|
||||
* @return string
|
||||
* @throws FormBuilderException
|
||||
*/
|
||||
public static function GetEventType(FormEvent $event): string
|
||||
{
|
||||
if ($event instanceof PostSetDataEvent) {
|
||||
return FormEvents::POST_SET_DATA;
|
||||
} else if ($event instanceof PostSubmitEvent) {
|
||||
return FormEvents::POST_SUBMIT;
|
||||
}
|
||||
|
||||
throw new FormBuilderException(sprintf('Unknown event type %s', get_class($event)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user