Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16248 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
16248 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 LeadersLinked\Mapper\KnowledgeAreaCategoryMapper;
16761 efrain 10
use LeadersLinked\Model\KnowledgeAreaCategory;
16248 efrain 11
 
12
 
13
class KnowledgeAreaCategoryUserDataForm extends Form
14
{
15
 
16
    /**
17
     *
18
     * @param AdapterInterface $adapter
19
     * @param int $company_id
20
     */
21
    public function __construct($adapter, $company_id) {
22
        parent::__construct();
23
        $this->setInputFilter(new KnowledgeAreaCategoryUserDataFilter());
24
 
25
 
26
 
27
 
28
        $this->add([
29
            'name' => 'category_id',
30
            'type' => \Laminas\Form\Element\Select::class,
31
            'attributes' => [
32
                'id' =>  'category_id',
33
            ],
34
            'options' => [
35
                //'disable_inarray_validator' => true,
36
                'value_options' =>  $this->getCategories($adapter, $company_id)
37
            ]
38
        ]);
39
 
40
 
41
 
42
    }
43
 
44
    private function getCategories($adapter, $company_id)
45
    {
46
        $items = [];
47
        $knowledgeAreaCategoryMapper = KnowledgeAreaCategoryMapper::getInstance($adapter);
48
        $records = $knowledgeAreaCategoryMapper->fetchAllByCompanyId($company_id);
49
 
50
        foreach($records as $record)
51
        {
16761 efrain 52
            switch($record->privacy)
53
            {
54
                case KnowledgeAreaCategory::PRIVACY_COMPANY :
55
                    $privacy = 'LABEL_COMPANY';
56
                    break;
57
 
58
                case KnowledgeAreaCategory::PRIVACY_PUBLIC :
59
                    $privacy = 'LABEL_PUBLIC';
60
                    break;
61
 
62
                default :
63
                    $privacy = 'LABEL_UNKNOW';
64
                    break;
65
            }
66
 
67
 
68
            $items[ $record->uuid ] = $record->name . ' (' . $privacy . ')';
16248 efrain 69
        }
70
 
71
        return $items;
72
    }
73
 
74
 
75
}
76