本文整理汇总了PHP中Relationship::setRelationshipTypeId方法的典型用法代码示例。如果您正苦于以下问题:PHP Relationship::setRelationshipTypeId方法的具体用法?PHP Relationship::setRelationshipTypeId怎么用?PHP Relationship::setRelationshipTypeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Relationship
的用法示例。
在下文中一共展示了Relationship::setRelationshipTypeId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setValuesArray
protected function setValuesArray($valuesArray)
{
$this->valuesArray = $valuesArray;
// if(!isset($valuesArray["attribute_metadata"])) {
// throw new Exception("Unable to initialize item without metadata");
// }
$this->initializeBaseFields($valuesArray);
$cachedAttributeMetadata = array();
foreach ($valuesArray as $key => $value) {
if (preg_match('/^' . preg_quote("_ca_attribute_") . "/", $key)) {
$va_tmp = explode('attribute_', $key);
$elementId = $va_tmp[1];
$this->addAttributeMetadata($elementId, $valuesArray["attribute_metadata"][$elementId]);
$this->setAttributeValue($elementId, $value);
}
}
//read attribute extended values
if (isset($valuesArray["extended_values"]) && is_array($valuesArray["extended_values"])) {
$attritbutes = $valuesArray["extended_values"];
foreach ($attritbutes as $key => $attributevalues) {
foreach ($attributevalues as $attribute) {
$this->addAttributeExtendedValue($key, array_pop($attribute['opa_values']));
}
}
}
if (isset($valuesArray["relationships"]) && is_array($valuesArray["relationships"])) {
//read relations data and wrap it into Relationship.php array()
$relations = $valuesArray["relationships"];
foreach ($relations as $key => $value) {
$relationship = new Relationship(array('relation_id' => $value["relation_id"], 'related_object_type' => $value["related_object_type"], 'item_info_service' => $this->itemInfoController));
if (isset($value["displayname"])) {
$displayname = $value["displayname"];
} elseif (isset($value['name_singular'])) {
$displayname = $value['name_singular'];
} elseif (isset($value["name"])) {
$displayname = $value["name"];
} else {
$displayname = '';
}
$relationship->setDisplayName($displayname);
$relationship->setRelationshipTypeId($value["relationship_type_id"]);
$relationship->setRelationshipTypeName($value["relationship_type_name"]);
$relationship->setRelatedObjectId($value);
$this->addRelation($relationship);
}
}
if (isset($valuesArray["labels"]) && is_array($valuesArray["labels"])) {
$labels = $valuesArray["labels"];
foreach ($labels as $lang) {
foreach ($lang as $id => $value) {
$label_id = $id;
if (isset($value['label_id'])) {
$label_id = $value['label_id'];
}
if (isset($value['name'])) {
$name = $value['name'];
} elseif (isset($value['name_plural'])) {
$name = $value['name_plural'];
}
$label = new Label(array('label_id' => $label_id, 'locale' => $value['locale_language'], 'is_preferred' => $value['is_preferred'], 'value' => $name));
$this->addLabel($label);
}
}
}
if (isset($valuesArray["tags"]) && is_array($valuesArray["tags"])) {
foreach ($valuesArray["tags"] as $tag_array) {
if (!isset($tag_array["moderated_by_user_id"]) || $tag_array["moderated_by_user_id"] == null || ($tag_array["moderated_by_user_id"] = '')) {
// comment has not been moderated yet
} else {
$newtag = new Tag(array('tag_id' => $tag_array["tag_id"], 'locale_id' => $tag_array["locale_id"], 'values' => $tag_array));
$this->addTag($newtag);
}
}
}
if (isset($valuesArray["rating"]) && is_array($valuesArray["rating"])) {
$this->setTotalNumberOfVotes($valuesArray["rating"]["total"]);
$this->setAverageRating($valuesArray["rating"]["average"]);
}
if (isset($valuesArray["comments"]) && is_array($valuesArray["comments"])) {
foreach ($valuesArray["comments"] as $comment_arr) {
if (!isset($comment_arr["moderated_by_user_id"]) || $comment_arr["moderated_by_user_id"] == null || ($comment_arr["moderated_by_user_id"] = '')) {
// comment has not been moderated yet
} else {
$newcomment = new Comment(array('comment_id' => $comment_arr["comment_id"], 'locale_id' => $comment_arr["locale_id"], 'values' => $comment_arr));
$this->addComment($newcomment);
}
}
}
if (isset($valuesArray["hierarchy"]) && is_array($valuesArray["hierarchy"])) {
$ancestors = array();
$ancestorArr = $valuesArray['hierarchy']['ancestors'];
foreach ($ancestorArr as $k => $a) {
$options = array('idno' => $a['idno'], 'parent_id' => $a['parent_id'], 'item_info_controller' => $this->itemInfoController, 'table' => $this->getTable());
$ancestor = new BasicNode($a['id'], $options);
$labelArr = $a['label'];
while (count($labelArr) == 1) {
$labelArr = array_pop($labelArr);
}
$label_id = 0;
if (isset($labelArr['label_id'])) {
//.........这里部分代码省略.........