-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathEARankyMediaFileManagerField.php
71 lines (57 loc) · 2.47 KB
/
EARankyMediaFileManagerField.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
64
65
66
67
68
69
70
71
<?php
declare(strict_types=1);
namespace Ranky\MediaBundle\Presentation\Form\EasyAdmin;
use EasyCorp\Bundle\EasyAdminBundle\Config\Asset;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait;
use Ranky\MediaBundle\Presentation\Form\RankyMediaFileManagerType;
if (\interface_exists('EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface')) {
final class EARankyMediaFileManagerField implements FieldInterface
{
use FieldTrait;
public const OPTION_MULTIPLE_SELECTION = 'multiple_selection';
public const OPTION_ASSOCIATION = 'association';
public const OPTION_MODAL_TITLE = 'modal_title';
public const OPTION_SAVE_PATH = 'save_path';
public static function new(string $propertyName, $label = null): self
{
return (new self())
->setProperty($propertyName)
->setLabel($label)
->addWebpackEncoreEntries(
Asset::new('ranky_media')
->webpackEntrypointName('ranky_media')
)
->setFormType(RankyMediaFileManagerType::class)
->setFormTypeOptions([
self::OPTION_SAVE_PATH => false,
self::OPTION_MULTIPLE_SELECTION => false,
self::OPTION_ASSOCIATION => false,
self::OPTION_MODAL_TITLE => 'Media File Manager',
])
->addFormTheme('@RankyMedia/form.html.twig')
->setTemplatePath('@RankyMedia/preview/easyadmin.html.twig')
->setSortable(false);
}
public function multipleSelection(bool $isMultiple = true): self
{
$this->setFormTypeOption(self::OPTION_MULTIPLE_SELECTION, $isMultiple);
return $this;
}
public function association(bool $isAssociation = true): self
{
$this->setFormTypeOption(self::OPTION_ASSOCIATION, $isAssociation);
return $this;
}
public function modalTitle(string $modalTitle): self
{
$this->setFormTypeOption(self::OPTION_MODAL_TITLE, $modalTitle);
return $this;
}
public function savePath(bool $savePath = true): self
{
$this->setFormTypeOption(self::OPTION_SAVE_PATH, $savePath);
return $this;
}
}
}