public function addField(FieldInterface $field): Definition
    {
        $name = $field->getName();

        if ($this->hasField($name)) {
            throw new DefinitionException("Field '$name' is already defined.");
        }

        $this->fields[$name] = $field;

        return $this;
    }
public function addField(FieldInterface $field): Definition
    {
        $name = $field->getName();

        if ($this->hasField($name)) {
            throw new DefinitionException("Field '$name' is already defined.");
        }

        $this->fields[$name] = $field;

        return $this;
    }
public function addField ( FieldInterface $ field ) : Definition { $ name = $ field -> getName ( ) ; if ( $ this -> hasField ( $ name ) ) { throw new DefinitionException ( "Field '$name' is already defined." ) ; } $ this -> fields [ $ name ] = $ field ; return $ this ; }
Adds the field.

@param FieldInterface $field

@return $this|Definition
Adds the field .