Esempio n. 1
0
 /**
  * Write an entity type and associated attributes.
  * 
  * @param ResourceType $resourceType                            Resource type
  * @param array        $associationTypesInResourceTypeNamespace Collection of 
  * association types for the given resource types
  * array(string, AssociationType)
  * 
  * @return void
  */
 private function _writeEntityType(ResourceType $resourceType, $associationTypesInResourceTypeNamespace)
 {
     $this->_xmlWriter->startElement(ODataConstants::ENTITY_TYPE);
     $this->_xmlWriter->writeAttribute(ODataConstants::NAME, $resourceType->getName());
     if ($resourceType->isAbstract()) {
         $this->_xmlWriter->writeAttribute(ODataConstants::ABSTRACT1, "true");
     }
     if ($resourceType->isMediaLinkEntry() && (!$resourceType->hasBaseType() || $resourceType->hasBaseType() && $resourceType->getBaseType()->isMediaLinkEntry())) {
         $this->_xmlWriter->writeAttributeNs(ODataConstants::ODATA_METADATA_NAMESPACE_PREFIX, ODataConstants::DATAWEB_ACCESS_HASSTREAM_ATTRIBUTE, null, "true");
     }
     if ($resourceType->hasBaseType()) {
         $this->_xmlWriter->writeAttribute(ODataConstants::BASE_TYPE, $resourceType->getBaseType()->getFullName());
     } else {
         $this->_xmlWriter->startElement(ODataConstants::KEY);
         foreach ($resourceType->getKeyProperties() as $resourceProperty) {
             $this->_xmlWriter->startElement(ODataConstants::PROPERTY_REF);
             $this->_xmlWriter->writeAttribute(ODataConstants::NAME, $resourceProperty->getName());
             $this->_xmlWriter->endElement();
         }
         $this->_xmlWriter->endElement();
     }
     $this->_writeProperties($resourceType, $associationTypesInResourceTypeNamespace);
     $this->_writeNamedStreams($resourceType);
     $this->_xmlWriter->endElement();
 }