/** * Get an actor. * * @param string $id * ID of the actor to load. * * @return CultureFeed_Cdb_Item_Actor * @throws CultureFeed_ParseException */ public function getActor($id) { $result = $this->oauth_client->authenticatedGetAsXml('actor/' . $id); try { $xml = new CultureFeed_SimpleXMLElement($result); } catch (Exception $e) { throw new CultureFeed_ParseException($result); } if ($xml->actor) { $actorXml = $xml->actor; return CultureFeed_Cdb_Item_Actor::parseFromCdbXml($actorXml); } throw new CultureFeed_ParseException($result); }
/** * @expectedException CultureFeed_Cdb_ParseException * @expectedExceptionMessage Actordetails missing for actor element */ public function testParseCdbXmlWithoutActorDetails() { $xml = $this->loadSample('actor-no-actordetails.xml'); CultureFeed_Cdb_Item_Actor::parseFromCdbXml($xml); }
/** * @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement * $xmlElement) * @return CultureFeed_Cdb_Data_Category */ public static function parseFromCdbXml(SimpleXMLElement $xmlElement) { $performer = new CultureFeed_Cdb_Data_Performer(); if (!empty($xmlElement->label)) { $performer->setLabel((string) $xmlElement->label); } if (!empty($xmlElement->role)) { $performer->setRole((string) $xmlElement->role); } if (!empty($xmlElement->actor)) { $performer->setActor(CultureFeed_Cdb_Item_Actor::parseFromCdbXml($xmlElement->actor)); } return $performer; }
/** * @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement * $xmlElement) * @return CultureFeed_Cdb_Data_Location */ public static function parseFromCdbXml(SimpleXMLElement $xmlElement) { if (empty($xmlElement->address)) { throw new CultureFeed_Cdb_ParseException("Address missing for location element"); } $address = CultureFeed_Cdb_Data_Address::parseFromCdbXml($xmlElement->address); $location = new CultureFeed_Cdb_Data_Location($address); if (!empty($xmlElement->label)) { $attributes = $xmlElement->label->attributes(); $location->setLabel((string) $xmlElement->label); if (isset($attributes['cdbid'])) { $location->setCdbid((string) $attributes['cdbid']); } } if (!empty($xmlElement->actor)) { $actor = CultureFeed_Cdb_Item_Actor::parseFromCdbXml($xmlElement->actor); $location->setActor($actor); } return $location; }
/** * @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement $xmlElement) * @return CultureFeed_Cdb_Data_Organiser */ public static function parseFromCdbXml(SimpleXMLElement $xmlElement) { $organiser = new CultureFeed_Cdb_Data_Organiser(); if (empty($xmlElement->label) && empty($xmlElement->actor)) { //throw new CultureFeed_Cdb_ParseException("One of the required fields (actor or label) is missing for organiser element"); } if (!empty($xmlElement->label)) { $organiser->setLabel((string) $xmlElement->label); $attributes = $xmlElement->label->attributes(); if (!empty($attributes->cdbid)) { $organiser->setCdbid((string) $attributes->cdbid); } } elseif (!empty($xmlElement->actor)) { $actor = CultureFeed_Cdb_Item_Actor::parseFromCdbXml($xmlElement->actor); $organiser->setActor($actor); } return $organiser; }
/** * Parse a given xml element to an CultureFeed_Cdb_Item_Base. * @param SimpleXMLElement $xmlElement * XML element from the item to parse. */ public static function parseItem(SimpleXMLElement $xmlElement) { // Return the correct cdb item. switch ($xmlElement->getName()) { case 'event': return CultureFeed_Cdb_Item_Event::parseFromCdbXml($xmlElement); case 'production': return CultureFeed_Cdb_Item_Production::parseFromCdbXml($xmlElement); case 'actor': return CultureFeed_Cdb_Item_Actor::parseFromCdbXml($xmlElement); default: return NULL; } }
/** * @param string $cdbId * @return \CultureFeed_Cdb_Item_Actor|false * @throws \CultureFeed_Cdb_ParseException */ public function getActor($cdbId) { $request = $this->getCnetRequest(); $request->getQuery()->set('q', 'cdbid:' . $cdbId); $request->getQuery()->set('group', 'actor'); try { $response = $request->send(); $responseBody = $response->getBody(true); $xml = simplexml_load_string($responseBody, 'SimpleXMLElement', 0, $this->config->getNameSpace()); $actors = array(); foreach ($xml->actor as $actorXml) { if ($actor = \CultureFeed_Cdb_Item_Actor::parseFromCdbXml($actorXml)) { $actors[] = $actor; } } if (count($actors) != 1) { $this->logger->warning(t('More than one or no Actor found for @cdbid, count: @count', array('@cdbid' => $cdbId, '@count' => count($actors)))); return false; } return $actors[0]; } catch (ClientErrorResponseException $e) { throw $e; } }