Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
17248 stevensc 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\Form\Microlearning\TopicUserFilter;
11
 
12
class TopicUserForm extends Form
13
{
14
 
15
    /**
16
     *
17
     * @param AdapterInterface $adapter
18
     * @param int $company_id
19
     * @param int $topic_id
20
     */
21
    public function __construct($adapter, $company_id, $topic_id)
22
    {
23
        parent::__construct();
24
        $this->setInputFilter(new TopicUserFilter($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
     * @param AdapterInterface $adapter
41
     */
42
    private function getSelectTopicOptions($adapter, $company_id)
43
    {
44
        $options = [];
45
 
46
        $mapper = MicrolearningTopicMapper::getInstance($adapter);
47
        $records = $mapper->fetchAllByCompanyId($company_id);
48
 
49
        foreach($records as $record)
50
        {
51
            $options[$record->uuid] = $record->name;
52
        }
53
        return $options;
54
    }
55
}