本文整理汇总了PHP中app\models\Object::setNode方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::setNode方法的具体用法?PHP Object::setNode怎么用?PHP Object::setNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Object
的用法示例。
在下文中一共展示了Object::setNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setValidationStatus
/**
* Set the validation status of a certain object
*
* @param integer $objectId The id of the object
* @param string $status The new status of the object
* @param array $feedback The given feedback on different properties
*
* @return Node
*/
public function setValidationStatus($objectId, $status, $feedback)
{
$objectNode = $this->getById($objectId);
$relationships = $objectNode->getRelationships(['P2'], Relationship::DirectionOut);
foreach ($relationships as $relationship) {
$typeNode = $relationship->getEndNode();
$relationship->delete();
$typeNode->delete();
}
$object = new Object();
$object->setNode($objectNode);
$typeNode = $object->createValueNode('objectValidationStatus', ['E55', 'objectValidationStatus'], $status);
if (!empty($feedback)) {
// Append the feedback if feedback already exists
$currentFeedback = $objectNode->getProperty('feedback');
if (!empty($currentFeedback)) {
$currentFeedback = json_decode($currentFeedback, true);
} else {
$currentFeedback = [];
}
$currentFeedback[] = $feedback;
$objectNode->setProperty('feedback', json_encode($currentFeedback))->save();
}
return $objectNode->relateTo($typeNode, 'P2')->save();
}