SilverStripe SiteConfig标题字段操作

I've set up a SiteConfig extension (declared in yml, tested and confirmed) through which I'm trying to change the Title field (the one for Site title) to a read only field.

I know that in the parent class SiteConfig the Title Field is stored in a variable. SiteConfig line 85: $titleField = new TextField("Title", _t('SiteConfig.SITETITLE', "Site title"))

So in my extension SiteConfigTweaks extends DataExtensions I've tried:

 public function updateCMSFields(FieldList $fields) {
     $titleField->performReadonlyTransformation();
 }

But this doesn't do the trick. What am I missing here?

I suggest you do the following:

public function updateCMSFields(FieldList $fields)
{
    if ($titleField = $fields->dataFieldByName('Title')) {
        $fields->replaceField(
            'Title', 
            $titleField->performReadonlyTransformation()
        );
    }
}

First you get the existing Title-field and also check for its existence. Then you replace the field with its read-only transformed variant.