Set associations by file type field, for "module" type Modules.

@param \CsvMigrations\FieldHandlers\CsvField $field CSV Field instance
@return void
341081
private function setByTypeFileField(CsvField $field) : void
    {
        if (! in_array($field->getType(), ['files', 'images'])) {
            return;
        }

        $this->setAssociation(
            'hasMany',
            static::generateAssociationName(FileUpload::FILE_STORAGE_TABLE_NAME, $field->getName()),
            [
                'className' => FileUpload::FILE_STORAGE_TABLE_NAME,
                'foreignKey' => 'foreign_key',
                'conditions' => ['model' => $this->getTable(), 'model_field' => $field->getName()]
            ]
        );
    }
10204
private function setByTypeSelfRelationField(string $module, array $fields) : void
    {
        $first = $fields[0];
        $second = $fields[1];

        $this->setAssociation(
            'belongsToMany',
            static::generateAssociationName($module, $first->getName()),
            [
                'joinTable' => Inflector::tableize($module),
                'className' => $first->getAssocCsvModule(),
                'foreignKey' => $second->getName(),
                'targetForeignKey' => $first->getName()
            ]
        );

        $this->setAssociation(
            'belongsToMany',
            static::generateAssociationName($module, $second->getName()),
            [
                'joinTable' => Inflector::tableize($module),
                'className' => $second->getAssocCsvModule(),
                'foreignKey' => $first->getName(),
                'targetForeignKey' => $second->getName()
            ]
        );
    }
1163007
public function setupPrimaryKey(Field $field)
    {
        if (!$this->primaryKey && $field->primaryKey) {
            $this->primaryKey = $field;
        }
    }
209744
public function setNewValue(string $field, $value) : void
    {
        $change = $this->objectChangeSet->getFieldChange($field);

        if ($change !== null) {
            $change->setNewValue($value);
        } else {
            $this->objectChangeSet->addChange(new Change($field, null, $value));
        }
    }
660425
protected function setDefaultFieldDefinitions() : void
    {
        $table = $this->config->getTable();
        $field = $this->config->getField();
        $dbFieldType = $this->getDbFieldType();

        // set $options['fieldDefinitions']
        $stubFields = [
            $field => [
                'name' => $field,
                'type' => $dbFieldType,
            ],
        ];
        if ($table instanceof HasFieldsInterface) {
            $fieldDefinitions = $table->getFieldsDefinitions($stubFields);
            $this->defaultOptions['fieldDefinitions'] = new CsvField($fieldDefinitions[$field]);
        }

        // This should never be the case, except, maybe
        // for some unit test runs or custom non-CSV
        // modules.
        if (empty($this->defaultOptions['fieldDefinitions'])) {
            $this->defaultOptions['fieldDefinitions'] = new CsvField($stubFields[$field]);
        }
    }
184093
public function setCreateProjectFolderField(&$fields) {
		// Check if the capistrano project folder exists
		if(!$this->Name) {
			return;
		}

		if($this->projectFolderExists()) {
			return;
		}

		$createFolderNotice = new LabelField('CreateEnvFolderNotice', 'Warning: No Capistrano project folder exists');
		$createFolderNotice->addExtraClass('message warning');
		$fields->insertBefore($createFolderNotice, 'Name');
		$createFolderField = new CheckboxField('CreateEnvFolder', 'Create folder');
		$createFolderField->setDescription('Would you like to create the capistrano project folder?');
		$fields->insertAfter($createFolderField, 'CreateEnvFolderNotice');
	}
1213568
private function updateFields($fields)
    {
        if ($this->isLink()) return;
        
        self::getDbConnection()->executeQuery('DELETE FROM types_fields_catalogs WHERE catalog_id='.$this->id);
        if (is_array($fields)) 
            foreach ($fields as $fid => $data) {
                if ($data['force_show'] || $data['force_hide']) 
					self::getDbConnection()->executeQuery('INSERT INTO types_fields_catalogs SET catalog_id='.$this->id.', type_id='.$this->materialsType.', field_id='.$fid.', force_show='.(int)$data['force_show'].', force_hide='.(int)$data['force_hide']);
            }
    }
1368593
public function add(FormField $field)
    {
        $segments = $this->getSegments($field->getName());

        $target = &$this->fields;
        while ($segments) {
            if (!\is_array($target)) {
                $target = [];
            }
            $path = array_shift($segments);
            if ('' === $path) {
                $target = &$target[];
            } else {
                $target = &$target[$path];
            }
        }
        $target = $field;
    }
1058681
public function setFromArray(array $fields)
    {
        foreach($fields as $key => $value)
        {
                $this->fields[$key] = $value;
                unset($key);
                unset($value);
        }
    }
1271842
public function setTypeAttribute($type)
    {
        if (!$type instanceof FileType) {
            $type = FileType::getByName($type);
        }
        if (!$type) {
            throw new InvalidArgumentException('Unknown file type');
        }
        $this->type()->associate($type);
    }
888943
protected static function setFile($file)
    {
        if (self::$isCom === false) {
            $incFile = route()->views.'/'.$file.'.php';
            if (file_exists($incFile)) {
                self::$file = $incFile;
            }
        } else {
            $incFile = route()->com.$file.'.php';
            if (file_exists($incFile)) {
                self::$file = $incFile;
            }
        }
    }
210048
public function addField(Field $field)
    {
        $tmp               = $this->fields->getValue($this->entity);
        $tmp[$field->name] = $field;
        $this->fields->setValue($this->entity, $tmp);

        if ($field->role == 'id') {
            $key = new \ReflectionProperty(Entity::class, 'key');
            $key->setAccessible(true);
            $key->setValue($this->entity, $field->name);
        }
    }
1071202
public function addField($field, $alias = null)
    {
        if (isset($this->addFieldStrategies[$field])) {
            $this->addFieldStrategies[$field]->addField($this->getCollection(), $field, $alias);

            return ;
        }
        parent::addField($field, $alias);
    }
410507
public function updateCMSFields(FieldList $fields)
    {
        // only apply the update to files (not folders)
        if ($this->owner->class != 'Folder') {
            // add the tabs from the translatable tab set to the fields
            /** @var TabSet $set */
            $set = $this->owner->getTranslatableTabSet();

            // Remove the tab of the default locale (these are in the "main" tab)
            $set->removeByName(Translatable::default_locale());

            foreach ($set->FieldList() as $tab) {
                $fields->addFieldToTab('Root', $tab);
            }
        }
    }
580230
private function setByModule(string $module) : void
    {
        $config = (new ModuleConfig(ConfigType::MODULE(), $module))->parse();
        $fields = $this->getModuleFields($module);

        if (! property_exists($config, 'table')) {
            return;
        }

        if (! property_exists($config->table, 'type')) {
            return;
        }

        if ('module' === $config->table->type) {
            $this->setByTypeModule($module, $fields);
        }

        if ('relation' === $config->table->type) {
            $this->setByTypeRelation($module, $fields);
        }

        if ($module === $this->getTableName()) {
            $this->setByTypeFile($module, $fields);
        }
    }
272749
public function addField(&$field)
    {
        if (!isset($this->_fields[$field->name()])) {
            $this->_fields[$field->name()] =& $field;
        }
    }
1310411
protected function assignFields($fields)
    {
        foreach ($fields as $field) {
            if (!$field instanceof FieldInterface) {
                throw new ModelException(sprintf('Field must be an instance of FieldInterface, got "%s"', $this->getType($field)));
            }

            $field->table($this->table);
            $this->fields[$field->name()] = $field;
        }
    }