Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Autoría | Ultima modificación | Ver Log |

<?php

declare(strict_types=1);

namespace LeadersLinked\Form\Job;

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

class ApplyForm extends Form
{
    /**
     * 
     * @param AdapterInterface $adapter
     * @param int $user_id
     */
    public function __construct($adapter, $user_id) 
    {
        parent::__construct();
        $this->setInputFilter(new ApplyFilter($adapter));
        
        $this->add([
            'name' => 'user_profile_id',
            'type' => \Laminas\Form\Element\Select::class,
            'options' => [
                'value_options' => $this->optionsProfiles($adapter, $user_id),
            ],
            'attributes' => [
                'id' => 'user_profile_id',
            ]
        ]);
    }
    
    /**
     *
     * @param AdapterInterface $adapter
     * @param int $user_id
     * @param LoggerInterface $logger
     * @return array
     */
    private function optionsProfiles($adapter, $user_id)
    {
        $userProfileMapper = UserProfileMapper::getInstance($adapter);
        $userProfiles = $userProfileMapper->fetchAllByUserId($user_id);
        
        $options = [];
        foreach($userProfiles as $userProfile)
        {
            $options[$userProfile->uuid] = $userProfile->name;
        }
        
        return $options;
    }
    
   
}