8.5.2: How to delete attribute key?

Permalink
I'm trying to delete an attribute key:
$service = $this->app->make('Concrete\Core\Attribute\Category\CategoryService');
$categoryEntity = $service->getByHandle('collection');
$category = $categoryEntity->getController();
$key = $category->getByHandle('disable_copy');
if (is_object($key)) {
    $key->delete();
}

but it throws a "Call to undefined method Concrete\Core\Entity\Attribute\Key\PageKey::delete()".

How can I delete an attribute key?

Thank you.

linuxoid
 
linuxoid replied on at Permalink Best Answer Reply
linuxoid
Got it.
$category->deleteKey($key);