Proyectos de Subversion LeadersLinked - Backend

Rev

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

<?php

declare(strict_types=1);

namespace LeadersLinked\Form\DevelopmentContent;

use Laminas\Form\Form;
use Laminas\Db\Adapter\AdapterInterface;
use Laminas\Log\LoggerInterface;
use LeadersLinked\Mapper\CompanySizeMapper;
use LeadersLinked\Mapper\IndustryMapper;
use LeadersLinked\Mapper\TopicMapper;
use LeadersLinked\Model\Feed;
use Laminas\Form\Element;

class DevelopmentContentCreateFeedForm extends Form
{

    public function __construct($adapter) 
    {
        parent::__construct();
        $this->setInputFilter(new DevelopmentContentCreateFeedFilter($adapter));
       

        $this->add([
            'name' => 'priority',
            'type' => \Laminas\Form\Element\Checkbox::class,
            'attributes' => [
                'id'                    => 'priority',
                'class'         => 'form-control',
            ],
            'options' => [
                'use_hidden_element' => false,
                'unchecked_value' => \LeadersLinked\Model\Feed::PRIORITY_NORMAL,
                'checked_value'=> \LeadersLinked\Model\Feed::PRIORITY_URGENT,
            ]
        ]);

        $this->add([
            'name' => 'file_type',
            'type' => \Laminas\Form\Element\Hidden::class,
            'attributes' => [
                'id'    => 'file_type',
                'value_options' => [ 
                    Feed::TYPE_HPTG,
                    Feed::TYPE_MYT_ANSWER
                ]
            ]
        ]);

        $this->add([
            'name' => 'time',
            'type' => Element\Time::class,
            'options'=> [
                'format' => 'H:i',
            ]
        ]);
        $this->add([
            'name' => 'date',
            'type' => Element\Date::class,
            'attributes' => [
                'maxlength'     => 15,
                'id'                    => 'date',
            ]
        ]);
        $this->add([
            'name' => 'link_name',
            'type' => \Laminas\Form\Element\Text::class,
            'attributes' => [
                'maxlength'     => 254,
                'id'                    => 'link_name',
            ]
        ]);
        $this->add([
            'type' => Element\Select::class,
            'name' => 'link_type',
            'options' =>  [
                'empty_option' => 'LABEL_SELECT',
                'value_options' =>[
                    'skype' => 'Skype',
                    'zoom' => 'Zoom',
                    'meet'=>'Meet'
                ],
            ],
            'attributes'=> [
                'class' => 'Custom-select', 
                'id' => 'link_type',
                  ]
            ]);

            $this->add([
                'name' => 'link_media',
                'type' => Element\Select::class,
                'options' => [
                    'empty_option' => 'LABEL_LINK',
                    'value_options' => [
                        'cesa' => 'CESA',
                        'youtube' => 'YouTube',
                        'spotify'=> 'Spotify',
                        'deezer' => 'Deezer',
                        'apple' => 'Apple Podcast',
                    ],
                ],
                'attributes' => [
                    'class' => 'Custom-select', 
                    'id' => 'link_media',
                ]
            ]);
            
        $this->add([
                'name' => 'title',
                'type' => \Laminas\Form\Element\Text::class,
                'attributes' => [
                    'maxlength'         => 128,
                    'id'                        => 'title',
                ]
        ]);

        $this->add([
            'name' => 'description',
            'type' => \Laminas\Form\Element\Textarea::class,
            'attributes' => [
                'id'    => 'description',
            ]
        ]);
        
        $this->add([
            'name' => 'file',
            'type' => \Laminas\Form\Element\File::class,
             'attributes' => [
                'id' => 'file',
            ]
         ]);

        $this->add([
            'name' => 'video',
            'type' => \Laminas\Form\Element\File::class,
            'attributes' => [
                'id' => 'video',
            ]
        ]);

        $this->add([
            'name' => 'doc',
            'type' => \Laminas\Form\Element\File::class,
            'attributes' => [
                'id' => 'doc',
            ]
        ]);

        $this->add([
            'name' => 'image',
            'type' => \Laminas\Form\Element\File::class,
            'attributes' => [
                'id' => 'image',
            ]
        ]);

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

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

     /**
     *
     * @param AdapterInterface $adapter
     */
    private function getSelectFormOptions($adapter)
    {
        $options = [];
        
        $mapper = TopicMapper::getInstance($adapter);
        $records = $mapper->fetchAllMyTrainer(); 
        
        foreach($records as $record)
        {
            $options[$record->uuid] = $record->title;    
        }
        return $options;
    }
        
     /**
     *
     * @param AdapterInterface $adapter
     */
    private function getDevelopmentFormOptions($adapter)
    {
        $options = [];
        
        $mapper = TopicMapper::getInstance($adapter);
        $records = $mapper->fetchAllDevelopment(); 
        
        foreach($records as $record)
        {
            $options[$record->uuid] = $record->title;    
        }
        return $options;
    }
        
    
}