コード例 #1
0
 /**
  * Writes an XML string representing the rule info instance. 
  * 
  * @param XMLWriter $xmlWriter The XML writer. 
  * 
  * @return none
  */
 public function writeXml($xmlWriter)
 {
     $content = null;
     if (!is_null($this->_ruleDescription)) {
         $content = new Content();
         $content->setText(XmlSerializer::objectSerialize($this->_ruleDescription, 'RuleDescription'));
     }
     $this->_entry->setContent($content);
     $this->_entry->writeXml($xmlWriter);
 }
コード例 #2
0
 /**
  * Creates a rule. 
  *
  * @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780774
  * 
  * @param string   $topicPath        The path of the topic.
  * @param string   $subscriptionName The name of the subscription. 
  * @param RuleInfo $ruleInfo         The information of the rule.
  *
  * @return RuleInfo
  */
 public function createRule($topicPath, $subscriptionName, $ruleInfo)
 {
     $httpCallContext = new HttpCallContext();
     $httpCallContext->setMethod(Resources::HTTP_PUT);
     $httpCallContext->addStatusCode(Resources::STATUS_CREATED);
     $httpCallContext->addHeader(Resources::CONTENT_TYPE, Resources::ATOM_ENTRY_CONTENT_TYPE);
     $rulePath = sprintf(Resources::RULE_PATH, $topicPath, $subscriptionName, $ruleInfo->getTitle());
     $ruleDescriptionXml = XmlSerializer::objectSerialize($ruleInfo->getRuleDescription(), 'RuleDescription');
     $entry = new Entry();
     $content = new Content($ruleDescriptionXml);
     $content->setType(Resources::XML_CONTENT_TYPE);
     $entry->setContent($content);
     $entry->setAttribute(Resources::XMLNS, Resources::SERVICE_BUS_NAMESPACE);
     $xmlWriter = new \XMLWriter();
     $xmlWriter->openMemory();
     $entry->writeXml($xmlWriter);
     $httpCallContext->setBody($xmlWriter->outputMemory());
     $httpCallContext->setPath($rulePath);
     $response = $this->sendContext($httpCallContext);
     $ruleInfo = new ruleInfo();
     $ruleInfo->parseXml($response->getBody());
     return $ruleInfo;
 }
コード例 #3
0
 /**
  * Wraps media services entity with Atom entry
  *
  * @param object $entity Media services entity
  * @param array  $links  AtomLinks to other media services entities
  *
  * @return XML string representing Atom Entry
  */
 protected function wrapAtomEntry($entity, $links = null)
 {
     Validate::notNull($entity, 'entity');
     $content = new Content();
     $content->setType(Resources::XML_CONTENT_TYPE);
     $content->setText(ContentPropertiesSerializer::serialize($entity));
     $atomEntry = new Entry();
     $atomEntry->setContent($content);
     if ($links) {
         Validate::isArray($links, 'links');
         $atomEntry->setLink($links);
     }
     $xmlWriter = new \XMLWriter();
     $xmlWriter->openMemory();
     $atomEntry->writeXml($xmlWriter);
     return $xmlWriter->outputMemory();
 }
コード例 #4
0
ファイル: Entry.php プロジェクト: yszar/linuxwp
 /**
  * Creates an ATOM ENTRY instance with specified simpleXML object
  *
  * @param \SimpleXMLElement $entryXml xml element of ATOM ENTRY
  *
  * @return none
  */
 public function fromXml($entryXml)
 {
     Validate::notNull($entryXml, 'entryXml');
     Validate::isA($entryXml, '\\SimpleXMLElement', 'entryXml');
     $this->attributes = (array) $entryXml->attributes();
     $entryArray = (array) $entryXml;
     if (array_key_exists(Resources::AUTHOR, $entryArray)) {
         $this->author = $this->processAuthorNode($entryArray);
     }
     if (array_key_exists(Resources::CATEGORY, $entryArray)) {
         $this->category = $this->processCategoryNode($entryArray);
     }
     if (array_key_exists('content', $entryArray)) {
         $content = new Content();
         $content->fromXml($entryArray['content']);
         $this->content = $content;
     }
     if (array_key_exists(Resources::CONTRIBUTOR, $entryArray)) {
         $this->contributor = $this->processContributorNode($entryArray);
     }
     if (array_key_exists('id', $entryArray)) {
         $this->id = (string) $entryArray['id'];
     }
     if (array_key_exists(Resources::LINK, $entryArray)) {
         $this->link = $this->processLinkNode($entryArray);
     }
     if (array_key_exists('published', $entryArray)) {
         $this->published = $entryArray['published'];
     }
     if (array_key_exists('rights', $entryArray)) {
         $this->rights = $entryArray['rights'];
     }
     if (array_key_exists('source', $entryArray)) {
         $source = new Source();
         $source->parseXml($entryArray['source']->asXML());
         $this->source = $source;
     }
     if (array_key_exists('title', $entryArray)) {
         $this->title = $entryArray['title'];
     }
     if (array_key_exists('updated', $entryArray)) {
         $this->updated = \DateTime::createFromFormat(\DateTime::ATOM, (string) $entryArray['updated']);
     }
 }
コード例 #5
0
 /**
  * Returns a XML string based on ATOM ENTRY schema. 
  * 
  * @param \XMLWriter $xmlWriter The XML writer.
  *
  * @return none
  */
 public function writeXml($xmlWriter)
 {
     $content = null;
     if (!is_null($this->_queueDescription)) {
         $content = new Content();
         $content->setText(XmlSerializer::objectSerialize($this->_queueDescription, 'QueueDescription'));
         $content->setType(Resources::XML_CONTENT_TYPE);
     }
     $this->_entry->setContent($content);
     $this->_entry->writeXml($xmlWriter);
 }
コード例 #6
0
 /**
  * @covers WindowsAzure\Common\Internal\Atom\Content::fromXml
  */
 public function testFromXml()
 {
     // Setup
     $testText = 'SomeName';
     $testKey = 'name';
     $innerText = '<test>test string</test>';
     $xmlString = "<content>{$innerText}</content>";
     $atomContent = new Content();
     $xml = simplexml_load_string($xmlString);
     // Test
     $atomContent->fromXml($xml);
     // Assert
     $this->assertEquals($innerText, $atomContent->getText());
     $this->assertEquals($xml, $atomContent->getXml());
 }
コード例 #7
0
 /**
  * @covers WindowsAzure\Common\Internal\Atom\Entry::getContent
  * @covers WindowsAzure\Common\Internal\Atom\Entry::setContent
  */
 public function testEntryGetSetContent()
 {
     // Setup
     $expected = new Content();
     $expected->setText('testText');
     $entry = new Entry();
     // Test
     $entry->setContent($expected);
     $actual = $entry->getContent();
     // Assert
     $this->assertEquals($expected->getText(), $actual->getText());
 }