예제 #1
0
 /**
  * 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();
 }