/** * Overloading * * For PHP < 5.3.0, provides access to the getPrevious() method. * * @param string $method * @param array $args * @return mixed */ public function __call($method, array $args) { if ('getprevious' == i::lower($method)) { return $this->_getPrevious(); } return null; }
public function run($method, $parameters = array()) { $class = 'Service_' . ucfirst(\i::lower($this->_name)) . '_' . ucfirst(\i::lower($method)); $code = '<?php' . "\nclass " . $class . "\n{\n"; foreach ($this->_methods as $name => $methodCode) { $code .= "\t" . $methodCode . "\n"; } $code .= '}'; $file = CACHE_PATH . DS . sha1($this->_name . $method . time()) . '.php'; file_put_contents($file, $code); require_once $file; $return = call_user_func_array(array($class, $method), $parameters); unlink($file); return $return; }
/** * @todo use file cache * * @throws Exception * @return string */ protected function _render() { if (mb_strlen($this->_html, 'utf-8') === 0 && empty($this->_url)) { throw new Exception("HTML content or source URL not set."); } if ($this->getUrl()) { $input = $this->getUrl(); } else { File::put($this->getFilePath(), $this->getHtml()); $input = $this->getFilePath(); } $content = $this->_exec(repl('%input%', $input, $this->_getCommand())); if (strpos(i::lower($content['stderr']), 'error')) { throw new Exception("System error <pre>" . $content['stderr'] . "</pre>"); } if (mb_strlen($content['stdout'], 'utf-8') === 0) { throw new Exception("WKHTMLTOPDF didn't return any data."); } if ((int) $content['return'] > 1) { throw new Exception("Shell error, return code : " . (int) $content['return']); } return $content['stdout']; }