Google\Spreadsheet\Batch\BatchRequest::createRequestXml PHP Method

createRequestXml() public method

public createRequestXml ( CellFeed $cellFeed ) : SimpleXMLElement
$cellFeed Google\Spreadsheet\CellFeed
return SimpleXMLElement
    public function createRequestXml(CellFeed $cellFeed)
    {
        if (count($this->entries) === 0) {
            throw new EmptyBatchException();
        }
        $feed = new \SimpleXMLElement("\n            <feed\n                xmlns=\"http://www.w3.org/2005/Atom\"\n                xmlns:batch=\"http://schemas.google.com/gdata/batch\"\n                xmlns:gs=\"http://schemas.google.com/spreadsheets/2006\">\n            </feed>\n        ");
        $feed->id = $cellFeed->getPostUrl();
        $i = 1;
        foreach ($this->entries as $cellEntry) {
            $entry = $feed->addChild("entry");
            $entry->addChild("xmlns:batch:id", "A" . $i++);
            $op = $entry->addChild("xmlns:batch:operation");
            $op->addAttribute("type", "update");
            $entry->addChild("id", $cellFeed->getPostUrl() . "/" . $cellEntry->getCellIdString());
            $link = $entry->addChild("link");
            $link->addAttribute("rel", "edit");
            $link->addAttribute("type", "application/atom+xml");
            $link->addAttribute("href", $cellEntry->getEditUrl());
            $cell = $entry->addChild("xmlns:gs:cell");
            $cell->addAttribute("row", $cellEntry->getRow());
            $cell->addAttribute("col", $cellEntry->getColumn());
            $cell->addAttribute("inputValue", $cellEntry->getContent());
        }
        return $feed;
    }

Usage Example

Beispiel #1
0
 /**
  *
  * @param \Google\Spreadsheet\Batch\BatchRequest $batchRequest
  *
  * @return \Google\Spreadsheet\Batch\BatchResponse
  */
 public function insertBatch(BatchRequest $batchRequest)
 {
     $xml = $batchRequest->createRequestXml($this);
     $response = ServiceRequestFactory::getInstance()->addHeader("If-Match", "*")->post($this->getBatchUrl(), $xml);
     ServiceRequestFactory::getInstance()->removeHeader("If-Match");
     return new BatchResponse(new SimpleXMLElement($response));
 }
All Usage Examples Of Google\Spreadsheet\Batch\BatchRequest::createRequestXml