|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2014 Jonathan Bouzekri. All rights reserved. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright Copyright 2014 Jonathan Bouzekri <[email protected]> |
|
7
|
|
|
* @license https://github.com/jbouzekri/FileUploaderBundle/blob/master/LICENSE |
|
8
|
|
|
* @link https://github.com/jbouzekri/FileUploaderBundle |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Jb\Bundle\FileUploaderBundle\Form\Type; |
|
12
|
|
|
|
|
13
|
|
|
use Symfony\Component\Form\AbstractType; |
|
14
|
|
|
use Symfony\Component\Form\Extension\Core\Type\IntegerType; |
|
15
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
|
16
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
|
17
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
18
|
|
|
use Symfony\Component\Validator\Constraints\NotBlank; |
|
19
|
|
|
use Symfony\Component\Validator\Constraints\Range; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* CropType |
|
23
|
|
|
*/ |
|
24
|
|
|
class CropType extends AbstractType |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* {@inheritdoc} |
|
28
|
|
|
*/ |
|
29
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options) |
|
30
|
|
|
{ |
|
31
|
|
|
parent::buildForm($builder, $options); |
|
32
|
|
|
|
|
33
|
|
|
$builder |
|
34
|
|
|
->add('x', IntegerType::class, [ |
|
35
|
|
|
'constraints' => [ |
|
36
|
|
|
new NotBlank(), |
|
37
|
|
|
new Range(['min' => 0]), |
|
38
|
|
|
] |
|
39
|
|
|
]) |
|
40
|
|
|
->add('y', IntegerType::class, [ |
|
41
|
|
|
'constraints' => [ |
|
42
|
|
|
new NotBlank(), |
|
43
|
|
|
new Range(['min' => 0]), |
|
44
|
|
|
] |
|
45
|
|
|
]) |
|
46
|
|
|
->add('width', IntegerType::class, [ |
|
47
|
|
|
'constraints' => [ |
|
48
|
|
|
new NotBlank(), |
|
49
|
|
|
new Range(['min' => 0]), |
|
50
|
|
|
] |
|
51
|
|
|
]) |
|
52
|
|
|
->add('height', IntegerType::class, [ |
|
53
|
|
|
'constraints' => [ |
|
54
|
|
|
new NotBlank(), |
|
55
|
|
|
new Range(['min' => 0]), |
|
56
|
|
|
] |
|
57
|
|
|
]) |
|
58
|
|
|
->add('filename', TextType::class, [ |
|
59
|
|
|
'constraints' => [ |
|
60
|
|
|
new NotBlank(), |
|
61
|
|
|
] |
|
62
|
|
|
]); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* {@inheritdoc} |
|
67
|
|
|
*/ |
|
68
|
|
|
public function configureOptions(OptionsResolver $resolver) |
|
69
|
|
|
{ |
|
70
|
|
|
$resolver->setDefaults(array( |
|
71
|
|
|
'csrf_protection' => false, |
|
72
|
|
|
)); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|