<?php

namespace Application\Service\Extension\Formatter;


use Application\Service\Extension\Helper\ArrayHelper;
use Application\Service\Extension\Laminas;
use Laminas\Db\Sql\Predicate\Between;

/**
 * 项目表单格式化类
 */
class ItemFormFormatter extends FormFormatter
{

    public function __construct()
    {
        parent::__construct();
    }

    protected function getForm()
    {
        return Laminas::$serviceManager->itemForm;
    }

    protected function getFormField()
    {
        return Laminas::$serviceManager->itemFormField;
    }

    protected function getFormFieldRadio()
    {
        return Laminas::$serviceManager->itemFormFieldRadio;
    }


    public function typeHandler($value): string
    {
        return $value == 1 ? '1对多' : '1对1';
    }

    public function groupIdHandler($value, $item)
    {
        return Laminas::$serviceManager->dictionaryFormGroup->fetchOne([
            'where' => ['id' => $value]
        ])['name'] . ($item['gco_pool'] ? "- {$item['gco_pool']}" : '') ?? 'error';
    }
}