3namespace ceLTIc\LTI\MediaType;
39 $tcContexts = array();
40 foreach ($tool->platform->profile->{
'@context'} as $context) {
41 if (is_object($context)) {
42 $tcContexts = array_merge(get_object_vars($context), $tcContexts);
46 $this->shared_secret = $secret;
47 $toolServices = array();
48 foreach ($tool->requiredServices as $requiredService) {
49 foreach ($requiredService->formats as $format) {
50 $service = $tool->findService($format, $requiredService->actions);
51 if (($service !==
false) && !array_key_exists($service->{
'@id'}, $toolServices)) {
52 $id = $service->{
'@id'};
53 $parts = explode(
':', $id, 2);
54 if (count($parts) > 1) {
55 if (array_key_exists($parts[0], $tcContexts)) {
56 $id =
"{$tcContexts[$parts[0]]}{$parts[1]}";
59 $toolService = new \stdClass;
60 $toolService->{
'@type'} =
'RestServiceProfile';
61 $toolService->service = $id;
62 $toolService->action = $requiredService->actions;
63 $toolServices[$service->{
'@id'}] = $toolService;
67 foreach ($tool->optionalServices as $optionalService) {
68 foreach ($optionalService->formats as $format) {
69 $service = $tool->findService($format, $optionalService->actions);
70 if (($service !==
false) && !array_key_exists($service->{
'@id'}, $toolServices)) {
71 $id = $service->{
'@id'};
72 $parts = explode(
':', $id, 2);
73 if (count($parts) > 1) {
74 if (array_key_exists($parts[0], $tcContexts)) {
75 $id =
"{$tcContexts[$parts[0]]}{$parts[1]}";
78 $toolService = new \stdClass;
79 $toolService->{
'@type'} =
'RestServiceProfile';
80 $toolService->service = $id;
81 $toolService->action = $optionalService->actions;
82 $toolServices[$service->{
'@id'}] = $toolService;
86 $this->tool_service = array_values($toolServices);