/**
  * @task apps
  */
 public static function getObjectFields(PhabricatorCustomFieldInterface $object, $role)
 {
     try {
         $attachment = $object->getCustomFields();
     } catch (PhabricatorDataNotAttachedException $ex) {
         $attachment = new PhabricatorCustomFieldAttachment();
         $object->attachCustomFields($attachment);
     }
     try {
         $field_list = $attachment->getCustomFieldList($role);
     } catch (PhabricatorCustomFieldNotAttachedException $ex) {
         $base_class = $object->getCustomFieldBaseClass();
         $spec = $object->getCustomFieldSpecificationForRole($role);
         if (!is_array($spec)) {
             throw new Exception(pht("Expected an array from %s for object of class '%s'.", 'getCustomFieldSpecificationForRole()', get_class($object)));
         }
         $fields = self::buildFieldList($base_class, $spec, $object);
         foreach ($fields as $key => $field) {
             if (!$field->shouldEnableForRole($role)) {
                 unset($fields[$key]);
             }
         }
         foreach ($fields as $field) {
             $field->setObject($object);
         }
         $field_list = new PhabricatorCustomFieldList($fields);
         $attachment->addCustomFieldList($role, $field_list);
     }
     return $field_list;
 }