LTI Integration Library 4.10.3
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
SecurityContract.php
1<?php
2
3namespace ceLTIc\LTI\MediaType;
4
6
15{
16
22 public $shared_secret = null;
23
29 public $tool_service = null;
30
37 function __construct($tool, $secret)
38 {
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);
43 }
44 }
45
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]}";
57 }
58 }
59 $toolService = new \stdClass;
60 $toolService->{'@type'} = 'RestServiceProfile';
61 $toolService->service = $id;
62 $toolService->action = $requiredService->actions;
63 $toolServices[$service->{'@id'}] = $toolService;
64 }
65 }
66 }
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]}";
76 }
77 }
78 $toolService = new \stdClass;
79 $toolService->{'@type'} = 'RestServiceProfile';
80 $toolService->service = $id;
81 $toolService->action = $optionalService->actions;
82 $toolServices[$service->{'@id'}] = $toolService;
83 }
84 }
85 }
86 $this->tool_service = array_values($toolServices);
87 }
88
89}
Class to represent an LTI Security Contract document.
__construct($tool, $secret)
Class constructor.
Class to represent an LTI Tool.
Definition Tool.php:24