Drest\DrestException::unableToHandleACollectionPush PHP Method

unableToHandleACollectionPush() public static method

public static unableToHandleACollectionPush ( )
    public static function unableToHandleACollectionPush()
    {
        return new self('Requests to push data (PUT/POST/PATCH) can only be used on individual elements.' . ' Data collections cannot be pushed');
    }

Usage Example

Example #1
0
 /**
  * Configure the expose object to filter out fields that are not allowed to be use by the client.
  * Unlike the configuring of the Pull request, this function will return the formatted array in a ResultSet object
  * This is only applicable for a HTTP push (POST/PUT/PATCH) call
  * @param  array                  $pushed - the data push on the request
  * @throws \Drest\DrestException
  * @return \DrestCommon\ResultSet
  *
  * @todo: this should follow the same pattern as configurePullRequest
  */
 public function configurePushRequest($pushed)
 {
     // Offset the array by one of it has a string key and is size of 1
     if (sizeof($pushed) == 1 && is_string(key($pushed))) {
         $rootKey = key($pushed);
         $pushed = $this->filterPushExpose($pushed[key($pushed)], $this->fields);
         return ResultSet::create($pushed, $rootKey);
     } else {
         throw DrestException::unableToHandleACollectionPush();
     }
 }