Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Lti/Edlib/DeepLinking/EdlibContentItemMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public function map(array $data): ContentItem
->withShared(Prop::getOfType($data, 'shared', Prop::TYPE_BOOLEAN))
->withTags(Prop::getArrayOfType($data, 'tag', Prop::TYPE_NORMALIZED_STRING))
->withOwnerEmail(Prop::getOfType($data, 'ownerEmail', Prop::TYPE_NORMALIZED_STRING))
->withContentType(Prop::getOfType($data, 'contentType', Prop::TYPE_NORMALIZED_STRING))
->withContentTypeName(Prop::getOfType($data, 'contentTypeName', Prop::TYPE_NORMALIZED_STRING))
;
}

Expand Down
30 changes: 30 additions & 0 deletions src/Lti/Edlib/DeepLinking/EdlibLtiLinkItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class EdlibLtiLinkItem extends LtiLinkItem

private string|null $ownerEmail = null;

private string|null $contentType = null;

private string|null $contentTypeName = null;

/**
* @var list<string>
*/
Expand Down Expand Up @@ -123,4 +127,30 @@ public function withOwnerEmail(string|null $email): static

return $self;
}

public function getContentType(): string|null
{
return $this->contentType;
}

public function withContentType(string|null $type): static
{
$self = clone $this;
$self->contentType = $type;

return $self;
}

public function getContentTypeName(): string|null
{
return $this->contentTypeName;
}

public function withContentTypeName(string|null $name): static
{
$self = clone $this;
$self->contentTypeName = $name;

return $self;
}
}
8 changes: 8 additions & 0 deletions src/Lti/Edlib/DeepLinking/EdlibLtiLinkItemSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public function serialize(LtiLinkItem $item): array
if ($item->getOwnerEmail() !== null) {
$serialized['ownerEmail'] = $item->getOwnerEmail();
}

if ($item->getContentType() !== null) {
$serialized['contentType'] = $item->getContentType();
}

if ($item->getContentTypeName() !== null) {
$serialized['contentTypeName'] = $item->getContentTypeName();
}
}

return $serialized;
Expand Down
4 changes: 4 additions & 0 deletions tests/Lti/Edlib/EdlibContentItemMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public function testMapsEdlibExtensions(): void
'shared' => false,
'tag' => 'foo',
'ownerEmail' => 'owner@example.com',
'contentType' => 'fake.fancy_content',
'contentTypeName' => 'FancyContent',
],
],
]);
Expand All @@ -50,6 +52,8 @@ public function testMapsEdlibExtensions(): void
$this->assertTrue($items[0]->isPublished());
$this->assertSame(['foo'], $items[0]->getTags());
$this->assertSame('owner@example.com', $items[0]->getOwnerEmail());
$this->assertSame('fake.fancy_content', $items[0]->getContentType());
$this->assertSame('FancyContent', $items[0]->getContentTypeName());
}

public function testMapsMultipleTags(): void
Expand Down
8 changes: 8 additions & 0 deletions tests/Lti/Edlib/EdlibContentItemsSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function testAddsJsonldContextAndSerializesEdlibExtensions(): void
->withShared(true)
->withTags(['foo'])
->withOwnerEmail('owner@example.com')
->withContentType('fake.fancy_content')
->withContentTypeName('FancyContent')
]);

$this->assertArrayHasKey('@context', $data);
Expand Down Expand Up @@ -65,6 +67,12 @@ public function testAddsJsonldContextAndSerializesEdlibExtensions(): void

$this->assertArrayHasKey('ownerEmail', $data['@graph'][0]);
$this->assertSame('owner@example.com', $data['@graph'][0]['ownerEmail']);

$this->assertArrayHasKey('contentType', $data['@graph'][0]);
$this->assertSame('fake.fancy_content', $data['@graph'][0]['contentType']);

$this->assertArrayHasKey('contentTypeName', $data['@graph'][0]);
$this->assertSame('FancyContent', $data['@graph'][0]['contentTypeName']);
}

public function testSerializesMultipleTags(): void
Expand Down