Trying to programmatically add page owner as page text attribute in template

Permalink
Hello all. Currently on concrete 5.7.5. I'm trying to add the page author string as a text attribute when a page is created through a template. Trying to automate this to save my users any problem. I've gotten this far already with help from some others.

$ownerID = $c->getCollectionUserID();
        $ui = UserInfo::getByID($ownerID);
        $ownerName = $ui->getUserName();
        $name = $ui->getAttribute('name');
        if ($name):
           echo 'This is my '.$name;
        else :
           echo $ownerName;
        endif;    
        use \Concrete\Core\Attribute\Type as AttributeType;
        $textAttributeType = AttributeType::getByHandle('text');
        $textAttribute = CollectionAttributeKey::add($type, array(
            'akHandle' => $ownerName, 
            'akName' => $name,
            'akIsSearchable' => false,

The problem is I keep getting the following error: Call to a member function getAttributeTypeID() on null.

The owner name portion works and echos appropriately. It just won't go forward beyond that. Now my goal is to first create the attribute before attaching it to the current page. But it seems like no dice. I'm sure there's something I don't understand. Could someone please help? Thanks much. - Ife