Пример #1
0
 /**
  * To get HTTP Verb to be used for a binding based on the state of the
  * RelatedEnd object holding the relationship.
  *
  * @param RelatedEnd $binding
  * @return HttpVerb
  */
 public function GetBindingHttpMethod($binding)
 {
     $property = new ReflectionProperty($binding->GetSourceResource(), $binding->GetSourceProperty());
     $attributes = Utility::getAttributes($property);
     $relationShip = $this->_context->GetRelationShip($attributes["Relationship"], $attributes["ToRole"]);
     //SetLink
     if ($relationShip == '0..1' || $relationShip == '1') {
         //SetLink with target null
         if ($binding->GetTargetResource() == null) {
             return HttpVerb::DELETE;
         }
         return HttpVerb::PUT;
     }
     //DeleteLink
     if (EntityStates::Deleted == $binding->State) {
         return HttpVerb::DELETE;
     }
     //AddLink
     return HttpVerb::POST;
 }
Пример #2
0
 /**
  * To check the equality of two RelatedEnd instances.
  *
  * @param RelatedEnd $relatedEnd1
  * @param RelatedEnd $relatedEnd2
  * @Return bool if both ends are equal else false
  */
 public static function Equals($relatedEnd1, $relatedEnd2)
 {
     $targetObjectID1 = $targetObjectID2 = '00000000-0000-0000-0000-000000000000';
     if ($relatedEnd1->GetTargetResource() != null) {
         $targetObjectID1 = $relatedEnd1->GetTargetResource()->getObjectID();
     }
     if ($relatedEnd2->GetTargetResource() != null) {
         $targetObjectID2 = $relatedEnd2->GetTargetResource()->getObjectID();
     }
     if ($relatedEnd1->GetSourceResource()->getObjectID() == $relatedEnd2->GetSourceResource()->getObjectID() && $targetObjectID1 == $targetObjectID2 && $relatedEnd1->GetSourceProperty() == $relatedEnd2->GetSourceProperty()) {
         return TRUE;
     }
     return FALSE;
 }