Example #1
0
 /**
  * 	Sets top-level bill information.
  */
 public function createDoc()
 {
     $this->checkAttr('domdoc');
     $this->setBillTitle();
     $this->setBillSlug();
     $bill = new Doc();
     $bill->title = $this->title;
     $bill->slug = $this->slug;
     $bill->save();
     try {
         $starter = new DocContent();
         $starter->doc_id = $bill->id;
         $starter->content = $this->getBillMeta('legis-type') . ' ' . $this->getBillMeta('official-title');
         $starter->save();
         $bill->init_section = $starter->id;
         $bill->save();
         $this->bill = $bill;
         $rootElement = $this->domdoc->getElementsByTagName($this->rootTag)->item(0);
         $c = 0;
         if (!is_object($rootElement)) {
             throw new Exception("Couldn't retrieve root element");
         }
         foreach ($rootElement->childNodes as $child) {
             $this->saveChildren($child, $starter->id, $c++);
         }
     } catch (Exception $e) {
         $bill->delete();
         $starter->delete();
         throw new Exception($e->getMessage());
     }
     return true;
 }