Example #1
0
 /**
  * Class constructor from context.
  *
  * @param Context $context Context object
  * @param string $ltiResourceLinkId Resource link ID value
  * @param string $tempId Temporary Resource link ID value (optional, default is null)
  * @return ResourceLink
  */
 public static function fromContext($context, $ltiResourceLinkId, $tempId = null)
 {
     $resourceLink = new ResourceLink();
     $resourceLink->setContextId($context->getRecordId());
     $resourceLink->context = $context;
     $resourceLink->dataConnector = $context->getDataConnector();
     $resourceLink->ltiResourceLinkId = $ltiResourceLinkId;
     if (!empty($ltiResourceLinkId)) {
         $resourceLink->load();
         if (is_null($resourceLink->id) && !empty($tempId)) {
             $resourceLink->ltiResourceLinkId = $tempId;
             $resourceLink->load();
             $resourceLink->ltiResourceLinkId = $ltiResourceLinkId;
         }
     }
     return $resourceLink;
 }