コード例 #1
0
ファイル: SaveResult.php プロジェクト: silviogarbes/phpodata
 /**
  * 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;
 }