Completed
Push — master ( 603670...576387 )
by Adam
06:48
created

LocalFile::getTypeIcons()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 16
nc 1
nop 0
1
<?php
2
3
namespace WellCommerce\Component\Form\Elements\Upload;
4
5
use Symfony\Component\OptionsResolver\OptionsResolver;
6
use WellCommerce\Component\Form\Elements\Attribute;
7
use WellCommerce\Component\Form\Elements\AttributeCollection;
8
9
/**
10
 * Class LocalFile
11
 *
12
 * @author  Adam Piotrowski <[email protected]>
13
 */
14
class LocalFile extends File
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function configureOptions(OptionsResolver $resolver)
20
    {
21
        parent::configureOptions($resolver);
22
        
23
        $resolver->setRequired([
24
            'file_source',
25
        ]);
26
        
27
        $resolver->setDefaults([
28
            'file_types'   => ['jpg', 'jpeg', 'png', 'gif', 'csv', 'xml', 'txt', 'pdf'],
29
            'load_route'   => 'admin.local_file.index',
30
            'upload_route' => 'admin.local_file.upload',
31
        ]);
32
        
33
        $resolver->setAllowedTypes('file_source', 'string');
34
    }
35
    
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function prepareAttributesCollection(AttributeCollection $collection)
40
    {
41
        parent::prepareAttributesCollection($collection);
42
        $collection->add(new Attribute('oTypeIcons', $this->getTypeIcons(), Attribute::TYPE_ARRAY));
43
        $collection->add(new Attribute('sFilePath', $this->getOption('file_source')));
44
    }
45
}
46