本文整理汇总了PHP中ArtefactType::attach方法的典型用法代码示例。如果您正苦于以下问题:PHP ArtefactType::attach方法的具体用法?PHP ArtefactType::attach怎么用?PHP ArtefactType::attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArtefactType
的用法示例。
在下文中一共展示了ArtefactType::attach方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_attachment
/**
* helper function to create attachments between entries.
* The 2010-07 version of leap2a says that linked *entries* should use related relation,
* and directly linked files (attachments) should use enclosures.
* However, for BC we should support both.
* This function supports both and additionally creates the File artefacts for attachments, then links them.
*
* @param SimpleXMLElement $entry the entry we want to attach things *to*
* @param SimpleXMLElement $link the link to inspect
* @param ArtefactType $artefact the artefact that has been created from the entry.
*
* @return void|int the id of a *newly created* attached artefact
*/
public function create_attachment(SimpleXMLElement $entry, SimpleXMLElement $link, ArtefactType &$artefact)
{
if (($this->curie_equals($link['rel'], '', 'enclosure') || $this->curie_equals($link['rel'], '', 'related')) && isset($link['href'])) {
$this->trace("Attaching file {$link['href']} to comment {$entry->id}", PluginImportLeap::LOG_LEVEL_VERBOSE);
$artefactids = $this->get_artefactids_imported_by_entryid((string) $link['href']);
if (isset($artefactids[0])) {
$artefact->attach($artefactids[0]);
} else {
// it may be just an attached file, with no Leap2A element in its own right ....
if ($id = $this->create_linked_file($entry, $link)) {
$artefact->attach($id);
return $id;
}
}
}
}