Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Form\MyCoach;use Laminas\Form\Form;use Laminas\Db\Adapter\AdapterInterface;use Laminas\Log\LoggerInterface;use LeadersLinked\Model\Topic;use Laminas\Form\Element;use LeadersLinked\Mapper\UserMapper;use LeadersLinked\Mapper\MyCoachQuestionCategoryMapper;use LeadersLinked\Mapper\MyCoachCategoryMapper;use LeadersLinked\Model\MyCoachCategoryUser;use LeadersLinked\Model\MyCoachCategory;class MyCoachCategoryUserForm extends Form{/**** @param AdapterInterface $adapter* @param int $company_id* @param string $privacy*/public function __construct($adapter, $company_id, $privacy) {parent::__construct();$this->setInputFilter(new MyCoachCategoryUserFilter());if($privacy == MyCoachCategory::PRIVACY_COMPANY) {$roles = [MyCoachCategoryUser::ROLE_USER => 'LABEL_USER',MyCoachCategoryUser::ROLE_EDITOR => 'LABEL_EDITOR',MyCoachCategoryUser::ROLE_ADMINISTRATOR => 'LABEL_ADMINISTRATOR',];} else {$roles = [MyCoachCategoryUser::ROLE_EDITOR => 'LABEL_EDITOR',MyCoachCategoryUser::ROLE_ADMINISTRATOR => 'LABEL_ADMINISTRATOR',];}$this->add(['name' => 'user_id','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'user_id',],'options' => [//'disable_inarray_validator' => true,'value_options' => $this->getUsers($adapter, $company_id)]]);$this->add(['name' => 'role','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'role',],'options' => [//'disable_inarray_validator' => true,'value_options' => $roles]]);}private function getUsers($adapter, $company_id){$items = [];$userMapper = UserMapper::getInstance($adapter);$records = $userMapper->fetchAllByCompanyId($company_id);foreach($records as $record){$items[ $record->uuid ] = $record->first_name . ' ' . $record->last_name . ' (' . $record->email . ')';}return $items;}}