-
Notifications
You must be signed in to change notification settings - Fork 40
Link and Content service
Stephen Vickers edited this page Dec 12, 2025
·
1 revision
The Link and Content service allows a tool to manage the links and content-items which have been created for it with a platform.
The Link and Content service class offers the following methods:
- for context-level endpoints:
-
getAll- gets all the links and content-items for the tool in the context, and allows the following optional parameter:-
$ltiResourceLinkId- limit the information to ones which are associated with the specified resource link -
$limit- used to limit the number of group sets or groups are requested to be included in each response
-
-
createContentItem- create a new link or content-item in the context
-
- for item-level endpoints:
-
get- get the item -
saveContentItem- update the item -
deleteContentItem- delete the item
-
$limit = null; // An optional limit on each response can be set
$items = $context->getContentItems($limit);
The default limit for the size of response pages from the platform can be overridden by changing the value of the Service\LinkContent::$defaultLimit property. The limit only affects the number of requests made to the platform; all of
the items will always be returned.
$contentItem = $resourceLink->getContentItem();
The value of $item will be false if the request was not successful.
use ceLTIc\LTI\ContentItem\ContentItem;
$contentItem = ContentItem::fromEndpoint($platform, $endpoint);
The value of $item will be false if the request was not successful.
use ceLTIc\LTI\Content\Item;
use ceLTIc\LTI\ContentItem\ContentItem;
$contentItem = ContentItem::fromType(Item::TYPE_LTI_LINK); // Sample content-item to be created
$item = $contentItem->getItem();
$item->setTitle('A new LTI link');
$item->setText('This link was created automatically by the tool.');
$item->setUrl('');
$item->addCustom('username', '$User.username');
$ok = $context->createContentItem($contentItem);
use ceLTIc\LTI\ContentItem\ContentItem;
$item = $contentItem->getItem();
$item->title = 'A new title';
$linkContentService->saveContentItem($contentItem);
For the content-item represented by a resource link object:
$ok = $resourceLink->deleteContentItem();
For a content-item known by its id (endpoint):
$ok = $contentItem->delete($platform);
© 2025 Stephen P Vickers. All Rights Reserved.