示例#1
0
文件: Backend.php 项目: lucagtc/pdf
 /**
  * Configures this container.
  *
  * @param TempFile $document The html file we will convert.
  *
  * @param array $config Further configuration for this container.
  */
 public function __construct(TempFile $document, $config = [])
 {
     parent::__construct($config);
     $this->document = $document;
 }
示例#2
0
文件: Pdf.php 项目: lucagtc/pdf
 /**
  * Proxy Properties to Backend
  *
  * Once a source document has been supplied and a backend choosen.
  * This will then proxy any unresolved properties through to backend
  * class.
  *
  * The user can then perform further configuration and custmoistation to
  * the backend easily before calling one of the output methods above.
  *
  * @param string $name
  * @param mixed $value
  * @return void
  */
 public function __set($name, $value)
 {
     if ($this->offsetExists($name)) {
         parent::__set($name, $value);
     } else {
         // Due to the fact that the backend class is not intialised until
         // after the main container is configured, we just fail siliently.
         if (!empty($this->backend)) {
             call_user_func([$this->backend, '__set'], $name, $value);
         }
     }
 }
示例#3
0
文件: Backend.php 项目: lucagtc/pdf
 /**
  * Configures this container.
  * 
  * @param TempFile $document The docx file we will convert.
  * 
  * @param array $config Further configuration for this container.
  */
 public function __construct(TempFile $document, $config = [])
 {
     parent::__construct($config);
     $this->template = $document;
     $this->readDocx();
 }
示例#4
0
文件: View.php 项目: phpgearbox/view
 /**
  * Method: __construct
  * =========================================================================
  * Here we configure ourselves and then make sure the cache folder exists.
  * 
  * Example usage:
  * 
  * ```php
  * $view = new Gears\View('/path/to/my/views');
  * echo $view->make('master');
  * ```
  * 
  * > NOTE: If you want to provide a custom cache path. It must be injected
  * > into the constructor. As we check that it exists at construction time.
  * 
  * For example the following will not work:
  * 
  * ```php
  * $view = new Gears\View('/path/to/my/views');
  * $view->cachePath = '/custom/cache/path';
  * ```
  * 
  * But this will work as expected:
  * 
  * ```php
  * $view = new Gears\View('/path/to/my/views',
  * [
  * 		'cachePath' => '/custom/cache/path'
  * ]);
  * ```
  * 
  * Parameters:
  * -------------------------------------------------------------------------
  * n/a
  * 
  * Returns:
  * -------------------------------------------------------------------------
  * void
  * 
  * Throws:
  * -------------------------------------------------------------------------
  * - RuntimeException: When the cache path is not writeable or
  *   we can not create the folder if it doesn't exist.
  */
 public function __construct($viewsPath, $config = [])
 {
     parent::__construct($config);
     if (is_array($viewsPath)) {
         $this->viewsPath = $viewsPath;
     } else {
         $this->viewsPath = [$viewsPath];
     }
     // Make sure the cache folder exists
     if (!is_dir($this->cachePath)) {
         // Lets attempt to create the folder
         if (!mkdir($this->cachePath, 0777, true)) {
             // Bail out we couldn't create the folder
             throw new RuntimeException('Blade Cache Folder could not be created!');
         }
     }
     // Make sure the cache folder is writeable
     if (!is_writeable($this->cachePath)) {
         throw new RuntimeException('Blade Cache Folder not writeable!');
     }
 }
示例#5
0
 /**
  * Method: __call
  * =========================================================================
  * Okay so this is the magic method that makes it possible to do this:
  *
  *     Route::get('/', function(){ return 'Hello World!'; });
  *
  * For more info on how the laravel route api works, please see:
  * http://laravel.com/docs/routing
  * 
  * > NOTE: Due to an odd PHP behaviour we are overriding the DI Containers
  * > __call method and no longer use the __callStatic method. See this
  * > stackoverflow link: http://stackoverflow.com/q/13232445
  *
  * Parameters:
  * -------------------------------------------------------------------------
  * - $name: The name of the method to call.
  * - $args: The argumnent array that is given to us.
  *
  * Returns:
  * -------------------------------------------------------------------------
  * mixed
  * 
  * Throws:
  * -------------------------------------------------------------------------
  * - RuntimeException: When the router has not been installed.
  */
 public function __call($name, $args)
 {
     if ($this->offsetExists($name)) {
         return parent::__call($name, $args);
     } else {
         if (empty(self::$router)) {
             throw new RuntimeException('You need to install a router first!');
         }
         return call_user_func_array([self::$router, $name], $args);
     }
 }