Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
17002 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\Microlearning;
6
 
7
use Laminas\Form\Form;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use LeadersLinked\Mapper\MicrolearningTopicMapper;
10
use LeadersLinked\Mapper\MicrolearningCapsuleMapper;
11
 
12
class TopicReportForm extends Form
13
{
14
 
15
 
16
    /**
17
     *
18
     * @param AdapterInterface $adapter
19
     * @param int $company_id
20
     */
21
    public function __construct($adapter, $company_id)
22
    {
23
        parent::__construct();
24
        $this->setInputFilter(new TopicReportFilter($adapter));
25
 
26
        $this->add([
27
            'name' => 'topic_uuid',
28
            'type' => \Laminas\Form\Element\Select::class,
29
            'attributes' => [
30
                'id' => 'topic_uuid',
31
            ],
32
            'options' => [
33
                'value_options' => $this->getSelectTopicOptions($adapter, $company_id)
34
            ]
35
        ]);
36
 
37
 
38
 
39
 
40
    }
41
 
42
    /**
43
     *
44
     * @param AdapterInterface $adapter
45
     */
46
    private function getSelectTopicOptions($adapter, $company_id)
47
    {
48
        $options = [];
49
 
50
        $mapper = MicrolearningTopicMapper::getInstance($adapter);
51
        $records = $mapper->fetchAllByCompanyId($company_id);
52
 
53
        foreach($records as $record)
54
        {
55
            $options[$record->uuid] = $record->name;
56
        }
57
        return $options;
58
    }
59
 
60
 
61
}