コード例 #1
0
ファイル: HtmlToPdf.php プロジェクト: bartlewis/code-samples
 /**
  * Initialize the module.
  *
  * Make sure required params are in the application.xml and perform garbage
  * collection.
  *
  * @param TXmlElement
  */
 public function init($config)
 {
     parent::init($config);
     if (!$this->getEnabled()) {
         return;
     }
     if (!$this->getScratchDirectory()) {
         throw new TConfigurationException('Missing param: ScratchDirectory');
     }
     if (!$this->getScript()) {
         throw new TConfigurationException('Missing param: Script');
     }
     //Clean out old files in scratch directory 1 out of every 100 times.
     if (rand(1, 100) == 100) {
         $scratchDirectory = $this->getScratchDirectory();
         $scratchFiles = array();
         foreach (glob($scratchDirectory . '*-htmltopdf-scratch.pdf') as $file) {
             $scratchFiles[] = $file;
         }
         foreach (glob($scratchDirectory . '*-htmltopdf-scratch.html') as $file) {
             $scratchFiles[] = $file;
         }
         //Delete all scratch files created more than an hour ago.
         foreach ($scratchFiles as $scratchFile) {
             if (filectime($scratchFile) < mktime() - 3600) {
                 unlink($scratchFile);
             }
         }
     }
 }
コード例 #2
0
 public function init($config)
 {
     if (!$this->_DBHandler) {
         throw new TConfigurationException('You must set DBHandler property!');
     }
     if (!$this->_UserTable) {
         throw new TConfigurationException('You must set UserTable property!');
     }
     if (!$this->_GroupTable) {
         throw new TConfigurationException('You must set GroupTable property!');
     }
     parent::init($config);
 }
コード例 #3
0
 public function init($config)
 {
     parent::init($config);
 }