-
Notifications
You must be signed in to change notification settings - Fork 1
/
FileManagerType.php
64 lines (54 loc) · 1.78 KB
/
FileManagerType.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
declare(strict_types=1);
namespace Matt9mg\Concrete5\Symfony\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* Class FileManagerType
* @package Matt9mg\Concrete5\Symfony\Form
*/
class FileManagerType extends AbstractType
{
public const FILE_MANAGER_TYPE_APP = 'APP';
public const FILE_MANAGER_TYPE_AUDIO = 'AUDIO';
public const FILE_MANAGER_TYPE_DOC = 'DOC';
public const FILE_MANAGER_TYPE_FILE = 'FILE';
public const FILE_MANAGER_TYPE_IMAGE = 'IMAGE';
public const FILE_MANAGER_TYPE_TEXT = 'TEXT';
public const FILE_MANAGER_TYPE_VIDEO = 'VIDEO';
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'compound' => false,
'file_manager_type' => self::FILE_MANAGER_TYPE_FILE,
'file_manager_args' => [],
]);
$resolver->setAllowedValues('file_manager_type', [
self::FILE_MANAGER_TYPE_APP,
self::FILE_MANAGER_TYPE_AUDIO,
self::FILE_MANAGER_TYPE_DOC,
self::FILE_MANAGER_TYPE_FILE,
self::FILE_MANAGER_TYPE_IMAGE,
self::FILE_MANAGER_TYPE_TEXT,
self::FILE_MANAGER_TYPE_VIDEO
]);
}
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['file_manager_type'] = $options['file_manager_type'];
$view->vars['file_manager_args'] = $options['file_manager_args'];
parent::buildView($view, $form, $options);
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix(): string
{
return 'file_manager';
}
}