Exemple #1
0
 /**
  * Load the detail of 1 item.
  * @param string $type
  *   Type of the item. (example: event)
  * @param string $id
  *   ID of the item to load.
  * @return ActivityStatsExtendedEntity
  */
 public function detail($type, $id)
 {
     $response = $this->executeSearch('detail/' . $type . '/' . $id);
     $xmlElement = new SimpleXMLElement($response->getBody(true), 0, false, $this->cdbXmlNamespaceUri);
     $detail = $xmlElement->{$type};
     if (!empty($detail[0])) {
         return ActivityStatsExtendedEntity::fromXml($detail[0]);
     }
 }
Exemple #2
0
 /**
  * Construct the search result based on the given result xml.
  * @param SimpleXMLElement $xmlElement
  * @return \CultuurNet\Search\SearchResult
  */
 public static function fromXml(SimpleXMLElement $xmlElement, $namespace_uri = \CultureFeed_Cdb_Default::CDB_SCHEME_URL)
 {
     $result = new static();
     $result->type = 'cdb';
     $result->namespaceUri = $namespace_uri;
     $result->total = intval($xmlElement->nofrecords);
     // Store parsed version. Set this to NULL before you cache it.
     $result->xmlElement = $xmlElement;
     // Store string version of xml, so the result object can be cached.
     $result->xml = $xmlElement->asXML();
     foreach ($xmlElement as $xmlItem) {
         $entity = ActivityStatsExtendedEntity::fromXml($xmlItem);
         if ($entity) {
             $result->items[] = $entity;
         }
     }
     if (!empty($xmlElement->suggestions)) {
         foreach ($xmlElement->suggestions->suggestion as $suggestionElement) {
             $result->suggestions[] = (string) $suggestionElement;
         }
     }
     return $result;
 }