Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

<?php

declare(strict_types=1);

namespace LeadersLinked\Form\MyGroup;

use Laminas\Form\Form;
use Laminas\Db\Adapter\AdapterInterface;
use Laminas\Log\LoggerInterface;
use LeadersLinked\Mapper\CompanySizeMapper;
use LeadersLinked\Mapper\IndustryMapper;

class IndustryForm extends Form
{
    /**
     * 
     * @param AdapterInterface $adapter
     */
    public function __construct($adapter) 
    {
        parent::__construct();
        $this->setInputFilter(new IndustryFilter($adapter));

        $this->add([
             'name' => 'industry_id',
             'type' => \Laminas\Form\Element\Select::class,
             'options' => [
                 'value_options' => $this->optionsIndustry($adapter),
             ],
             'attributes' => [
                 'id' => 'industry_id',
             ]
         ]);

    }


    /**
     *
     * @param AdapterInterface $adapter
     * @return array
     */
    private function optionsIndustry($adapter)
    {
        $industryMapper = IndustryMapper::getInstance($adapter);
        $industries  = $industryMapper->fetchAllActive();
        
        $options = [];
        foreach($industries as $industry)
        {
            $options[$industry->uuid] = $industry->name;
        }
        
        return $options;
    }

   
}