PHP Classes

File: GenericView.class.php

Recommend this page to a friend!
  Classes of Diogo Souza da Silva   REST Server   GenericView.class.php   Download  
File: GenericView.class.php
Role: Class source
Content type: text/plain
Description: GenericView class
Class: REST Server
Implement REST Web services servers
Author: By
Last change: big update
Date: 14 years ago
Size: 923 bytes
 

Contents

Class file image Download
<?php

/**
  * Class GenericView
  * A GenericView representation, throws the result of a script into the Response
  */
class GenericView implements RestView {

    protected
$file ;
    protected
$props ;

   
/**
      * Constructor of GenericView
      * @param string $file The script to be rendered
      * @param mixed $props Vars to be passed to the script
      */
   
function __construct($file=null,$props=null) {
        if(
$file != null) $this->file = $file ;
        if(
$props != null) $this->props = $props ;
    }

   
/**
      * Render the selected script
      * @param RestServer $rest
      * @return RestServer
      */
   
function show(RestServer $rest) {
       
ob_start();
       
$params = $this->props ;
        include
$this->file ;
       
$content = ob_get_clean();
       
$rest->getResponse()->setResponse($content);
        return
$rest ;
    }

}
?>