Skip to content

Commit

Permalink
feat: Add parent_case field support
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbarletta authored Jan 25, 2018
1 parent d0115bc commit cfde61e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions graphql/Schema/CallType.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ public function build($config) // implementing an abstract function where you b
}
},
]);
$config->addField('parent_case', [
'type' => new CaseType(),
'args' => argsHelper::entityArgsHelper('Cases'),
'resolve' => function ($value, array $args, ResolveInfo $info) {
file_put_contents($_SERVER["DOCUMENT_ROOT"]."/lx.log", PHP_EOL. date_format(date_create(),"Y-m-d H:i:s ") .__FILE__ .":". __LINE__." -- ".print_r($value, 1).PHP_EOL, FILE_APPEND);
if (!empty($value['parent_case'])) {
$args['id']=$value['parent_case'];
return CaseType::resolve($value, $args, $info);
} else {
return null;
}
},
]);
$config->addField('parent_opportunity', [
'type' => new OpportunityType(),
'args' => argsHelper::entityArgsHelper('Opportunities'),
Expand Down Expand Up @@ -169,25 +182,35 @@ private function retrieveCall($id, $info)
}

switch ($module_arr['parent_type']) {
case 'Cases':
$module_arr['parent_case'] = $module_arr['parent_id'];
$module_arr['parent_contact'] = '';
$module_arr['parent_account'] = '';
$module_arr['parent_opportunity'] = '';
break;
case 'Contacts':
$module_arr['parent_contact'] = $module_arr['parent_id'];
$module_arr['parent_account'] = '';
$module_arr['parent_opportunity'] = '';
$module_arr['parent_case'] = '';
break;
case 'Accounts':
$module_arr['parent_account'] = $module_arr['parent_id'];
$module_arr['parent_contact'] = '';
$module_arr['parent_opportunity'] = '';
$module_arr['parent_case'] = '';
break;
case 'Opportunities':
$module_arr['parent_opportunity'] = $module_arr['parent_id'];
$module_arr['parent_contact'] = '';
$module_arr['parent_account'] = '';
$module_arr['parent_case'] = '';
break;
default:
$module_arr['parent_opportunity'] = '';
$module_arr['parent_contact'] = '';
$module_arr['parent_account'] = '';
$module_arr['parent_case'] = '';
break;

}
Expand Down

0 comments on commit cfde61e

Please sign in to comment.