Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
6056 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\KnowledgeArea;
6
 
7
use Laminas\Form\Form;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use Laminas\Log\LoggerInterface;
10
use LeadersLinked\Mapper\CompanySizeMapper;
11
use LeadersLinked\Mapper\IndustryMapper;
12
use LeadersLinked\Model\Feed;
13
use Laminas\Db\Adapter\Adapter;
14
use LeadersLinked\Mapper\KnowledgeAreaCategoryMapper;
15
 
16
class KnowledgeAreaEditForm extends Form
17
{
18
 
19
    /**
20
     *
21
     * @param AdapterInterface $adapter
22
     * @param int[] $category_with_edition_ids
23
     */
24
    public function __construct($adapter, $category_with_edition_ids)
25
    {
26
        parent::__construct();
27
        $this->setInputFilter(new KnowledgeAreaEditFilter());
28
 
29
        $this->add([
30
            'name' => 'category_id',
31
            'type' => \Laminas\Form\Element\Select::class,
32
            'options' => [
33
                'value_options' =>  $this->getCategories($adapter, $category_with_edition_ids)
34
            ],
35
            'attributes' => [
36
                'id' => 'category_id',
37
            ]
38
        ]);
39
 
40
 
41
        $this->add([
42
            'name' => 'title',
43
            'type' => \Laminas\Form\Element\Textarea::class,
44
            'attributes' => [
45
                'id'    => 'title',
46
                'maxlength' => 120
47
            ]
48
        ]);
49
 
50
 
51
        $this->add([
52
            'name' => 'description',
53
            'type' => \Laminas\Form\Element\Textarea::class,
54
            'attributes' => [
55
                'id'    => 'description',
56
            ]
57
        ]);
58
 
59
        $this->add([
60
            'name' => 'image',
61
            'type' => \Laminas\Form\Element\File::class,
62
             'attributes' => [
63
                'id' => 'image',
64
            ]
65
         ]);
66
 
67
 
68
        $this->add([
69
            'name' => 'attachment',
70
            'type' => \Laminas\Form\Element\File::class,
71
            'attributes' => [
72
                'id' => 'attachment',
73
            ]
74
        ]);
75
 
76
 
77
        $this->add([
78
            'name' => 'link',
79
            'type' => \Laminas\Form\Element\Url::class,
80
            'attributes' => [
81
                'id'    => 'link',
82
            ]
83
        ]);
84
    }
85
 
86
    /**
87
     *
88
     * @param AdapterInterface $adapter
89
     * @param int[] $category_with_edition_ids
90
     * @return array
91
     */
92
    private function getCategories($adapter, $category_with_edition_ids)
93
    {
94
        $options = [];
95
 
96
        $knowledgeAreaCategoryMapper = KnowledgeAreaCategoryMapper::getInstance($adapter);
97
        $records = $knowledgeAreaCategoryMapper->fetchAllByIds($category_with_edition_ids);
98
 
99
        foreach($records as $record)
100
        {
101
            $options[ $record->uuid  ] = $record->name;
102
        }
103
 
104
 
105
        return $options;
106
    }
107
}