LTI Integration Library  3.1.0
PHP class library for building LTI integrations
SecurityContract.php
Go to the documentation of this file.
1 <?php
2 
3 namespace ceLTIc\LTI\MediaType;
4 
6 
16 {
17 
24  function __construct($toolProvider, $secret)
25  {
26  $tcContexts = array();
27  foreach ($toolProvider->consumer->profile->{'@context'} as $context) {
28  if (is_object($context)) {
29  $tcContexts = array_merge(get_object_vars($context), $tcContexts);
30  }
31  }
32 
33  $this->shared_secret = $secret;
34  $toolServices = array();
35  foreach ($toolProvider->requiredServices as $requiredService) {
36  foreach ($requiredService->formats as $format) {
37  $service = $toolProvider->findService($format, $requiredService->actions);
38  if (($service !== false) && !array_key_exists($service->{'@id'}, $toolServices)) {
39  $id = $service->{'@id'};
40  $parts = explode(':', $id, 2);
41  if (count($parts) > 1) {
42  if (array_key_exists($parts[0], $tcContexts)) {
43  $id = "{$tcContexts[$parts[0]]}{$parts[1]}";
44  }
45  }
46  $toolService = new \stdClass;
47  $toolService->{'@type'} = 'RestServiceProfile';
48  $toolService->service = $id;
49  $toolService->action = $requiredService->actions;
50  $toolServices[$service->{'@id'}] = $toolService;
51  }
52  }
53  }
54  foreach ($toolProvider->optionalServices as $optionalService) {
55  foreach ($optionalService->formats as $format) {
56  $service = $toolProvider->findService($format, $optionalService->actions);
57  if (($service !== false) && !array_key_exists($service->{'@id'}, $toolServices)) {
58  $id = $service->{'@id'};
59  $parts = explode(':', $id, 2);
60  if (count($parts) > 1) {
61  if (array_key_exists($parts[0], $tcContexts)) {
62  $id = "{$tcContexts[$parts[0]]}{$parts[1]}";
63  }
64  }
65  $toolService = new \stdClass;
66  $toolService->{'@type'} = 'RestServiceProfile';
67  $toolService->service = $id;
68  $toolService->action = $optionalService->actions;
69  $toolServices[$service->{'@id'}] = $toolService;
70  }
71  }
72  }
73  $this->tool_service = array_values($toolServices);
74  }
75 
76 }
__construct($toolProvider, $secret)
Class constructor.
Class to represent an LTI Security Contract document.
Class to represent an LTI Tool Provider.