Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

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