示例#1
0
 /**
  * @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement $xmlElement)
  * @return CultureFeed_Cdb_Data_Calendar_PeriodList
  */
 public static function parseFromCdbXml(SimpleXMLElement $xmlElement)
 {
     $periodList = new CultureFeed_Cdb_Data_Calendar_PeriodList();
     if (!empty($xmlElement->periods->period)) {
         foreach ($xmlElement->periods->period as $periodElement) {
             $periodList->add(CultureFeed_Cdb_Data_Calendar_Period::parseFromCdbXml($periodElement));
         }
     }
     return $periodList;
 }
示例#2
0
 public function testAppendToDOM()
 {
     $from = '2013-12-06';
     $to = '2013-12-25';
     $period = new CultureFeed_Cdb_Data_Calendar_Period($from, $to);
     $scheme = new CultureFeed_Cdb_Data_Calendar_Weekscheme();
     $scheme->monday()->setOpen();
     $scheme->tuesday()->setOpen();
     $scheme->wednesday()->setOpen();
     $scheme->thursday()->setOpenByAppointment();
     $scheme->friday()->setOpen();
     $scheme->saturday()->setClosed();
     $scheme->sunday()->setClosed();
     $period->setWeekScheme($scheme);
     $dom = new DOMDocument('1.0', 'utf8');
     $root = $dom->createElement('calendar');
     $dom->appendChild($root);
     $period->appendToDOM($root);
     $this->assertXmlStringEqualsXmlFile(__DIR__ . '/samples/period.xml', $dom->saveXML());
 }
示例#3
0
文件: Period.php 项目: cultuurnet/cdb
 /**
  * @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement
  *     $xmlElement)
  * @return CultureFeed_Cdb_Data_Calendar_Period
  */
 public static function parseFromCdbXml(SimpleXMLElement $xmlElement)
 {
     if (empty($xmlElement->datefrom)) {
         throw new CultureFeed_Cdb_ParseException("Date from is missing for period");
     }
     if (empty($xmlElement->dateto)) {
         throw new CultureFeed_Cdb_ParseException("Date to is missing for period");
     }
     $period = new CultureFeed_Cdb_Data_Calendar_Period((string) $xmlElement->datefrom, (string) $xmlElement->dateto);
     if (!empty($xmlElement->weekscheme)) {
         $period->setWeekScheme(CultureFeed_Cdb_Data_Calendar_Weekscheme::parseFromCdbXml($xmlElement->weekscheme));
     }
     if (!empty($xmlElement->exceptions)) {
         $period->setExceptions(CultureFeed_Cdb_Data_Calendar_Exceptions::parseFromCdbXml($xmlElement->exceptions));
     }
     return $period;
 }