Add custom field

@param $name
@param $class
509700
public function addCustomField($name, $class)
    {
        if (!array_key_exists($name, $this->customTypes)) {
            return $this->customTypes[$name] = $class;
        }

        throw new \InvalidArgumentException('Custom field ['.$name.'] already exists on this form object.');
    }
535152
public function addToClass($name, $value)
    {
        if ($value instanceof ContributorInterface) {
            $value->contributeToClass($name, $this);
        } else {
            $this->_nonModelfields[$name] = $value;
        }
    }
55787
protected function createActor($class, $name)
    {
        $actor = Pool::getInstance()->get($class);
        $actor->initialization($name);
        $this->addChild($actor);
        return $actor;
    }
392894
public void addField(String name, Object value, Object type) {
        if (value == null) {
            this.fields.add(new Field(name, null, null));
        } else {
            this.fields.add(new Field(name, value.toString(), type.toString()));
        }
    }
964878
public function addField($name, $decorator = null, $field = null)
    {
        if (!$this->model) {
            $this->model = new \atk4\ui\misc\ProxyModel();
        }

        return $this->layout->addField($name, $decorator, $field);
    }
288214
public static function registerPluginClass(string $name, string $class): bool
    {
        if (class_exists($class) === false) {
            return false;
        }
        if (self::$plugin_classes === null) {
            self::$plugin_classes = [];
        }
        $check = new ReflectionClass($class);
        if ($check->implementsInterface("TheCMSThread\\Classes\\Plugin") === true) {
            self::$plugin_classes[$name] = $class;
            return true;
        } else {
            return false;
        }
    }
461862
public static function createEmbedOne(string $name, string $class): DenormalizationFieldMappingBuilderInterface
    {
        $self = new self($name);
        $self->fieldDenormalizer = new EmbedOneFieldDenormalizer($class, new PropertyAccessor($name));

        return $self;
    }
388052
public function setConstraintClass($name, $class)
    {
        // Ensure class exists
        if (!class_exists($class)) {
            throw new InvalidArgumentException('Unknown constraint ' . $name);
        }
        // Ensure class is appropriate
        if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
            throw new InvalidArgumentException('Invalid class ' . $name);
        }
        $this->constraintMap[$name] = $class;

        return $this;
    }
878444
public void putField(Class<?> cls, String name) throws IOException
    {
        putField(El.getField(cls, name));
    }
501786
private function addProperty(ClassType $class, Field $field)
    {
        $property = $class->addProperty($field->getFieldName());
        $property->setVisibility('protected');
        if (!empty($field->getDescription())) {
            $property->setComment($field->getDescription());
            $property->addComment('');
        }
        $dataType = $this->getPhpDataType($field);
        $property->addComment('@var '.$dataType);
        if ($this->isCollectionType($dataType)) {
            $property->setValue([]);
        }
    }
302724
public function addField($type, $name, array $attributes = [])
    {
        $attributes = array_merge(compact('type', 'name'), $attributes);

        $this->fields[] = $field = new Fluent($attributes);

        return $field;
    }
938538
public function addTaskDefinition($name, $class, $classpath = null)
    {
        ComponentHelper::getComponentHelper($this)->addTaskDefinition($name, $class, $classpath);
    }
629244
public void getField(Class<?> cls, String name) throws IOException
    {
        getField(El.getField(cls, name));
    }
1284677
public static function load($name, $class=null) {
		$descriptorPath = ENTITY_DESCRIPTOR_CONFIG_PATH.$name;
		$cache = new FSCache(self::DESCRIPTORCLASS, $name, filemtime(YAML::getFilePath($descriptorPath)));
		
		// Comment when editing class and entity field types
		$descriptor	= null;
		try {
			if( !defined('ENTITY_ALWAYS_RELOAD')
					&& $cache->get($descriptor)
					&& isset($descriptor->version)
					&& $descriptor->version==self::VERSION ) {
				return $descriptor;
			}
		} catch( Exception $e ) {
			// If file is corrupted (version mismatch ?)
			$cache->reset();
		}
		// Unable to get from cache, building new one
		
		$conf = YAML::build($descriptorPath, true);
		if( empty($conf->fields) ) {
			throw new \Exception('Descriptor file for "'.$name.'" is corrupted, empty or not found, there is no field.');
		}
		// Build descriptor
		//    Parse Config file
		//      Fields
		$fields	= array();
		if( !empty($conf->parent) ) {
			if( !is_array($conf->parent) ) {
				$conf->parent = array($conf->parent);
			}
			foreach( $conf->parent as $p ) {
				$p	= static::load($p);
				if( !empty($p) ) {
					$fields	= array_merge($fields, $p->getFields());
				}
			}
		}
		$IDField = $class ? $class::getIDField() : self::IDFIELD;
		$fields[$IDField] = FieldDescriptor::buildIDField($IDField);
		foreach( $conf->fields as $fieldName => $fieldInfos ) {
			$fields[$fieldName]	= FieldDescriptor::parseType($fieldName, $fieldInfos);
		}

		//      Indexes
		$indexes = array();
		if( !empty($conf->indexes) ) {
			foreach( $conf->indexes as $index ) {
				$iType		= static::parseType(null, $index);
				$indexes[]	= (object) array('name'=>$iType->default, 'type'=>strtoupper($iType->type), 'fields'=>$iType->args);
			}
		}
		//    Save cache output
		$descriptor	= new EntityDescriptor($name, $fields, $indexes, $class);
		if( !empty($conf->flags) ) {
			if( in_array(self::FLAG_ABSTRACT, $conf->flags) ) {
				$descriptor->setAbstract(true);
			}
		}
// 		debug('Entity load('.$name.')', $fields);
		$cache->set($descriptor);
		return $descriptor;
	}
640678
public DynamicReportBuilder addField(String name, String className) {
        return addField(new ColumnProperty(name, className));
    }
4590
public function replaceField($name, $field)
    {
        $index = $this->getFieldIndex($name);
        $this->removeFieldAtIndex($index);
        $this->insertFields($field, $index);
    }
1097093
public FieldRefConstant addFieldRef(String className,
                                      String name,
                                      String type)
  {
    FieldRefConstant entry = getFieldRef(className, name, type);

    if (entry != null)
      return entry;

    ClassConstant classEntry = addClass(className);
    NameAndTypeConstant typeEntry = addNameAndType(name, type);

    entry = new FieldRefConstant(this, _entries.size(),
                                 classEntry.getIndex(),
                                 typeEntry.getIndex());

    addConstant(entry);

    return entry;
  }