<commit_before><?php

namespace RegistrationFieldTypes;

use MapasCulturais\App;
use MapasCulturais\i;
use MapasCulturais\Entities\Agent;
use MapasCulturais\Definitions\RegistrationFieldType;

class Module extends \MapasCulturais\Module
{
    public function _init()
    {
    }

    public function register()
    {
        $app = App::i();
        foreach ($this->getRegistrationFieldTypesDefinitions() as $definition) {
            $app->registerRegistrationFieldType(new RegistrationFieldType($definition));
        }

        $this->_config['availableAgentFields'] = $this->getAgentFields();
    }

    function getAgentFields()
    {
        $agent_fields = ['name', '_type', 'shortDescription', '@location'];
        
        $definitions = Agent::getMetadataMetadata();
        
        foreach ($definitions as $key => $def) {
            $def = (object) $def;
            if ($def->isMetadata && $def->available_for_opportunities) {
                $agent_fields[] = $key;
            }
        }
        
        return $agent_fields;
    }

    function getRegistrationFieldTypesDefinitions()
    {
        $registration_field_types = [
            [
                'slug' => 'textarea',
                'name' => \MapasCulturais\i::__('Campo de texto (textarea)'),
                'viewTemplate' => 'registration-field-types/textarea',
                'configTemplate' => 'registration-field-types/textarea-config',
            ],
            [
                'slug' => 'text',<commit_msg>define o tipo dos campos de agente nas oportunidades (refs: #1467)<commit_after><?php

namespace RegistrationFieldTypes;

use MapasCulturais\App;
use MapasCulturais\i;
use MapasCulturais\Entities\Agent;
use MapasCulturais\Definitions\RegistrationFieldType;

class Module extends \MapasCulturais\Module
{
    public function _init()
    {
    }

    public function register()
    {
        $app = App::i();
        foreach ($this->getRegistrationFieldTypesDefinitions() as $definition) {
            $app->registerRegistrationFieldType(new RegistrationFieldType($definition));
        }

        $agent_fields = Agent::getPropertiesMetadata();
        $app->hook('controller(registration).registerFieldType(agent-owner-field)', function (\MapasCulturais\Entities\RegistrationFieldConfiguration $field, &$registration_field_config) use ($agent_fields) {
            $agent_field_name = $field->config['agentField'];
            $agent_field = $agent_fields[$agent_field_name];

            $registration_field_config['type'] = $agent_field['type'];
            if(isset($agent_field['options'])){
                $registration_field_config['options'] = $agent_field['options'];
            }
            if(isset($agent_field['optionsOrder'])){
                $registration_field_config['optionsOrder'] = $agent_field['optionsOrder'];
            }
        });

        $this->_config['availableAgentFields'] = $this->getAgentFields();
    }

    function getAgentFields()
    {
        $agent_fields = ['name', '_type', 'shortDescription', '@location'];
        
        $definitions = Agent::getMetadataMetadata();
        
        foreach ($definitions as $key => $def) {
            $def = (object) $def;
            if ($def->isMetadata && $def->available_for_opportunities) {
                $agent_fields[] = $key;
            }
        }
        
        return $agent_fields;
    }

    function getRegistrationFieldTypesDefinitions()
    {
        $registration_field_types = [
            [
                'slug' => 'textarea',
                'name' => \MapasCulturais\i::__('Campo de texto (textarea)'),
                'viewTemplate' => 'registration-field-types/textarea',
                'configTemplate' => 'registration-field-types/textarea-config',
            ],
            [
                'slug' => 'text',
{'fraction_non_alphanumeric': 0.12933507170795305, 'fraction_numerical': 0.0010430247718383311, 'mean_word_length': 2.4311270125223614, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3874117', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1033, 'n_words': 172}