'title', 'title' => E::ts('Campaign Title'), 'type' => CRM_Utils_Type::T_STRING, 'api.required' => 1, 'description' => E::ts('Title of the Campaign'), ]; $spec['project_type'] = [ 'name' => 'project_type', 'title' => E::ts('Twingle Project Type'), 'type' => CRM_Utils_Type::T_STRING, 'api.required' => 0, 'description' => E::ts('The type of the Twingle Project'), ]; $spec['allow_more'] = [ 'name' => 'allow_more', 'title' => E::ts('Allow more'), 'type' => CRM_Utils_Type::T_BOOLEAN, 'api.required' => 0, 'description' => E::ts('Allow to donate more than is defined in the target'), ]; } /** * TwingleProject.Create API * * @param array $params * * @return array * API result descriptor * * @throws \Exception * @see civicrm_api3_create_success * */ function civicrm_api3_twingle_project_Create($params) { $title = $params['title']; $name = strtolower(preg_replace('/[^A-Za-z0-9]/', '_', $title)); $type = $params['project_type'] ?? 'default'; $allow_more = $params['allow_more'] ?? 1; $values = [ 'title' => $title, 'name' => $name, 'type' => $type, 'allow_more' => $allow_more, ]; $project = new TwingleProject($values, 'CIVICRM'); $project->create(); $sync = $result = civicrm_api3('TwingleSync', 'post'); if ($sync['is_error'] == 0) { $returnValues = civicrm_api3(); } $returnValues = null; return civicrm_api3_create_success($returnValues, $params, 'TwingleProject', 'Create'); }