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\OptionsResolver\OptionsResolver; |
15
|
|
|
use Symfony\Component\Form\FormView; |
16
|
|
|
use Symfony\Component\Form\FormInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* CropImageAjaxType |
20
|
|
|
*/ |
21
|
|
|
class CropImageAjaxType extends AbstractType |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* {@inheritDoc} |
25
|
|
|
*/ |
26
|
|
|
public function configureOptions(OptionsResolver $resolver) |
27
|
|
|
{ |
28
|
|
|
$resolver->setDefined( |
29
|
|
|
array( |
30
|
|
|
'max_width', |
31
|
|
|
'max_height', |
32
|
|
|
'reset_button', |
33
|
|
|
'reset_button_label', |
34
|
|
|
'confirm_button_label', |
35
|
|
|
'crop_options' |
36
|
|
|
) |
37
|
|
|
); |
38
|
|
|
|
39
|
|
|
$resolver->setDefaults( |
40
|
|
|
array( |
41
|
|
|
'resolver_key' => 'croped_resolver', |
42
|
|
|
'max_width' => 350, |
43
|
|
|
'max_height' => 350, |
44
|
|
|
'reset_button' => true, |
45
|
|
|
'reset_button_label' => 'Reset', |
46
|
|
|
'confirm_button_label' => 'Confirm', |
47
|
|
|
'crop_options' => array() |
48
|
|
|
) |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritDoc} |
54
|
|
|
*/ |
55
|
|
|
public function buildView(FormView $view, FormInterface $form, array $options) |
56
|
|
|
{ |
57
|
|
|
$view->vars['use_crop'] = true; |
58
|
|
|
$view->vars['max_width'] = $options['max_width']; |
59
|
|
|
$view->vars['max_height'] = $options['max_height']; |
60
|
|
|
$view->vars['reset_button'] = $options['reset_button']; |
61
|
|
|
$view->vars['reset_button_label'] = $options['reset_button_label']; |
62
|
|
|
$view->vars['confirm_button_label'] = $options['confirm_button_label']; |
63
|
|
|
$view->vars['crop_options'] = $options['crop_options']; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* {@inheritDoc} |
68
|
|
|
*/ |
69
|
|
|
public function getParent() |
70
|
|
|
{ |
71
|
|
|
return ImageAjaxType::class; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|