public function testParsePage() { $xml = $this->loadSample('page.xml'); $page = CultureFeed_Cdb_Item_Page::parseFromCdbXml($xml); $address = $page->getAddress(); $this->assertInstanceOf('CultureFeed_Cdb_Data_Address_PhysicalAddress', $address); $geo = $address->getGeoInformation(); $this->assertInstanceOf('CultureFeed_Cdb_Data_Address_GeoInformation', $geo); $this->assertEquals(5.3537689, $geo->getXCoordinate()); $this->assertEquals(50.9216401, $geo->getYCoordinate()); }
/** * Create an extended entity based on a given xmlElement. * @param \SimpleXMLElement $xmlElement * Pages search xml element. */ public static function fromPagesXml(\SimpleXMLElement $xmlElement) { $attributes = $xmlElement->attributes(); $type = (string) $attributes['type']; if ($type != 'page') { return NULL; } $cdbItem = \CultureFeed_Cdb_Item_Page::parseFromCdbXml($xmlElement->page); $extendedEntity = new static(); $extendedEntity->type = (string) $attributes['type']; $extendedEntity->id = $cdbItem->getId(); // Add the different activity counts. if (isset($xmlElement->activity)) { foreach ($xmlElement->activity as $activity) { $activityType = (string) $activity->attributes()->type; $extendedEntity->activityCounts[$activityType] = (int) $activity->attributes()->count; } } $extendedEntity->entity = $cdbItem; return $extendedEntity; }
/** * @see CultureFeed_Pages::getPage() */ public function getPage($id) { $result = $this->oauth_client->consumerGetAsXml('page/' . $id); try { $xml = new CultureFeed_SimpleXMLElement($result); } catch (Exception $e) { throw new CultureFeed_ParseException($result); } return CultureFeed_Cdb_Item_Page::parseFromCdbXml($xml); }