Permalink
Browse files

switch to new ::class constant

  • Loading branch information...
flack committed Oct 7, 2017
1 parent ee591a0 commit 0bd878d8e992f7e4d5905fe64d127b83e6fa1519
@@ -7,6 +7,7 @@
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
/**
* Experimental extension class
@@ -25,6 +26,6 @@ public function configureOptions(OptionsResolver $resolver)
public function getExtendedType()
{
return compat::get_type_name('button');
return ButtonType::class;
}
}
@@ -6,9 +6,7 @@
namespace midcom\datamanager\extension;
/**
* Typename converter
*
* (on PHP 5.5+, this could be replaced by use statements & CLASS constants in the caller)
* Typename converter for short type names from old DM2 style schemas
*/
class compat
{
@@ -9,6 +9,7 @@
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\FormType;
/**
* Experimental extension class
@@ -49,6 +50,6 @@ public function buildView(FormView $view, FormInterface $form, array $options)
public function getExtendedType()
{
return compat::get_type_name('form');
return FormType::class;
}
}
@@ -19,7 +19,9 @@
use midcom_connection;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use midcom\datamanager\extension\compat;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SearchType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
/**
* Experimental autocomplete type
@@ -83,14 +85,14 @@ public function configureOptions(OptionsResolver $resolver)
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addModelTransformer(new transformer($options));
$builder->add('selection', compat::get_type_name('hidden'));
$builder->add('selection', HiddenType::class);
$builder->get('selection')->addViewTransformer(new jsontransformer);
if ($options['type_config']['allow_multiple'] && $options['dm2_type'] == 'select') {
$builder->get('selection')->addModelTransformer(new multipletransformer($options));
}
$builder->add('search_input', compat::get_type_name('search'), ['mapped' => false]);
$builder->add('search_input', SearchType::class, ['mapped' => false]);
$head = midcom::get()->head;
$head->add_stylesheet(MIDCOM_STATIC_URL . '/midcom.datamanager/autocomplete.css');
@@ -152,6 +154,6 @@ public function getBlockPrefix()
*/
public function getParent()
{
return compat::get_type_name('form');
return FormType::class;
}
}
@@ -8,7 +8,9 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use midcom\datamanager\extension\transformer\blobs as transformer;
use midcom\datamanager\extension\compat;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
/**
* Experimental attachment type
@@ -20,9 +22,9 @@ class blobs extends AbstractType
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('title', compat::get_type_name('text'));
$builder->add('file', compat::get_type_name('file'), ['required' => false]);
$builder->add('identifier', compat::get_type_name('hidden'));
$builder->add('title', TextType::class);
$builder->add('file', FileType::class, ['required' => false]);
$builder->add('identifier', HiddenType::class);
$builder->addViewTransformer(new transformer($options));
}
@@ -13,7 +13,6 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use midcom\datamanager\extension\helper;
use midcom\datamanager\extension\compat;
use midcom\datamanager\validation\php;
/**
@@ -122,6 +121,6 @@ public function getBlockPrefix()
*/
public function getParent()
{
return compat::get_type_name('textarea');
return TextareaType::class;
}
}
@@ -13,7 +13,10 @@
use midcom;
use midcom\datamanager\extension\transformer\photo as transformer;
use midcom\datamanager\validation\photo as constraint;
use midcom\datamanager\extension\compat;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
/**
* Experimental image type
@@ -56,14 +59,14 @@ public function configureOptions(OptionsResolver $resolver)
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addViewTransformer(new transformer($options));
$builder->add('file', compat::get_type_name('file'), ['required' => false]);
$builder->add('file', FileType::class, ['required' => false]);
if ($options['widget_config']['show_title']) {
$builder->add('title', compat::get_type_name('text'));
$builder->add('title', TextType::class);
}
$builder->add('delete', compat::get_type_name('checkbox'), ['attr' => [
$builder->add('delete', CheckboxType::class, ['attr' => [
"class" => "midcom_datamanager_photo_checkbox"
], "required" => false ]);
$builder->add('identifier', compat::get_type_name('hidden'), ['data' => 'file']);
$builder->add('identifier', HiddenType::class, ['data' => 'file']);
$head = midcom::get()->head;
$head->add_stylesheet(MIDCOM_STATIC_URL . '/midcom.datamanager/image.css');
@@ -11,7 +11,9 @@
use Symfony\Component\Form\AbstractType;
use midcom\datamanager\extension\helper;
use midcom\datamanager\extension\transformer\blobs as transformer;
use midcom\datamanager\extension\compat;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
/**
* Experimental image type
@@ -39,16 +41,16 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('file', compat::get_type_name('file'));
$builder->add('file', FileType::class);
if ($options['widget_config']['show_title']) {
$builder->add('title', compat::get_type_name('text'));
$builder->add('title', TextType::class);
}
if ($options['widget_config']['show_description']) {
$builder->add('description', compat::get_type_name('text'));
$builder->add('description', TextType::class);
}
$builder->add('identifier', compat::get_type_name('hidden'), ['data' => 'file']);
$builder->add('identifier', HiddenType::class, ['data' => 'file']);
if ($options['widget_config']['sortable']) {
$builder->add('score', compat::get_type_name('hidden'));
$builder->add('score', HiddenType::class);
}
$builder->addViewTransformer(new transformer($options));
}
@@ -16,8 +16,11 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\Validator\Constraints\NotBlank;
use midcom\datamanager\extension\compat;
use midcom\datamanager\validation\laterthan;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TimeType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
/**
* Experimental jsdate type
@@ -80,8 +83,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$date_options['constraints'] = [new NotBlank];
}
$builder->add('date', compat::get_type_name('date'), $date_options);
$builder->add('input', compat::get_type_name('text'), $input_options);
$builder->add('date', DateType::class, $date_options);
$builder->add('input', TextType::class, $input_options);
if ($options['widget_config']['show_time']) {
$pattern = '[0-2][0-9]:[0-5][0-9]';
@@ -98,7 +101,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$time_options['constraints'] = [new NotBlank()];
}
$builder->add('time', compat::get_type_name('time'), $time_options);
$builder->add('time', TimeType::class, $time_options);
}
$head = midcom::get()->head;
@@ -163,6 +166,6 @@ public function getBlockPrefix()
*/
public function getParent()
{
return compat::get_type_name('form');
return FormType::class;
}
}
@@ -10,7 +10,6 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\Options;
use midcom;
use midcom\datamanager\extension\compat;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
use midcom\datamanager\extension\helper;
@@ -83,6 +82,6 @@ public function getBlockPrefix()
*/
public function getParent()
{
return compat::get_type_name('textarea');
return TextareaType::class;
}
}
@@ -12,7 +12,7 @@
use midcom\datamanager\extension\transformer\other as transformer;
use midcom\datamanager\extension\transformer\multiple;
use midcom\datamanager\extension\helper;
use midcom\datamanager\extension\compat;
use Symfony\Component\Form\Extension\Core\Type\TextType;
/**
* Experimental other type
@@ -47,11 +47,11 @@ public function buildForm(FormBuilderInterface $builder, array $options)
if (!empty($options['type_config']['allow_multiple'])) {
$builder->addModelTransformer(new multiple($options));
}
$builder->add('select', compat::get_type_name('select'), [
$builder->add('select', select::class, [
'type_config' => $options['type_config'],
'widget_config' => $options['widget_config'],
]);
$builder->add('other', compat::get_type_name('text'), ['label' => 'widget select: other value']);
$builder->add('other', TextType::class, ['label' => 'widget select: other value']);
}
@@ -7,7 +7,6 @@
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use midcom\datamanager\extension\compat;
use Symfony\Component\Form\Extension\Core\Type\RadioType;
use midcom;
use midcom_core_user;
@@ -125,6 +124,6 @@ public function getBlockPrefix()
*/
public function getParent()
{
return compat::get_type_name('radiocheckselect');
return radiocheckselect::class;
}
}
@@ -16,6 +16,7 @@
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Validator\Constraints\Count;
use midcom\datamanager\extension\compat;
use Symfony\Component\Form\Extension\Core\Type\FormType;
/**
* Experimental images type
@@ -114,6 +115,6 @@ public function getBlockPrefix()
*/
public function getParent()
{
return compat::get_type_name('form');
return FormType::class;
}
}
@@ -14,7 +14,6 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use midcom\datamanager\extension\helper;
use midcom\datamanager\extension\compat;
/**
* Experimental textarea type
@@ -114,7 +113,7 @@ public function getBlockPrefix()
*/
public function getParent()
{
return compat::get_type_name('textarea');
return TextareaType::class;
}
/**
@@ -10,7 +10,7 @@
use Symfony\Component\Form\AbstractType;
use midcom;
use midcom\datamanager\controller;
use midcom\datamanager\extension\compat;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
/**
* Experimental autocomplete type
@@ -54,7 +54,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$attributes['attr']['formnovalidate'] = true;
}
$builder->add($operation . $key, compat::get_type_name('submit'), $attributes);
$builder->add($operation . $key, SubmitType::class, $attributes);
}
}
}
@@ -18,6 +18,8 @@
use midcom\datamanager\storage\container\container;
use midcom\datamanager\storage\container\dbacontainer;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use midcom\datamanager\extension\type\toolbar;
/**
* Experimental schema class
@@ -82,7 +84,7 @@ public function build_form(FormFactoryInterface $factory, container $storage, $n
}
}
$builder = $factory->createNamedBuilder($name, compat::get_type_name('form'), $storage, ['csrf_protection' => $csrf]);
$builder = $factory->createNamedBuilder($name, FormType::class, $storage, ['csrf_protection' => $csrf]);
foreach ($fields as $field => $config) {
if ($config['write_privilege'] !== null) {
if ( array_key_exists('group', $config['write_privilege'])
@@ -126,7 +128,7 @@ public function build_form(FormFactoryInterface $factory, container $storage, $n
$options['constraints'] = [new Callback(['callback' => [$cb_wrapper, 'validate']])];
}
$builder->add('form_toolbar', compat::get_type_name('toolbar'), $options);
$builder->add('form_toolbar', toolbar::class, $options);
return $builder->getForm();
}

0 comments on commit 0bd878d

Please sign in to comment.